summaryrefslogtreecommitdiff
path: root/sly/math
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-11-30 19:08:25 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-11-30 19:09:30 -0500
commit48ab4e73f9250d0f3a242419a59652d4ae1a710c (patch)
tree285fefcd649712d4e26fd69c6e660ad007435e8b /sly/math
parent957249f3cab47785e4f153fc3719b7de5ea85114 (diff)
math: tween: Memoize iterpolation procedure.
* sly/math/tween.scm (tween): Memoize interpolator.
Diffstat (limited to 'sly/math')
-rw-r--r--sly/math/tween.scm8
1 files changed, 7 insertions, 1 deletions
diff --git a/sly/math/tween.scm b/sly/math/tween.scm
index 46c1384..3c88d4a 100644
--- a/sly/math/tween.scm
+++ b/sly/math/tween.scm
@@ -23,6 +23,7 @@
(define-module (sly math tween)
#:use-module (sly math)
+ #:use-module (sly utils)
#:export (ease-loop ease-reflect ease-linear
ease-in-sine ease-out-sine ease-in-out-sine
ease-in-quad ease-out-quad ease-in-out-quad
@@ -103,5 +104,10 @@ ticks. The value returned for a given time is determined by applying
EASE with the time ratio to acquire an 'alpha' value, and then
applying INTERPOLATOR with START, END, and alpha. Alpha is a rational
number in the range [0, 1]."
+ (define interpolate
+ (memoize
+ (lambda (alpha)
+ (interpolator start end alpha))))
+
(lambda (time)
- (interpolator start end (clamp 0 1 (ease (/ time duration))))))
+ (interpolate (clamp 0 1 (ease (/ time duration))))))