Skip to content

Commit

Permalink
experiment with circular-repeition
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed May 31, 2024
1 parent 681ea0b commit 720c520
Show file tree
Hide file tree
Showing 2 changed files with 49 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 @@ -33,6 +33,7 @@
shimmers.sketches.circle-hatch
shimmers.sketches.circle-packing
shimmers.sketches.circuit-intersections
shimmers.sketches.circular-repetition
shimmers.sketches.clothoid-flowers
shimmers.sketches.clothoids
shimmers.sketches.clustered-farmlands
Expand Down
48 changes: 48 additions & 0 deletions src/shimmers/sketches/circular_repetition.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
(ns shimmers.sketches.circular-repetition
(:require
[clojure.math :as math]
[quil.core :as q :include-macros true]
[quil.middleware :as m]
[shimmers.common.framerate :as framerate]
[shimmers.common.quil :as cq]
[shimmers.common.ui.controls :as ctrl]
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.sketch :as sketch :include-macros true]
[thi.ng.geom.vector :as gv]))

(defn setup []
(q/color-mode :hsl 1.0)
(q/ellipse-mode :radius)
(q/stroke-weight 0.5)
{:weights (repeatedly 3 #(dr/random -0.1 0.1))
:osc (repeatedly 3 #(dr/random -0.2 0.2))})

(defn draw [{[a b c] :weights [o1 o2 o3] :osc}]
(q/background 1.0)
(q/with-translation [(cq/rel-vec 0.0 0.0)]
(let [center (gv/vec2 0 0)
r (cq/rel-h 0.4)
t (/ (q/millis) 2000.0)]
(dotimes [i 360]
(q/push-matrix)
(q/rotate-z (mod (+ (* c (+ t i)) (* 2 (Math/sin (* o3 t)))) eq/TAU))
(q/rotate-y (mod (+ (* b (+ t i)) (* 2 (math/sin (* o2 t)))) eq/TAU))
(q/rotate-x (mod (+ (* a (+ t i)) (* 2 (math/sin (* o1 t)))) eq/TAU))
(cq/circle center r)
(q/pop-matrix)))))

(defn page []
[:div
(sketch/component
:size [800 600]
:renderer :p3d
:setup setup
:draw draw
:middleware [m/fun-mode framerate/mode])])

(sketch/definition circular-repetition
{:created-at "2024-05-31"
:tags #{}
:type :quil}
(ctrl/mount page))

0 comments on commit 720c520

Please sign in to comment.