Skip to content

Commit

Permalink
use helix rendering on the path
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Apr 28, 2024
1 parent 2ca83ba commit f5977de
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/shimmers/sketches/helix.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
[clojure.math :as math]
[shimmers.common.svg :as csvg :include-macros true]
[shimmers.common.ui.controls :as ctrl]
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.math.vector :as v]
[shimmers.sketch :as sketch :include-macros true]
[shimmers.view.sketch :as view-sketch]
[thi.ng.geom.circle :as gc]
[thi.ng.geom.core :as g]
[thi.ng.geom.line :as gl]
[thi.ng.geom.vector :as gv]
[thi.ng.math.core :as tm]
[shimmers.math.deterministic-random :as dr]))
[thi.ng.math.core :as tm]))

(def width 800)
(def height 600)
Expand All @@ -24,8 +26,9 @@
(math/sin (* eq/TAU (+ (* s f) p))))

(defn fractional []
(/ (dr/random-int 1 10)
(dr/random-int 1 6)))
(+ (/ (dr/random-int 1 8)
(dr/random-int 1 5))
(dr/gaussian 0.0 0.1)))

(defn harmonic-loop [center radius a b c]
(for [s (tm/norm-range 256)]
Expand All @@ -37,7 +40,19 @@
(tm/+ center))))

(defn shapes [a b c]
(gl/linestrip2 (harmonic-loop (rv 0.5 0.5) (* 0.45 height) a b c)))
(let [pts (harmonic-loop (rv 0.5 0.5) (* 0.45 height) a b c)
r (* 0.0066 height)]
(for [[p q] (partition 2 1 pts)]
(let [z (tm/- q p)
delta (g/rotate z (/ eq/TAU 4))
left (tm/+ p delta)
right (tm/- p delta)
line-delta (tm/normalize delta (- (tm/mag delta) r))]
(csvg/group {}
(gc/circle left r)
(gc/circle right r)
(gl/line2 (tm/+ p line-delta)
(tm/- p line-delta)))))))

(defn scene [a b c]
(csvg/svg-timed {:width width
Expand All @@ -49,8 +64,8 @@

(defn page []
(let [a (fractional)
b (fractional)
c (* -2 (fractional))]
b (- (fractional))
c (* -3 (fractional))]
(fn []
[sketch/with-explanation
[:div.canvas-frame [scene a b c]]
Expand Down

0 comments on commit f5977de

Please sign in to comment.