OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkAnimTimer.h" |
9 #include "SkView.h" | 10 #include "SkView.h" |
10 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
11 #include "SkGradientShader.h" | 12 #include "SkGradientShader.h" |
12 #include "SkString.h" | 13 #include "SkString.h" |
13 | 14 |
14 static void draw_gradient2(SkCanvas* canvas, const SkRect& rect, SkScalar delta)
{ | 15 static void draw_gradient2(SkCanvas* canvas, const SkRect& rect, SkScalar delta)
{ |
15 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorMAGEN
TA }; | 16 SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorMAGEN
TA }; |
16 SkScalar pos[] = { 0, 0.25f, 0.75f, SK_Scalar1 }; | 17 SkScalar pos[] = { 0, 0.25f, 0.75f, SK_Scalar1 }; |
17 | 18 |
18 SkScalar l = rect.fLeft; | 19 SkScalar l = rect.fLeft; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 SkScalar t = SK_Scalar1 * 100; | 70 SkScalar t = SK_Scalar1 * 100; |
70 draw_gradient2(canvas, SkRect::MakeXYWH(l, t, w, h), delta); | 71 draw_gradient2(canvas, SkRect::MakeXYWH(l, t, w, h), delta); |
71 SkString txt; | 72 SkString txt; |
72 txt.appendf("gap at \"tangent\" pt = %f", SkScalarToFloat(delta)); | 73 txt.appendf("gap at \"tangent\" pt = %f", SkScalarToFloat(delta)); |
73 SkPaint paint; | 74 SkPaint paint; |
74 paint.setAntiAlias(true); | 75 paint.setAntiAlias(true); |
75 paint.setColor(SK_ColorBLACK); | 76 paint.setColor(SK_ColorBLACK); |
76 canvas->drawText(txt.c_str(), txt.size(), l + w/2 + w*DELTA_SCALE*delta,
t + h + SK_Scalar1 * 10, paint); | 77 canvas->drawText(txt.c_str(), txt.size(), l + w/2 + w*DELTA_SCALE*delta,
t + h + SK_Scalar1 * 10, paint); |
77 } | 78 } |
78 | 79 |
79 bool onAnimatePulse(SkMSec curr, SkMSec prev) SK_OVERRIDE { | 80 bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE { |
80 fTime += (curr - prev) * 0.001f; | 81 fTime = SkDoubleToScalar(timer.secs() / 15); |
81 return true; | 82 return true; |
82 } | 83 } |
83 | 84 |
84 private: | 85 private: |
85 SkScalar fTime; | 86 SkScalar fTime; |
86 typedef SampleView INHERITED; | 87 typedef SampleView INHERITED; |
87 }; | 88 }; |
88 | 89 |
89 ////////////////////////////////////////////////////////////////////////////// | 90 ////////////////////////////////////////////////////////////////////////////// |
90 | 91 |
91 static SkView* MyFactory() { return new DegenerateTwoPtRadialsView; } | 92 static SkView* MyFactory() { return new DegenerateTwoPtRadialsView; } |
92 static SkViewRegister reg(MyFactory); | 93 static SkViewRegister reg(MyFactory); |
OLD | NEW |