| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkView.h" | 9 #include "SkView.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 DrawTheText(canvas, text, length, SkIntToScalar(110), y, paint); | 126 DrawTheText(canvas, text, length, SkIntToScalar(110), y, paint); |
| 127 } | 127 } |
| 128 canvas->restore(); | 128 canvas->restore(); |
| 129 | 129 |
| 130 paint.setTextSize(16); | 130 paint.setTextSize(16); |
| 131 // canvas->drawText(outString.c_str(), outString.size(), 512.f, 540.f, pa
int); | 131 // canvas->drawText(outString.c_str(), outString.size(), 512.f, 540.f, pa
int); |
| 132 canvas->drawText(modeString.c_str(), modeString.size(), 768.f, 540.f, pa
int); | 132 canvas->drawText(modeString.c_str(), modeString.size(), 768.f, 540.f, pa
int); |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool onAnimate(const SkAnimTimer& timer) override { | 135 bool onAnimate(const SkAnimTimer& timer) override { |
| 136 // We add noise to the scale and rotation animations to | 136 // We add noise to the scale and rotation animations to |
| 137 // keep the font atlas from falling into a steady state | 137 // keep the font atlas from falling into a steady state |
| 138 fRotation += (1.0f + gRand.nextRangeF(-0.1f, 0.1f)); | 138 fRotation += (1.0f + gRand.nextRangeF(-0.1f, 0.1f)); |
| 139 fScale += (fScaleInc + gRand.nextRangeF(-0.025f, 0.025f)); | 139 fScale += (fScaleInc + gRand.nextRangeF(-0.025f, 0.025f)); |
| 140 if (fScale >= 2.0f) { | 140 if (fScale >= 2.0f) { |
| 141 fScaleInc = -0.1f; | 141 fScaleInc = -0.1f; |
| 142 } else if (fScale <= 1.0f) { | 142 } else if (fScale <= 1.0f) { |
| 143 fScaleInc = 0.1f; | 143 fScaleInc = 0.1f; |
| 144 } | 144 } |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 private: | 148 private: |
| 149 float fScale; | 149 float fScale; |
| 150 float fScaleInc; | 150 float fScaleInc; |
| 151 float fRotation; | 151 float fRotation; |
| 152 int fSizeScale; | 152 int fSizeScale; |
| 153 | 153 |
| 154 WallTimer fTimer; | 154 WallTimer fTimer; |
| 155 float fTimes[32]; | 155 float fTimes[32]; |
| 156 int fCurrentTime; | 156 int fCurrentTime; |
| 157 | 157 |
| 158 | 158 |
| 159 typedef SampleView INHERITED; | 159 typedef SampleView INHERITED; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 ////////////////////////////////////////////////////////////////////////////// | 162 ////////////////////////////////////////////////////////////////////////////// |
| 163 | 163 |
| 164 static SkView* MyFactory() { return new AnimatedTextView; } | 164 static SkView* MyFactory() { return new AnimatedTextView; } |
| 165 static SkViewRegister reg(MyFactory); | 165 static SkViewRegister reg(MyFactory); |
| OLD | NEW |