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

Unified Diff: gm/addarc.cpp

Issue 888283002: allow GMs to animate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: switch all existing animations to use animatePulse Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gm/gm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/addarc.cpp
diff --git a/gm/addarc.cpp b/gm/addarc.cpp
index 209fb59aef77cfc66a8dc2fdf8d0a5dda3816870..1386cdd0e78e6a2c985f0b20cdc8c6f2d247b61a 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -10,6 +10,9 @@
#include "SkRandom.h"
class AddArcGM : public skiagm::GM {
+public:
+ AddArcGM() : fRotate(0) {}
+
protected:
SkString onShortName() SK_OVERRIDE { return SkString("addarc"); }
@@ -29,20 +32,30 @@ protected:
const SkScalar sweepAngle = 345;
SkRandom rand;
+ SkScalar sign = 1;
while (r.width() > paint.getStrokeWidth() * 3) {
paint.setColor(rand.nextU() | (0xFF << 24));
SkScalar startAngle = rand.nextUScalar1() * 360;
+ SkScalar speed = SkScalarSqrt(16 / r.width()) * 0.5f;
+ startAngle += fRotate * 360 * speed * sign;
+
SkPath path;
path.addArc(r, startAngle, sweepAngle);
canvas->drawPath(path, paint);
r.inset(inset, inset);
-
+ sign = -sign;
}
}
+ bool onAnimatePulse(SkMSec curr, SkMSec prev) SK_OVERRIDE {
+ fRotate = SkDoubleToScalar(fmod(curr * 0.001, 360));
+ return true;
+ }
+
private:
+ SkScalar fRotate;
typedef skiagm::GM INHERITED;
};
DEF_GM( return new AddArcGM; )
« no previous file with comments | « no previous file | gm/gm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698