summaryrefslogtreecommitdiff
path: root/README.org
blob: 05b4b51c115783b6f243c8257951e04fff0f2e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

* Animise

  /General purpose tweens and easing/ 

  Animise is a small library that you may use to orchestrate any time-varying
  numerical values. While animise is intended to be used as a general purpose
  [[https://en.wikipedia.org/wiki/Inbetweening][tweening]] solution for your Common Lisp projects, you could use it for other
  purposes as well (e.g. modulating audio signals).

  As a taste of the animise language, here is a snip from an [[https://github.com/thegoofist/animise-examples][example]] that
  animates a box with SDL2:

(**NOTE**: These gifs are jumpier looking than the "real thing" - 
my gif recorder makes chopy gifs I guess :()

  #+begin_src lisp
;; ... snip

(let* ((rect (sdl2:make-rect 0 0 100 100))
         (color (list 255 0 0 255))

         (anim (sequencing (:loop-mode :looping :targeting rect)
                 (pausing :for 200 :start (sdl2:get-ticks))
                 (grouping (:with-duration 1200)
                   (animating :linearly :the 'cadddr :of color :to 0)
                   (animating :quading-out :the 'sdl2:rect-x :to 400)
                   (animating :bouncing-out :the 'sdl2:rect-y :to 300))
                 (grouping (:with-duration 1000)
                   (animating :linearly :the 'cadddr :of color :to 255)
                   (animating :elastically-out :the 'sdl2:rect-x :to 0))
                 (animating :cubically-in-out :the 'sdl2:rect-y :to 0 :for 800))))

 ;; ... snip
  
  #+end_src

And here is what the above looks like

[[.images/animise-eg-3.gif]]


*** Another example

[[.images/eg1.gif]] 

#+begin_src lisp

  (let* ((rect (sdl2:make-rect 0 0 100 100))
         (dur 2200)
         (dur/3 (round (/ dur 3)))
         (anim
           (sequencing (:loop-mode :looping :targeting rect)
             (grouping (:for dur)
               ;; only the first member of a sequence needs a real start time
               (animating :elastically-out :starting (sdl2:get-ticks) :the 'sdl2:rect-x :to 500)
               (animating :quading-out :the 'sdl2:rect-height :to 20)
               (animating :quading-out :the 'sdl2:rect-width :to 20))
             (grouping (:for dur)
               (animating :quading-out :the 'sdl2:rect-width :to 100)
               (animating :quading-out :the 'sdl2:rect-height :to 100)
               (animating :bouncing-out :the 'sdl2:rect-x :to 0))))
         (other-anim
           (sequencing (:targeting rect :loop-mode :looping)
             ;; again, first member of a sequence
             (animating :quading-in-out :the 'sdl2:rect-y :to 150 :for dur/3 :starting (sdl2:get-ticks))
             (animating :quading-in-out :the 'sdl2:rect-y :to 0 :for dur/3))))

#+end_src

Then to update each of the animations `anim` and `other-anim`, the above calls

#+begin_src lisp

                   (animise:run-tween anim (sdl2:get-ticks))
                   (animise:run-tween other-anim (sdl2:get-ticks))

#+end_src

before the start of the rendering step.