Skip to content

Commit 6cb239e

Browse files
committed
Allow phase-modulation for maurer-rose
1 parent 92106a0 commit 6cb239e

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/shimmers/sketches/principles_of_chording.cljs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
(defn rv [x y]
2020
(gv/vec2 (* width x) (* height y)))
2121

22-
(defn maurer-rose [{:keys [samples rotation n d]}]
22+
(defn maurer-rose [{:keys [samples rotation n d pm m]}]
2323
(let [center (rv 0.5 0.5)
2424
radius (* 0.49 height)
2525
rot (tm/radians rotation)]
2626
(->> (for [i (range (inc samples))
2727
:let [k (tm/radians (* d i))]]
2828
(v/+polar center
29-
(* radius (math/sin (+ rot (* n k))))
29+
(* radius (math/sin (+ rot (* n k)
30+
(* pm (math/sin (tm/radians (* m i)))))))
3031
(+ k rot)))
3132
csvg/segmented-path
3233
csvg/path)))
@@ -73,7 +74,11 @@
7374
{:n ((if (dr/chance 0.5) math/round identity)
7475
(dr/random 2 16))
7576
:d ((if (dr/chance 0.3) math/round identity)
76-
(dr/random 2 128))}
77+
(dr/random 2 128))
78+
:pm (if (dr/chance 0.75) 0.0 1.0)
79+
:m (if (dr/chance 0.66) 0.0
80+
(/ (float (dr/random-int 0 64))
81+
(float (dr/weighted {1.0 6 2.0 2 3.0 1 4.0 1}))))}
7782
:chorded
7883
{:n ((if (dr/chance 0.4) math/round identity)
7984
(min (dr/random 0.5 9)
@@ -101,7 +106,11 @@
101106
[ctrl/numeric params "Samples" [:samples] [1 5000 1]]
102107
[ctrl/numeric params "N" [:n] [0.01 360 0.00001]]
103108
(when (not= method :modulo-chords)
104-
[ctrl/numeric params "D" [:d] [0.01 128 0.00001]])]]))
109+
[ctrl/numeric params "D" [:d] [0.01 128 0.00001]])
110+
(when (= method :maurer-rose)
111+
[ctrl/numeric params "Phase M" [:pm] [0.00 16.0 0.001]])
112+
(when (= method :maurer-rose)
113+
[ctrl/numeric params "M" [:m] [0.01 64 0.0001]])]]))
105114

106115
(sketch/definition principles-of-chording
107116
{:created-at "2026-04-14"

0 commit comments

Comments
 (0)