Twenty-eight till thirty-one
This commit is contained in:
parent
21b86ce217
commit
d88a17f54e
6 changed files with 231 additions and 3 deletions
57
src/aphorisms/thirty.clj
Normal file
57
src/aphorisms/thirty.clj
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
(ns aphorisms.thirty
|
||||
(:require [quil.core :as q]
|
||||
[quil.middleware :as qm]
|
||||
[aphorisms.utils.middleware :refer [screenshottable]]
|
||||
[thi.ng.math.core :as m]
|
||||
[thi.ng.math.noise :as n]
|
||||
[thi.ng.geom.line :as l]
|
||||
[thi.ng.geom.rect :as r]
|
||||
[thi.ng.geom.core :as g]
|
||||
[thi.ng.geom.polygon :as p]
|
||||
[thi.ng.geom.vector :as v]))
|
||||
|
||||
(def bounds (r/rect 500 500))
|
||||
(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)
|
||||
{})
|
||||
|
||||
|
||||
(defn noise-line [x y intensity]
|
||||
(->> (map (fn [i]
|
||||
(v/vec2 (+ x (* 10 (n/noise2 (* x 0.003) (* i 0.2))))
|
||||
(+ y (* i (n/noise1 (+ x 0.4))))))
|
||||
(range intensity))
|
||||
(l/linestrip2)))
|
||||
|
||||
(g/subdivide bounds {:num 4})
|
||||
|
||||
(defn draw-state [_]
|
||||
(q/background 232)
|
||||
(q/no-fill)
|
||||
(q/stroke 140)
|
||||
(q/with-translation [(/ (- (g/width bounds) (g/width canvas)) 4)
|
||||
(/ (- (g/height bounds) (g/height canvas)) 2)]
|
||||
(doseq [sector (g/subdivide canvas {:rows 5
|
||||
:cols 6})
|
||||
:let [[x y] (g/centroid sector)
|
||||
line (noise-line x y (* 0.1 (- (g/height bounds) y)))]]
|
||||
(doseq [[from to] (->> (g/vertices line)
|
||||
(partition 2 1))]
|
||||
#_(q/scale 0 -1)
|
||||
(q/line from to)))))
|
||||
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(q/defsketch thirty
|
||||
:title "Thirty"
|
||||
: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])
|
||||
49
src/aphorisms/thirty_one.clj
Normal file
49
src/aphorisms/thirty_one.clj
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
(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])
|
||||
41
src/aphorisms/twenty_eight.clj
Normal file
41
src/aphorisms/twenty_eight.clj
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
(ns aphorisms.twenty-eight
|
||||
(:require [quil.core :as q]
|
||||
[quil.middleware :as qm]
|
||||
[aphorisms.utils.middleware :refer [screenshottable]]
|
||||
[thi.ng.geom.rect :as r]
|
||||
[thi.ng.geom.core :as g]))
|
||||
|
||||
(def bounds (r/rect 640 480))
|
||||
|
||||
(defn setup []
|
||||
(q/frame-rate 30)
|
||||
(q/ellipse-mode :center)
|
||||
(q/color-mode :hsb 255)
|
||||
{})
|
||||
|
||||
(defn draw-state [_]
|
||||
(q/background 255)
|
||||
(q/stroke 40)
|
||||
(q/fill 255)
|
||||
|
||||
(q/with-translation [(* 0.5 (q/width))
|
||||
(* 0.5 (q/height))]
|
||||
(doseq [i (range -5 5)
|
||||
:let [r (q/map-range i -5 4 20 32)
|
||||
x (* i (* (q/sin i) 0.2) 20)
|
||||
y (q/map-range i -5 4 -20 40)
|
||||
]]
|
||||
(q/ellipse x y r r))))
|
||||
|
||||
; define 2 images and a mask to apply to them
|
||||
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(q/defsketch twenty-eight
|
||||
:title "Twenty-Eight"
|
||||
:size (:size bounds)
|
||||
:settings #(q/pixel-density (q/display-density))
|
||||
:setup setup
|
||||
:update update-state
|
||||
:draw draw-state
|
||||
:middleware [(screenshottable) qm/pause-on-error qm/fun-mode])
|
||||
60
src/aphorisms/twenty_nine.clj
Normal file
60
src/aphorisms/twenty_nine.clj
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
(ns aphorisms.twenty-nine
|
||||
(:require [quil.core :as q]
|
||||
[quil.middleware :as qm]
|
||||
[aphorisms.utils.middleware :refer [screenshottable]]
|
||||
[thi.ng.math.core :as m]
|
||||
[thi.ng.geom.line :as l]
|
||||
[thi.ng.geom.rect :as r]
|
||||
[thi.ng.geom.core :as g]
|
||||
[thi.ng.geom.polygon :as p]))
|
||||
|
||||
(def bounds (r/rect 640 480))
|
||||
|
||||
(defn setup []
|
||||
(q/frame-rate 30)
|
||||
(q/ellipse-mode :center)
|
||||
(q/rect-mode :corners)
|
||||
(q/color-mode :hsb 255)
|
||||
{})
|
||||
|
||||
(def line (l/line2 [0 (rand-int (g/height bounds))]
|
||||
[(g/width bounds) (rand-int (g/height bounds))]))
|
||||
|
||||
(defn spaced-line [l s]
|
||||
(let [spacer (-> (g/translate line (m/- (nth (g/vertices line) 0)))
|
||||
(m/normalize)
|
||||
(g/rotate m/HALF_PI)
|
||||
(g/scale-size s))]
|
||||
(g/translate l (nth (g/vertices spacer) 1))))
|
||||
|
||||
(defn line2->poly2 [l]
|
||||
(p/polygon2 (g/vertices l)))
|
||||
|
||||
(line2->poly2 line)
|
||||
|
||||
(defn line-pattern [bounds line dist]
|
||||
;; 1. move line to top of bounds so that it barely still touches it
|
||||
;; 2. repeat line, spacing it by dist, so that it fills the complete bounds
|
||||
|
||||
)
|
||||
|
||||
(defn draw-state [_]
|
||||
(q/background 255)
|
||||
(q/no-fill)
|
||||
(q/stroke-weight 3)
|
||||
(q/stroke 120)
|
||||
(q/with-translation [(* 0.5 (q/width))
|
||||
(* 0.5 (q/height))]
|
||||
(q/rect -100 -100 100 100 3))
|
||||
(doseq [line (reductions spaced-line line (range 10 101 10))]
|
||||
(apply q/line (g/vertices line))))
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(q/defsketch twenty-nine
|
||||
:title "Twenty-Nine"
|
||||
:size (:size bounds)
|
||||
:settings #(q/pixel-density (q/display-density))
|
||||
:setup setup
|
||||
;; :update update-state
|
||||
:draw draw-state
|
||||
:middleware [(screenshottable) qm/pause-on-error qm/fun-mode])
|
||||
21
src/aphorisms/utils/middleware.clj
Normal file
21
src/aphorisms/utils/middleware.clj
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
(ns aphorisms.utils.middleware
|
||||
(:require [quil.core :as q]))
|
||||
|
||||
(defn- default-name-fn [timestamp]
|
||||
(println "*ns*" *ns*)
|
||||
(format "%s.png" timestamp))
|
||||
|
||||
(defn screenshottable
|
||||
([] (screenshottable {}))
|
||||
([{:keys [out-dir name-fn]
|
||||
:or {out-dir "exports"
|
||||
name-fn default-name-fn}}]
|
||||
(fn screenshottable [opts]
|
||||
(let [key-pressed (:key-pressed opts)]
|
||||
(when (fn? key-pressed)
|
||||
(println "There is already a function bound to key-pressed."))
|
||||
(assoc opts :key-pressed
|
||||
(fn [e]
|
||||
(println e)
|
||||
(when (fn? key-pressed)
|
||||
(key-pressed e))))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue