heyarne.aphorisms/src/aphorisms/thirty_one.clj
2022-11-04 00:31:10 +01:00

49 lines
1.5 KiB
Clojure

(ns aphorisms.thirty-one
(:require [quil.core :as q]
[quil.middleware :as qm]
[thi.ng.geom.rect :as r]
[thi.ng.geom.core :as g]
[thi.ng.geom.circle :as c]
[thi.ng.math.core :as m]))
(def bounds (r/rect 600 600))
(def canvas (g/scale bounds 0.92))
(defn setup []
(q/frame-rate 30)
(q/ellipse-mode :center)
(q/rect-mode :corners)
(q/color-mode :hsb 255)
{})
(def circ
(c/circle 100))
(defn draw-state [_]
(let [t (* 0.0002 (q/millis))]
(q/background 232)
(q/fill 255)
(q/no-stroke)
(q/blend-mode :difference)
(q/with-translation [(/ (g/width bounds) 2)
(/ (g/height bounds) 2)]
(q/ellipse 0 0 (g/width circ) (g/height circ))
(doseq [i (range 12)
:let [offset (* 0.82 (g/height circ))]]
(q/ellipse (* offset (Math/cos (- i t))) (* offset (Math/sin (- i t))) (* 0.41 (g/width circ)) (* 0.41 (g/height circ))))
(doseq [i (mapv (fn [i] (/ i m/TWO_PI )) (range 1 41))
:let [offset (* 1.23 (g/height circ))
circumference (* m/TWO_PI offset)]]
(q/ellipse (* offset (Math/cos (+ t i))) (* offset (Math/sin (+ t i))) (/ circumference 80) (/ circumference 80))))))
#_:clj-kondo/ignore
(q/defsketch thirty-one
:title "Thirty-One"
:size (:size bounds)
:settings #(q/pixel-density (q/display-density))
:setup setup
;; :update update-state
:draw draw-state
:middleware [qm/pause-on-error #_(screenshottable) qm/fun-mode])