diff options
-rw-r--r-- | animise.lisp | 18 | ||||
-rw-r--r-- | package.lisp | 28 |
2 files changed, 41 insertions, 5 deletions
diff --git a/animise.lisp b/animise.lisp index 5ba2d86..8c6e54a 100644 --- a/animise.lisp +++ b/animise.lisp @@ -22,6 +22,15 @@ (- current (+ start (* 0.5 duration)))) delta))))) + +;;; The DEF-EASE macro defines a function. the BODY of the function has the +;;; following variables available to it: +;;; START the start time in MS +;;; DURATION intended duration of this animation +;;; CURRENT the current time, sometime after START +;;; DELTA, a number, the total change in the value being animated (e.g. X coordinate) +;;; FRAC, a number between 0 and 1, the how close to completion this animation is. + (def-ease linear (* delta frac)) (def-mirror-for linear) @@ -109,16 +118,17 @@ (def-mirror-for bounce-out) -(defun frames (ease-fn &optional (step 0.1)) + +;;; Some functions to check your intuitions about the output of easing functions + +(defun make-frames (ease-fn &optional (step 0.1)) (loop :for time :from 0 :upto (+ 1 step) :by step :collect (funcall ease-fn 0 1.0 time))) (defun print-frames (fn &key (width 20) (mark #\.) (step 0.1)) - (loop for frame in (frames fn step) do + (loop for frame in (make-frames fn step) do (dotimes (x width) (princ #\Space)) (dotimes (x (round (* frame width))) (princ #\Space)) (princ mark) (terpri))) - - diff --git a/package.lisp b/package.lisp index c71ecb8..9516b26 100644 --- a/package.lisp +++ b/package.lisp @@ -1,4 +1,30 @@ ;;;; package.lisp (defpackage #:animise - (:use #:cl)) + (:use #:cl) + (:export + #:linear + #:mirror-linear + #:quad-in + #:quad-out + #:mirror-quad-in + #:mirror-quad-out + #:quad-in-out + #:mirror-quad-in-out + #:cubic-in + #:cubic-out + #:mirror-cubic-in + #:mirror-cubic-out + #:cubic-in-out + #:mirror-cubic-in-out + #:sinusoidal-in + #:mirror-sinusoidal-in + #:sinusoidal-out + #:mirror-sinusoidal-out + #:sinusoidal-in-out + #:mirror-sinusoidal-in-out + #:elastic-out + #:mirror-elastic-out + #:bouce-out + #:mirror-bounce-out + )) |