Skip to content

Commit

Permalink
circle textured ley-lines
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Aug 10, 2024
1 parent 2f6ba4a commit ca77ac1
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/shimmers/sketches.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
shimmers.sketches.lattice-in-steps
shimmers.sketches.lattice-of-common-chords
shimmers.sketches.layered-intersections
shimmers.sketches.ley-lines
shimmers.sketches.lifecycle-of-shapes
shimmers.sketches.light-and-dark
shimmers.sketches.liminal-tension
Expand Down
63 changes: 63 additions & 0 deletions src/shimmers/sketches/ley_lines.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
(ns shimmers.sketches.ley-lines
(:require
[shimmers.algorithm.random-points :as rp]
[shimmers.common.svg :as csvg :include-macros true]
[shimmers.common.ui.controls :as ctrl]
[shimmers.common.ui.svg :as usvg]
[shimmers.math.deterministic-random :as dr]
[shimmers.math.equations :as eq]
[shimmers.math.vector :as v]
[shimmers.sketch :as sketch :include-macros true]
[thi.ng.geom.circle :as gc]
[thi.ng.geom.core :as g]
[thi.ng.geom.vector :as gv]
[thi.ng.math.core :as tm]
[thi.ng.geom.line :as gl]))

(def width 800)
(def height 600)
(defn rv [x y]
(gv/vec2 (* width x) (* height y)))

(defn make-path [bounds start-fn seed scale lifespan]
(fn []
(let [path
(->> [(start-fn) (gv/vec2)]
(iterate
(fn [[p v]]
(let [noise (dr/noise-at-point-01 seed scale p)
v' (tm/* (tm/+ v (v/polar (/ 100 height) (* noise eq/TAU))) 0.85)]
[(tm/+ p v) v'])))
(take (lifespan))
(take-while (fn [[p _v]] (g/contains-point? bounds p)))
(map first))]
(when (and (seq path) (> (count path) 1))
(csvg/group {}
(csvg/path (csvg/segmented-path path)
{:stroke-width 0.5})
(let [stops (dr/gaussian-range 0.125 0.05)]
(map (fn [t] (gc/circle (g/point-at (gl/linestrip2 path) t) 1.5)) stops)))))))

(defn shapes [bounds]
(let [start (fn [] (rp/sample-point-inside (gc/circle (rv 0.5 0.5) (* 0.4 height))))
scale 0.001
seed (dr/noise-seed)
lifespan (fn [] (int (dr/gaussian 100 10)))]
(repeatedly
384
(make-path (g/scale-size bounds 0.95) start seed scale lifespan))))

(defn scene [{:keys [scene-id]}]
(csvg/svg-timed {:id scene-id
:width width
:height height
:stroke "black"
:fill "none"
:stroke-width 0.75}
(shapes (csvg/screen width height))))

(sketch/definition ley-lines
{:created-at "2024-08-10"
:tags #{}
:type :svg}
(ctrl/mount (usvg/page sketch-args scene)))

0 comments on commit ca77ac1

Please sign in to comment.