概要と元ネタです。
(ns fern
(:require [incanter.core :refer [$=]])
(:require [quil.core :refer :all]))
(def ^:dynamic *width* 500)
(def ^:dynamic *height* 500)
(defn W1x [x y]
($= 0.836 * x + 0.044 * y))
(defn W1y [x y]
($= -0.044 * x + 0.836 * y + 0.169))
(defn W2x [x y]
($= -0.141 * x + 0.302 * y))
(defn W2y [x y]
($= 0.302 * x + 0.141 * y + 0.127))
(defn W3x [x y]
($= 0.141 * x - 0.302 * y))
(defn W3y [x y]
($= 0.302 * x + 0.141 * y + 0.169))
(defn W4x [x y]
0)
(defn W4y [x y]
($= 0.175337 * y))
(defn draw [n x y]
(if (pos? n)
(do
(draw (dec n) (W1x x y) (W1y x y))
(when (< (rand) 0.3) (draw (dec n) (W2x x y) (W2y x y)))
(when (< (rand) 0.3) (draw (dec n) (W3x x y) (W3y x y)))
(when (< (rand) 0.3) (draw (dec n) (W4x x y) (W4y x y))))
(let [u ($= *width* - 10)
v ($= *height* - 10)]
(point ($= x * u + *width* * 0.5) ($= *height* - y * v)))))
(defn setup []
(smooth)
(stroke 32 128 32)
(stroke-weight 1)
(background 255)
(draw 20 0 0))
(defsketch fern
:title "fern"
:setup setup
:size [*width* *height*])
楽しい! ✌(’ω’✌ )三✌(’ω’)✌三( ✌’ω’)✌