From 48ab4e73f9250d0f3a242419a59652d4ae1a710c Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 30 Nov 2014 19:08:25 -0500 Subject: math: tween: Memoize iterpolation procedure. * sly/math/tween.scm (tween): Memoize interpolator. --- sly/math/tween.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)))))) -- cgit v1.2.3