52 lines
1.3 KiB
Clojure
52 lines
1.3 KiB
Clojure
(ns aphorisms.twenty-six
|
|
(:require [quil.core :as q]
|
|
[quil.middleware :as qm]
|
|
[thi.ng.geom.rect :as r]
|
|
[thi.ng.geom.core :as g]))
|
|
|
|
(def bounds (r/rect 1500 500))
|
|
|
|
(defn setup []
|
|
(q/frame-rate 30)
|
|
(q/ellipse-mode :center)
|
|
(q/color-mode :hsb 100)
|
|
{})
|
|
|
|
(defn update-state [_]
|
|
_)
|
|
|
|
(defn divisors [n]
|
|
(->>
|
|
(range 1 (inc (int (/ n 2))))
|
|
(filter #(zero? (rem n %)))))
|
|
|
|
(divisors 800)
|
|
;; => (1 2 4 5 8 10 16 20 25 32 40 50 80 100 160 200 400)
|
|
(divisors 230)
|
|
;; => (1 2 5 10 23 46 115)
|
|
|
|
(def x-noise-scale 0.006)
|
|
(def y-noise-scale 0.005)
|
|
|
|
(defn draw-state [_]
|
|
(q/background 100)
|
|
(q/stroke-weight 1)
|
|
(doseq [y (range 0 (inc (- (g/height bounds) 10)) 10)
|
|
x (range 0 (inc (- (g/width bounds) 10)) 10)
|
|
:let [noise-x (* x x-noise-scale)
|
|
noise-y (* y y-noise-scale)]]
|
|
(q/with-translation [(+ x 5) (+ y 5)]
|
|
(q/with-rotation [(* q/TWO-PI (q/noise noise-x noise-y))]
|
|
(q/stroke (q/map-range (* noise-x noise-y) -1 1 90 70) 60 80)
|
|
(q/line [-3 0] [3 0]))))
|
|
#_(q/save-frame "exports/twenty-six--business-card.png"))
|
|
|
|
#_:clj-kondo/ignore
|
|
(q/defsketch twenty-six
|
|
:title "Twenty-Six"
|
|
:size (:size bounds)
|
|
:settings #(q/pixel-density (q/display-density))
|
|
:setup setup
|
|
:update update-state
|
|
:draw draw-state
|
|
:middleware [qm/pause-on-error qm/fun-mode])
|