ronin/examples/demo/dejong.lisp
2019-07-22 15:56:35 +09:00

34 lines
565 B
Common Lisp

; dejong attractor
(clear)
(defn point (x y color)
(fill (rect x y 1 1) color))
(defn _dejong (x y a b c d)
(rest ((point
(add 300 (mul 100 x))
(add 400 (mul 100 y))
"red")
(add (sin (mul a y)) (mul x (cos (mul b x))))
(add (mul x (sin (mul x c))) (cos (mul d y)))
))
)
(defn dejong (r a b c d)
(reduce
(λ (acc val)
(first (
(_dejong (first acc) (last acc) a b c d)
)))
(range 0 r)
(2 1)
)
)
(benchmark
'(dejong 12800
(random -2 2)
(random -2 2)
(random -2 2)
(random -2 2)
))