From f5977ded1a898eecf8b28739ccfd95a0106c70dc Mon Sep 17 00:00:00 2001 From: Charles Comstock Date: Sat, 27 Apr 2024 20:05:52 -0500 Subject: [PATCH] use helix rendering on the path --- src/shimmers/sketches/helix.cljs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/shimmers/sketches/helix.cljs b/src/shimmers/sketches/helix.cljs index ca1d7016c..60e844988 100644 --- a/src/shimmers/sketches/helix.cljs +++ b/src/shimmers/sketches/helix.cljs @@ -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) @@ -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)] @@ -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 @@ -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]]