-
Notifications
You must be signed in to change notification settings - Fork 1
/
vortex.fnl
23 lines (21 loc) · 938 Bytes
/
vortex.fnl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{:create (fn [x y radius]
{:x x :y y :radius radius :index 1 :t 0 :tt 0})
:update (fn [vortex t]
(set vortex.t (+ vortex.t t))
(when (> vortex.t 1)
(set vortex.t 0)))
:center-and-radius (fn [vortex]
{:center {:x vortex.x :y vortex.y}
:radius vortex.radius})
:draw (fn [vortex]
(let [circles 10
gi (if (> vortex.t 0.5) 1
(- circles (math.floor (* 2 vortex.t circles))))
lw (/ vortex.radius circles)]
(for [i 1 circles]
(love.graphics.setColor 255 (+ 13 (* i 20)) 255
(if (= gi i) 255 60))
(love.graphics.setLineWidth 3)
(love.graphics.circle (if (= i 1) "fill" "line")
vortex.x vortex.y
(* i lw)))))}