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

Unified Diff: gm/SkAnimTimer.h

Issue 1974353003: Add blurcircles2 GM (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: more warning fixes Created 4 years, 7 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/blurcircles2.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/SkAnimTimer.h
diff --git a/gm/SkAnimTimer.h b/gm/SkAnimTimer.h
index 2c8a723e5bb970d0799e1a802536ad5e6715b95a..060de00c2e997ec702738de1325dc31194bceabb 100644
--- a/gm/SkAnimTimer.h
+++ b/gm/SkAnimTimer.h
@@ -104,6 +104,23 @@ public:
return SkDoubleToScalar(value);
}
+ /**
+ * Transitions from ends->mid->ends linearly over period seconds. The phase specifies a phase
+ * shift in seconds.
+ */
+ SkScalar pingPong(SkScalar period, SkScalar phase, SkScalar ends, SkScalar mid) const {
+ return PingPong(this->secs(), period, phase, ends, mid);
+ }
+
+ /** Helper for computing a ping-pong value without a SkAnimTimer object. */
+ static SkScalar PingPong(double t, SkScalar period, SkScalar phase, SkScalar ends,
+ SkScalar mid) {
+ double value = ::fmod(t + phase, period);
+ double half = period / 2.0;
+ double diff = ::fabs(value - half);
+ return SkDoubleToScalar(ends + (1.0 - diff / half) * (mid - ends));
+ }
+
private:
double fBaseTimeNanos;
double fCurrTimeNanos;
« no previous file with comments | « no previous file | gm/blurcircles2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698