diff --git a/examples/events/on-animate.lisp b/examples/events/on-animate.lisp index 276fa84..67cfabf 100644 --- a/examples/events/on-animate.lisp +++ b/examples/events/on-animate.lisp @@ -1,9 +1,10 @@ ; this demo shows how to use the animate event to animate lines into a sine wave. + ; (def seg-count 50) ; (def seg-width - (div frame:w seg-count)) + (div frame:w seg-count)) ; (defn elevation (i) @@ -13,29 +14,35 @@ (add (time 0.001) (div i 5))) - (div frame:h 5)) frame:m)) + (div frame:h 5)) 300)) ; (defn draw-dash (i) - ( - (def x - (mul - (sub i 1) seg-width)) - (def y - (elevation i)) - (stroke - (line x - (elevation - (sub i 1)) - (add x seg-width) + (if + (gt i 0) + ( + (def x + (mul + (sub i 1) seg-width)) + (def y (elevation i)) - (gradient - (line 50 0 frame:w 0) - ("#ffb545" "#72dec2")) 4 ))) + (stroke + (line x + (elevation + (sub i 1)) + (add x seg-width) + (elevation i)) + (gradient + (line 50 0 frame:w 0) + ("#ffb545" "#72dec2")) 4) + (draw-dash + (sub i 1))) )) + ; -(defn redraw - () +(defn redraw () ( + (clear) - (times seg-count draw-dash))) -(on "animate" redraw) \ No newline at end of file + (draw-dash seg-count))) + +(on "animate" redraw)