Skip to content

Commit

Permalink
draw triangles or squares depending on another noise field
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Jan 22, 2025
1 parent 9d8cd73 commit 2b7a47b
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/shimmers/sketches/blustery_day.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
[shimmers.common.ui.svg :as usvg]
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.math.geometry.triangle :as triangle]
[shimmers.math.vector :as v]
[shimmers.sketch :as sketch :include-macros true]
[thi.ng.geom.circle :as gc]
[thi.ng.geom.core :as g]
[thi.ng.geom.rect :as rect]
[thi.ng.geom.vector :as gv]
[thi.ng.math.core :as tm]))

Expand All @@ -21,17 +23,27 @@
(for [cell (g/subdivide bounds {:cols (/ width 5)
:rows (/ height 5)})
:let [p (g/centroid cell)
[x y] p
dir-noise (dr/noise-at-point-01 seed 0.0025 p)
amp-noise (dr/noise-at-point-01 seed 0.0025 (tm/+ p (:size bounds)))
size-noise (dr/noise-at-point-01 seed 0.0025 (tm/+ p (tm/* (:size bounds) 2)))
jitter-noise (dr/noise-at-point-01 seed 0.0025 (tm/+ p (tm/* (:size bounds) 3)))]
jitter-noise (dr/noise-at-point-01 seed 0.0025 (tm/+ p (tm/* (:size bounds) 3)))
shape-noise (dr/noise-at-point-01 seed 0.0025 (tm/+ p (tm/* (:size bounds) 4)))
angle (* 1.5 eq/TAU dir-noise)]
:when (< (dr/gaussian 0.0 (tm/smoothstep* 0.5 1.0 jitter-noise)) 1.0)]
(gc/circle (-> p
(v/+polar (* 32.0 amp-noise) (* 1.5 eq/TAU dir-noise))
(v/+polar (* 0.75 (dr/gaussian 0.0 (tm/smoothstep* 0.5 1.0 jitter-noise)))
(dr/random-tau)))
(+ 0.5 (* 2.0 size-noise)))))
(let [c (gc/circle (-> p
(v/+polar (* 32.0 amp-noise) angle)
(v/+polar (* 0.75 (dr/gaussian 0.0 (tm/smoothstep* 0.5 1.0 jitter-noise)))
(dr/random-tau)))
(+ 0.5 (* 2.0 size-noise)))]
(cond (< shape-noise 0.2)
(-> (* 1.1 (:r c))
rect/rect
g/center
(g/rotate angle)
(g/translate (:p c)))
(> shape-noise 0.8)
(triangle/inscribed-equilateral (:p c) (* 1.1 (:r c)) angle)
:else c))))

(defn scene [{:keys [scene-id]}]
(csvg/svg-timed {:id scene-id
Expand Down

0 comments on commit 2b7a47b

Please sign in to comment.