Skip to content

Commit

Permalink
extract common sqrt-d calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Jan 18, 2024
1 parent 0685f72 commit f703904
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/shimmers/sketches/hexpansion.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@
centroid (g/centroid hex)
[cx cy] centroid
d (/ (tm/mag centroid) mmag)
sqrt-d (Math/sqrt d)
scale-factor (Math/sin (* 0.02 (+ (* 0.55 t cx) (* 0.65 t cy))))
scale (+ (- 0.9 d) (* 0.2 scale-factor))
rot (* Math/PI (Math/cos (+ (* 0.5 t)
(* 2 (Math/sin (* 0.5 (+ (/ t (+ 1 cx)) (/ t (+ 1 cy)))))))))]]
(-> hex
(g/scale-size scale)
(g/rotate (* (Math/sqrt d) spiral-rot))
(g/scale (+ 1 (* 0.5 (Math/sqrt d)
(g/rotate (* sqrt-d spiral-rot))
(g/scale (+ 1 (* 0.5 sqrt-d
duty-scale
(tm/smoothstep* 0.25 1.0 scale-factor))))
(g/vertices 6)
Expand Down

0 comments on commit f703904

Please sign in to comment.