Skip to content

Instantly share code, notes, and snippets.

@samaaron
Forked from quephird/pleiades.clj
Created June 13, 2012 12:27
Show Gist options
  • Save samaaron/2923758 to your computer and use it in GitHub Desktop.
Save samaaron/2923758 to your computer and use it in GitHub Desktop.
Quil: pleiades
(ns pleiades
(:import [processing.core PApplet PConstants])
(:use quil.core))
(def screen-w 1920)
(def screen-h 1080)
; TODO: Need to apply blur to entire background; stars look too fake here
(defn- generate-background-stars []
(doseq [_ (range 1000)]
(let [r (random 5)]
(fill 255 255 255)
(ellipse (random screen-w) (random screen-h) r r))))
; TODO: Need to blur blue rings or starlight together instead of independently;
; forces a completely different implementation of this routine
(defn- generate-star [x y r]
(no-stroke)
(let [gc-width 500
gc-center (/ gc-width 2)
gc (create-graphics gc-width gc-width PApplet/P3D)]
(doto gc
(.beginDraw)
(.noStroke)
; (.fill 0 0 64)
; (.ellipse gc-center gc-center (* r 3) (* r 3))
; (.filter PConstants/BLUR 15)
(.fill 0 0 127)
(.ellipse gc-center gc-center (* r 1.5) (* r 1.5))
(.filter PConstants/BLUR 15)
(.fill 255 255 255)
(.ellipse gc-center gc-center (* r 0.5) (* r 0.5))
(.filter PConstants/BLUR 4)
(.stroke 255 255 255)
(.noFill)
(.ellipse gc-center gc-center (* r 1.1) (* r 1.1))
(.line (- gc-center r) gc-center (+ gc-center r) gc-center)
(.line gc-center (- gc-center r) gc-center (+ gc-center r))
(.filter PConstants/BLUR 2)
(.endDraw))
(image gc (- x gc-center) (- y gc-center))))
; TODO: Violates DRY; need to fix this
(defn- generate-pleides []
(generate-star 500 600 100)
(generate-star 500 550 40)
(generate-star 800 575 150)
(generate-star 950 700 100)
(generate-star 1025 315 30)
(generate-star 1040 300 30)
(generate-star 1050 425 100)
(generate-star 1150 350 50)
(generate-star 1200 575 100)
(generate-star 1210 475 40)
)
(defn setup []
(smooth)
(background 0)
(no-loop))
(defn draw []
(generate-background-stars)
(generate-pleides)
(save "pleiades.png"))
(defsketch main
:title "pleiades"
:setup setup
:draw draw
:size [screen-w screen-h])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment