Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A common optical illusion that is a static image, but appears to move as you look at different parts of the image - first popularised by Akiyoshi Kitaoka, Ritsumeikan University ( This gist based on a processing-js script at
(ns enchilada.rotating-spiral
[jayq.core :refer [show]]
[enchilada :refer [ctx canvas]]
[big-bang.core :refer [big-bang]]
[monet.canvas :refer [fill-style fill ellipse rotate translate save restore fill-rect]]))
(def initial-state {
:angle 0
:radius 600
:speed 1
:t 0})
(defn update-state [event {:keys [t angle speed radius] :as world-state}]
(if (< radius 2)
(assoc world-state
:radius (/ radius (+ 1 (* 0.001 speed)))
:angle (+ angle (* speed (/ Math/PI 102)))
:t (inc t))))
(defn render [{:keys [t angle radius]}]
(translate 400 300)
(rotate angle)
(fill-style (case (mod t 8)
1 :#D2D200
2 :#D2D200
3 :#D2D200
4 :#000000
5 :#3232FF
6 :#3232FF
7 :#3232FF))
(ellipse {:x radius :y 0 :rw (/ radius 10) :rh (/ radius 6)})
(show canvas)
(-> ctx
(fill-style :lightgrey)
(fill-rect {:x 0 :y 0 :w 800 :h 600}))
:initial-state initial-state
:on-tick update-state
:to-draw render)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.