Created
January 14, 2016 15:42
-
-
Save vydd/a2337c0f0702536a2318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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