Last active
December 22, 2018 10:44
-
-
Save ampersanda/b590d0c6a1ae0d7ec0b7bd2833d3bf91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns my.core | |
(:require [quil.core :as q :include-macros true] | |
[quil.middleware :as m])) | |
(def c 6) | |
(defn setup [] | |
(q/frame-rate 60) | |
(q/color-mode :hsb) | |
(q/background 255) | |
{:n 6}) | |
(defn update-state [{:keys [n]}] | |
{:n (inc n)}) | |
(defn draw-state [{:keys [n]}] | |
(let [a (* n 137,6) | |
r (* c (Math/sqrt n)) | |
x (+ (* r (q/cos a)) (/ (q/width) 2)) | |
y (+ (* r (q/sin a)) (/ (q/width) 2))] | |
(let [p (q/random 0 1)] | |
(cond | |
(<= p 0.3) (q/fill 31 64 114) | |
(and (> p 0.3) (<= p 0.6)) (q/fill 254 187 187) | |
:else (q/fill 253 240 240))) | |
(q/no-stroke) | |
(q/ellipse x y 6 6) | |
(q/scale 4))) | |
(q/defsketch my | |
:host "host" | |
:size [400 400] | |
:setup setup | |
:update update-state | |
:draw draw-state | |
:middleware [m/fun-mode]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment