Created
April 1, 2013 19:01
-
-
Save quephird/5286903 to your computer and use it in GitHub Desktop.
first time playing with 3d primitives in quil and processing
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 easter-eggs | |
(:use quil.core quil.applet)) | |
(def screen-w 1920) | |
(def screen-h 1080) | |
(def easter-colors | |
[[255 170 255] ; pink | |
[253 198 137] ; orange | |
[255 255 170] ; yellow | |
[170 255 170] ; green | |
[170 255 255]] ; blue | |
) | |
(def top-plane | |
[[1 0] [2 0] [0 1] [2 1] [1 2] [2 2]]) | |
(def bottom-plane | |
[[-2 -1] [-1 -1] [-1 0] | |
[3 -1] [4 -1] [4 0] | |
[1 0] [2 0] [0 1] [1 1] [2 1] [1 2] [2 2] | |
[-1 2] [-2 3] [-1 3] | |
[4 2] [3 3] [4 3]]) | |
(defn setup [] | |
(background 0) | |
(smooth) | |
(no-stroke) | |
(no-loop) | |
) | |
(defn easter-egg-rosette [] | |
(doseq [r (range 1 7)] | |
(push-matrix) | |
(doseq [t (range 0 360 (/ 360 (* r 5)))] | |
(push-matrix) | |
(translate (* 50 r (cos (radians t))) (* 50 r (sin (radians t)))) | |
(apply fill (easter-colors (rand-int (count easter-colors)))) | |
(sphere 25) | |
(pop-matrix)) | |
(pop-matrix)) | |
) | |
(defn easter-egg-plane [xs-and-ys] | |
(doseq [[x y] xs-and-ys] | |
(push-matrix) | |
(if (even? y) | |
(translate (* x 650) (* y 550)) | |
(translate (+ 325 (* x 650)) (* y 550))) | |
(easter-egg-rosette) | |
(pop-matrix)) | |
) | |
(defn draw [] | |
(point-light 200 200 200 0 0 100) | |
(ambient-light 100 100 100) | |
(ambient 100 100 100) | |
(easter-egg-plane top-plane) | |
(translate 0 0 -1000) | |
(easter-egg-plane bottom-plane) | |
(save "easter-eggs.png") | |
) | |
(defsketch main | |
:title "easter eggs" | |
:setup setup | |
:draw draw | |
:size [screen-w screen-h] | |
:renderer :opengl | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment