Skip to content

Commit

Permalink
experiment using sin to generate stripes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Nov 17, 2024
1 parent a2a63b1 commit f69324f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/shimmers/sketches/cilia_phase.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
:flat-smooth 1.33
:random 0.66
:random-normal 0.75
:stripes 1.5})
:stripes 1.5
:sin-stripes 1.0})
proportion
(dr/weighted {6 1.0
5.0 1.0
Expand All @@ -106,13 +107,17 @@
{:mode mode
:density
(math/floor (/ (max width height) proportion))}
(when (= mode :stripes)
(case mode
:stripes
(let[primes (sm/primes-between 16 256)
threshold (fn [x] (< x 64))
mul-prime (dr/rand-nth (remove threshold primes))
div-prime (dr/rand-nth (filter threshold primes))]
{:mul-prime mul-prime
:div-prime div-prime})))))
:div-prime div-prime})
:sin-stripes
{:freq (dr/random 0.66 1.33)}
{}))))

(defn samples-from-density [{:keys [mode density] :as pts}]
(case mode
Expand All @@ -134,7 +139,10 @@
:stripes
(let [{:keys [mul-prime div-prime]} pts]
(for [x (range -0.05 1.05 (/ 1.0 density))]
(/ (mod (* x mul-prime) div-prime) div-prime)))))
(/ (mod (* x mul-prime) div-prime) div-prime)))
:sin-stripes
(for [x (range -0.05 1.05 (/ 1.0 density))]
(eq/unit-sin (* eq/TAU (:freq pts) x)))))

(defn line-parameters []
(let [n (dr/weighted {(dr/random-int 3 8) 3.0
Expand Down

0 comments on commit f69324f

Please sign in to comment.