Skip to content

Instantly share code, notes, and snippets.

@vydd
Created January 14, 2016 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vydd/a2337c0f0702536a2318 to your computer and use it in GitHub Desktop.
Save vydd/a2337c0f0702536a2318 to your computer and use it in GitHub Desktop.
(defparameter *theta* 0)
(defsketch recursive-tree (:width 640 :height 360) ()
(background +black+)
(with-pen (make-pen :stroke +white+)
(let ((*theta* (* 90 (/ (in :mouse-x) width))))
(with-identity-matrix
(translate (/ width 2) height)
(line 0 0 0 -120)
(translate 0 -120)
(branch 120)))))
(defun branch (h)
(let ((h (* h 0.66)))
(when (> h 2)
(dotimes (i 2)
(with-current-matrix
(rotate (if (zerop i) (- *theta*) *theta*))
(line 0 0 0 (- h))
(translate 0 (- h))
(branch h))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment