Created
June 4, 2012 11:48
-
-
Save cola-zero/2867904 to your computer and use it in GitHub Desktop.
my first sketch
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-art.pteridophyte | |
(:use quil.core)) | |
(defn setup [] | |
(background 255) | |
(stroke-weight 8) | |
(smooth) | |
(draw-pteridophyte) | |
) | |
(defn next-point [x y] | |
(let [fn0 (fn [x y a b c d e] | |
(let [x' (+ (* a x) | |
(* b y)) | |
y' (+ (* c x) | |
(* d y) | |
e)] | |
[x' y'])) | |
fn1 (fn [x y] | |
(fn0 x y 0 0 0 0.16 0)) | |
fn2 (fn [x y] | |
(fn0 x y 0.2 -0.26 0.23 0.22 1.6)) | |
fn3 (fn [x y] | |
(fn0 x y -0.15 0.28 0.26 0.24 0.44)) | |
fn4 (fn [x y] | |
(fn0 x y 0.85 0.04 -0.04 0.85 1.6)) | |
r (rand 100)] | |
(cond (< r 1) (fn1 x y) | |
(< r 8) (fn2 x y) | |
(< r 15) (fn3 x y) | |
:else (fn4 x y)))) | |
(def points | |
(concat | |
[[0 0]] | |
((fn rnext-point [x y] | |
(let [[x' y'] (next-point x y)] | |
(lazy-seq | |
(cons [x' y'] (rnext-point x' y'))))) 0 0))) | |
(defn draw-pteridophyte [] | |
(background 255) | |
(stroke 30 255 30) | |
(stroke-weight 2) | |
(let [psize 59 | |
points' (take 60000 points) | |
offset 200 | |
xs (map #(- 400 (+ offset (* psize (first %)))) points') | |
ys (map #(- 600 (* psize (second %))) points')] | |
(dorun (map point xs ys)))) | |
(defsketch pteridophyte | |
:title "Pteridophyte" | |
:setup setup | |
:size [400 600]) | |
;; (sketch-stop pteridophyte) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment