From 084d135df45a13e173adb32e5be0cad9d0dab1d6 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 24 Jul 2019 14:42:49 +0900 Subject: [PATCH] Optimized spiral --- examples/demo/spiral.lisp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/demo/spiral.lisp b/examples/demo/spiral.lisp index 77e8b0a..33ca57c 100644 --- a/examples/demo/spiral.lisp +++ b/examples/demo/spiral.lisp @@ -1,20 +1,18 @@ ; animated recusive spiral ; by @local_guru - -; (defn rec (v) (if (gt v 0) - ((stroke - (circle - (add 375 (mul (cos (add (div v 17) (div (time) 2000))) (div v 2))) - (add 300 (mul (sin (div v 11)) (div v 2))) - (div v 2)) 1 "rgba(114,222, 194,0.1)") - (rec (sub v 0.3))))) + ( + ; params + (def spiral-x (add (of (frame) :c) (mul (cos (add (div v 17) (time 0.001))) (div v 2)))) + (def spiral-y (add (of (frame) :m) (mul (sin (div v 11)) (div v 2)))) + (def spiral-r (div v 2)) + ; draw + (stroke (circle spiral-x spiral-y spiral-r) 1 "rgba(114,222,194,0.1)") (rec (sub v 0.3))))) ; (defn redraw () ( (clear) - (rec 300) -)) + (rec 300))) ; (on "animate" redraw) \ No newline at end of file