Skip to content

Instantly share code, notes, and snippets.

@mattearnshaw
Created August 16, 2017 22:13
Show Gist options
  • Save mattearnshaw/5f1e644e01c19d126e8ab89fac180a6f to your computer and use it in GitHub Desktop.
Save mattearnshaw/5f1e644e01c19d126e8ab89fac180a6f to your computer and use it in GitHub Desktop.
(ns quil-site.examples.tree
(:require [quil.core :as q :include-macros true]
[quil.middleware :as m]))
(def grid-spacing 20)
(def copies 5)
(defn setup []
(q/no-smooth)
(q/background 255)
(q/fill 0 0 0)
(doseq [i (map (partial * (/ Math/PI copies)) (range copies))]
(let [center-x (/ (q/width) 2)
center-y (/ (q/height) 2)]
(q/with-translation [center-x center-y]
(q/with-rotation [i] (draw-grid grid-spacing))))))
(defn draw-grid [spacing]
(let [nbars 1000 n2 10000
oX (/ (q/width) 2)
oY (/ (q/height) 2)]
(doseq [offset (map (partial * spacing) (range (* -1 nbars) nbars))]
(q/line (* -1 n2) (+ oY offset) (+ (q/width) n2) (+ oY offset))
(q/line (+ oX offset) (* -1 n2) (+ oX offset) (+ (q/height) n2)))))
(q/defsketch quil-cljs
:host "host"
:size [1100 800]
:setup setup
:middleware [m/fun-mode])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment