Last active
August 29, 2015 14:00
-
-
Save quephird/11302445 to your computer and use it in GitHub Desktop.
Clojure interpretation of this neat little post here: http://p5art.tumblr.com/post/83764524629/turbine-inspired-by-this-my-code-here
This file contains hidden or 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 quil.hello | |
| (:use quil.core)) | |
| (def screen-w 800) | |
| (def screen-h 800) | |
| (def t (atom 0)) | |
| (defn setup [] | |
| (smooth) | |
| (background 0) | |
| (no-stroke)) | |
| (defn draw [] | |
| (let [center-x (* screen-w 0.5) | |
| center-y (* screen-h 0.5) | |
| wedge-groups 12 | |
| colors [[127 0 255] | |
| [127 0 192] | |
| [127 0 127] | |
| [63 0 63] | |
| [0 0 0]] | |
| dθ (/ 360 wedge-groups (count colors)) | |
| wedge-r (* (Math/sqrt (+ (* screen-w screen-w) (* screen-h screen-h))) 0.5) | |
| wedge-x (* 0.5 wedge-r (sin (* dθ 0.5))) | |
| disc-d (* wedge-r 0.25)] | |
| (translate center-x center-y) | |
| (rotate (radians @t)) | |
| (push-matrix) | |
| (doseq [_ (range wedge-groups)] | |
| (doseq [slice-color colors] | |
| (apply fill slice-color) | |
| (begin-shape :triangles) | |
| (vertex 0 0) | |
| (vertex (- wedge-x) (- wedge-r)) | |
| (vertex wedge-x (- wedge-r)) | |
| (end-shape) | |
| (rotate (radians dθ)))) | |
| (pop-matrix) | |
| (fill 0) | |
| (ellipse 0 0 disc-d disc-d) | |
| (swap! t + 0.5))) | |
| (sketch | |
| :title "turbine" | |
| :setup setup | |
| :draw draw | |
| :renderer :p2d | |
| :size [screen-w screen-h]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment