Add previously unstaged aphorism eleven
This commit is contained in:
parent
252227296a
commit
57ad9171f7
1 changed files with 23 additions and 18 deletions
|
|
@ -3,38 +3,43 @@
|
||||||
[thi.ng.geom.circle :as c]
|
[thi.ng.geom.circle :as c]
|
||||||
[thi.ng.geom.core :as g]
|
[thi.ng.geom.core :as g]
|
||||||
[thi.ng.math.core :as m]
|
[thi.ng.math.core :as m]
|
||||||
|
[thi.ng.math.noise :as n]
|
||||||
[quil.core :as q]
|
[quil.core :as q]
|
||||||
[quil.middleware :as qm]))
|
[quil.middleware :as qm]))
|
||||||
|
|
||||||
|
|
||||||
(defn setup []
|
(defn setup []
|
||||||
(q/frame-rate 1)
|
(q/frame-rate 1)
|
||||||
(q/color-mode :hsb)
|
(q/color-mode :hsb 360 1.0 1.0 1.0)
|
||||||
{:shapes [(->
|
{:shapes (repeatedly 20 #(-> (m/* (v/randvec2) (q/random 25 175))
|
||||||
(c/circle 60)
|
(c/circle 20)))})
|
||||||
(g/as-polygon 120))]})
|
|
||||||
|
|
||||||
(defn update-state [state]
|
(defn update-state [state]
|
||||||
state)
|
state)
|
||||||
|
|
||||||
(defn mix-hsb [[h1 s1 b1] [h2 s2 b2] t]
|
(defn lerp-color [c1 c2 t]
|
||||||
(mapv + (map (partial * (- 1 t)) [h1 s1 b1])
|
(mapv + (map (partial * (- 1 t)) (cond-> c1
|
||||||
(map (partial * t) [h2 s2 b2])))
|
(< (count c1) 4) (conj 1.0)))
|
||||||
|
(map (partial * t) (cond-> c2
|
||||||
|
(< (count c2) 4) (conj 1.0)))))
|
||||||
|
|
||||||
(def color1 [180 (* 255 0.5) (* 255 0.6)])
|
(def color1 [180 0.5 0.6 0.5])
|
||||||
(def color2 [210 (* 255 0.5) (* 255 0.6)])
|
(def color2 [210 0.5 0.6])
|
||||||
|
|
||||||
(defn draw-state [state]
|
(defn draw-state [state]
|
||||||
(q/background 0 0 (* 255 0.92))
|
(q/background 0 0 0.98)
|
||||||
(q/no-fill)
|
(q/no-fill)
|
||||||
(q/no-stroke)
|
(q/no-stroke)
|
||||||
(q/with-translation [(* 0.5 (q/width)) (* 0.5 (q/height))]
|
(q/with-translation [(* 0.5 (q/width)) (* 0.5 (q/height))]
|
||||||
(q/begin-shape)
|
(doseq [shape (:shapes state)]
|
||||||
(doseq [shape (:shapes state)
|
(q/begin-shape)
|
||||||
pt (:points shape)]
|
(doseq [pt (:points (g/as-polygon shape 120))]
|
||||||
(apply q/fill (mix-hsb color1 color2 (q/map-range (first pt) -25 25 0 1)))
|
(let [color (lerp-color color1 color2 (q/map-range (first pt)
|
||||||
(apply q/vertex pt))
|
(- (first (:p shape))
|
||||||
(q/end-shape :close)))
|
(:r shape))
|
||||||
|
(+ (first (:p shape))
|
||||||
|
(:r shape)) 0 1))]
|
||||||
|
(apply q/fill color)
|
||||||
|
(apply q/vertex pt)))
|
||||||
|
(q/end-shape :close))))
|
||||||
|
|
||||||
(q/defsketch eleven
|
(q/defsketch eleven
|
||||||
:title "Eleven"
|
:title "Eleven"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue