aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-04-04 14:17:36 +0200
committerThomas White <taw@physics.org>2021-04-04 14:17:36 +0200
commita98d9ab8c9c3ec12df621861170ab2a3b8c69d82 (patch)
tree4634f8d34fc320854ec929c60b33fcf04528a74f
parent6d54086fc0814e55dfb80ebe36c16e53bed3401a (diff)
Actually fade attribute values (when appropriate)
-rw-r--r--guile/starlet/playback.scm49
1 files changed, 35 insertions, 14 deletions
diff --git a/guile/starlet/playback.scm b/guile/starlet/playback.scm
index b580d7b..c9153d8 100644
--- a/guile/starlet/playback.scm
+++ b/guile/starlet/playback.scm
@@ -311,23 +311,44 @@
(define (make-continuous-attr-fade start-val
target-val
preset-val
- fade-times
+ fade-time
fade-start-time
preset-time
preset-start-time)
- (lambda (time)
-
- ;; FIXME: If target value is a number, do a fade
- ;; (if starting value is a function, freeze it)
- (cond
-
- ((< time fade-start-time) start-val)
-
- ((and (not (eq? 'no-value preset-val))
- (> time preset-start-time))
- preset-val)
-
- (else target-val))))
+ (if (and (number? target-val)
+ (not (eq? start-val 'no-value)))
+
+ ;; It makes sense to do a fade
+ (let ((real-start-val (value->number start-val fade-start-time)))
+ (lambda (time)
+ (cond
+ ((< time fade-start-time) start-val)
+
+ ((and (not (eq? 'no-value preset-val))
+ (> time preset-start-time))
+ (simple-fade target-val
+ preset-val
+ preset-time
+ preset-start-time
+ time))
+
+ (else
+ (simple-fade real-start-val
+ target-val
+ fade-time
+ fade-start-time
+ time)))))
+
+ ;; A fade doesn't make sense, so make do with a snap transition
+ (lambda (time)
+ (cond
+ ((< time fade-start-time) start-val)
+
+ ((and (not (eq? 'no-value preset-val))
+ (> time preset-start-time))
+ preset-val)
+
+ (else target-val)))))
(define (match-fix-attr attr-el fix attr)