Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: samplecode/SampleDegenerateTwoPtRadials.cpp

Issue 894083003: add SkAnimTimer, SPACE = pause/resume, ESP = stop (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
OLDNEW
« gm/SkAnimTimer.h ('K') | « samplecode/SampleCode.h ('k') | samplecode/SampleHT.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698