Skip to content

Commit

Permalink
yet another spiral sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Feb 11, 2024
1 parent 78e23d7 commit 9a0026c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/shimmers/sketches.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
shimmers.sketches.sphere
shimmers.sketches.spiderwebs
shimmers.sketches.spin-doctor
shimmers.sketches.spiral-approach
shimmers.sketches.spiral-distance
shimmers.sketches.spiral-pack
shimmers.sketches.splitting-polygons
Expand Down
53 changes: 53 additions & 0 deletions src/shimmers/sketches/spiral_approach.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
(ns shimmers.sketches.spiral-approach
(:require
[shimmers.common.svg :as csvg :include-macros true]
[shimmers.common.ui.controls :as ctrl]
[shimmers.sketch :as sketch :include-macros true]
[shimmers.view.sketch :as view-sketch]
[thi.ng.geom.vector :as gv]
[shimmers.math.vector :as v]
[thi.ng.math.core :as tm]
[shimmers.math.equations :as eq]
[thi.ng.geom.line :as gl]
[shimmers.math.deterministic-random :as dr]))

(def width 800)
(def height 600)
(defn rv [x y]
(gv/vec2 (* width x) (* height y)))

(defn spiral [p n v s]
(for [f (tm/norm-range n)
:let [t (+ f s)]]
(v/+polar p
(* tm/PHI (Math/pow v (+ s (* 9 t))))
(* 7 t eq/TAU))))

(defn shapes []
(for [_s (tm/norm-range 10)]
(gl/linestrip2 (spiral (rv 0.5 0.5)
(dr/random-int 1500 2500)
(+ tm/PHI (dr/gaussian 0.0 0.2))
(dr/gaussian 0.2 0.1)))))

(defn scene []
(csvg/svg-timed {:width width
:height height
:stroke "black"
:fill "white"
:stroke-width 0.66}
(shapes)))

(defn page []
(fn []
[sketch/with-explanation
[:div.canvas-frame [scene]]
[view-sketch/generate :spiral-approach]
[:div.readable-width
"Experimenting with varying the exponential factor of a spiral."]]))

(sketch/definition spiral-approach
{:created-at "2024-02-10"
:tags #{}
:type :svg}
(ctrl/mount page))

0 comments on commit 9a0026c

Please sign in to comment.