quil/joy-division/src/joy_division/core.clj
Anish Lakhwara 3f151bc314 some others
2022-03-22 11:36:14 +10:00

51 lines
1.4 KiB
Clojure

(ns joy-division.core
(:require [quil.core :as q]
[quil.middleware :as m]))
(defn setup []
; Set frame rate to 30 frames per second.
(q/frame-rate 30)
; Set color mode to HSB (HSV) instead of default RGB.
(q/color-mode :hsb)
; setup function returns initial state. It contains
; circle color and position.
{:lines []
:angle 0})
(def y-step 50)
(def x-step 10)
(defn make-line [y]
(vec (map #(vec [% (+ y (q/random 4))]) (range 0 (q/width) 10))))
(defn make-lines [y]
(vec (map #(make-line ) (range 0 (q/height) y-step))))
(defn update-state [state]
; Update sketch state by changing circle color and position.
{:lines [(make-line)]
:angle (+ (:angle state) 0.1)})
(defn draw-state [state]
(q/background 240)
(q/fill (:color state) 255 255)
(let [lines (make-lines 50)]
(println lines)
#_(doseq [i (range (count line))]
(q/line (get line i) (get line (+ 1 i))))))
(q/defsketch joy-division
:title "You spin my circle right round"
:size [500 500]
; setup function called only once, during sketch initialization.
:setup setup
; update-state is called on each iteration before draw-state.
:update update-state
:draw draw-state
:features [:keep-on-top]
; This sketch uses functional-mode middleware.
; Check quil wiki for more info about middlewares and particularly
; fun-mode.
:middleware [m/fun-mode])