Skip to content

Commit

Permalink
push parameters for density into the line parameter map
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Nov 16, 2024
1 parent ce50064 commit d131a60
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/shimmers/sketches/cilia_phase.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,19 @@
2.25 0.75
2.0 0.5
1.5 0.25})]
{:mode mode
:density
(math/floor (/ (max width height) proportion))}))

(defn samples-from-density [{:keys [mode density]}]
(merge
{:mode mode
:density
(math/floor (/ (max width height) proportion))}
(when (= 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})))))

(defn samples-from-density [{:keys [mode density] :as pts}]
(case mode
:equal (range -0.05 1.05 (/ 1.0 density))
:gaussian
Expand All @@ -124,10 +132,7 @@
(repeatedly (* 0.8 density)
#(dr/sample-between (dr/gaussian 0.5 0.15) 0 1))
: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))]
(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)))))

Expand Down

0 comments on commit d131a60

Please sign in to comment.