(setf #j:canvas (#j:document:getElementById "canvas")
#j:ctx (#j:canvas:getContext "2d"))
(defun to-radix (var radix)
((jscl::oget var "toString") radix))
(defun random-hex ()
(to-radix (random 15) 16))
(defun get-random-colour ()
(concatenate 'string
"#"
(loop for _ below 6 collect (random-hex))))
(defvar step-scale 0.99)
(defconstant +PI+ #j:Math:PI)
(defun render-leaflet (rotation)
(#j:ctx:scale step-scale step-scale)
(#j:ctx:rotate rotation)
(#j:ctx:beginPath)
(#j:ctx:arc 0 50 50 (/ (- +PI+) 2) 0)
(setf #j:ctx:fillStyle "#000")
(#j:ctx:fill)
(#j:ctx:beginPath)
(#j:ctx:arc 50 0 50 (- +PI+) (/ +PI+ 2) t)
(setf #j:ctx:fillStyle (get-random-colour))
(#j:ctx:fill))
(setf #j:ctx:canvas:width #j:window:innerWidth
#j:ctx:canvas:height #j:window:innerWidth)
(#j:ctx:translate
(/ #j:window:innerWidth 2)
(/ #j:window:innerWidth 2))
(#j:ctx:scale 5 5)
(#j:setInterval
(let ((i 0))
(lambda ()
(format t "Rendering ~a~%" i)
(render-leaflet (/ (incf i) 50))))
50))