Add previously unstaged aphorism eleven

This commit is contained in:
arne 2020-09-16 20:03:49 +02:00
commit 57ad9171f7

View file

@ -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))]
(doseq [shape (:shapes state)]
(q/begin-shape) (q/begin-shape)
(doseq [shape (:shapes state) (doseq [pt (:points (g/as-polygon shape 120))]
pt (:points shape)] (let [color (lerp-color color1 color2 (q/map-range (first pt)
(apply q/fill (mix-hsb color1 color2 (q/map-range (first pt) -25 25 0 1))) (- (first (:p shape))
(apply q/vertex pt)) (:r shape))
(q/end-shape :close))) (+ (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"