Skip to content

Instantly share code, notes, and snippets.

@ooesili
Created November 27, 2018 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ooesili/1bbf1502a9da578077078426b0693e70 to your computer and use it in GitHub Desktop.
Save ooesili/1bbf1502a9da578077078426b0693e70 to your computer and use it in GitHub Desktop.
Circles
(ns quils.circles.core
(:require [quil.core :as q]
[quils.util :refer :all]))
(def TAU (* 2 q/PI))
(def max-depth 4)
(defn setup []
(q/frame-rate 1)
(q/color-mode :hsb)
{})
(defn draw-circles [depth]
(let [radius 10
diameter (* 2 radius)
angle-step (/ TAU 6)]
(q/ellipse 0 0 diameter diameter)
(q/ellipse 0 0 (* 2 diameter) (* 2 diameter))
(when-not (zero? depth)
(doseq [i (range 6)]
(with-matrix
(q/rotate (* i angle-step))
(q/translate 0 radius)
(draw-circles (dec depth)))))))
(defn draw-state [state]
(q/background 0 0 0)
(q/no-fill)
(q/stroke 64 255 255 8)
(q/stroke-weight 0.5)
(with-matrix
(q/translate (/ (q/width) 2) (/ (q/height) 2))
(q/scale (/ (q/width) 100) (/ (q/height) 100))
(draw-circles max-depth)))
(ns quils.circles.sketch
(:require [quil.core :as q]
[quil.middleware :as m]
[quils.circles.core :as core]))
(q/defsketch circles
:title "Circles"
:size [800 800]
:setup core/setup
:update identity
:draw core/draw-state
:features []
:middleware [m/fun-mode])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment