Initial commit, 3-52-19 alpha
[cls.git] / xlisponly / lsp / dragon.lsp
blobb30b002a271ee7708c50064b80ea8e667ca43d2a
1 ;; DRAGON.L FOR PC-LISP V2.10
2 ;; Modified for xlisp 2.1d (w. graphics extensions) by Tom Almy
3 ;; ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 ;; Draw an Nth order Dragon Curve requires Turtle.l routines to run.
5 ;; Taken From Byte April 1986. Try (DragonCurve 16) then put on supper,
6 ;; watch the news and come back in an hour and see the results. It takes
7 ;; about 1/2 hour on my machine so on a normal IBM-PC it should take about
8 ;; an 1.5 hours.
9 ;;
10 ;; Peter Ashwood-Smith.
11 ;; April 1986
13 ;; P.S - This dragon is nicknamed "spot"
15 #-:turtle (load "turtle")
17 (defvar *StepSize* 1)
19 (defun Dragon(sign level)
20 (if (zerop level)
21 (TurtleForward *StepSize*)
22 (progn
23 (setq level (1- level))
24 (TurtleRight (* 45 sign))
25 (Dragon -1 level)
26 (TurtleLeft (* 90 sign))
27 (Dragon 1 level)
28 (TurtleRight (* 45 sign))
33 (defun DragonCurve (n m)
34 (setq *StepSize* m) ; *StepSize* is global variable
35 (TurtleGraphicsUp)
36 (TurtleCenter)
37 (TurtleGoto 50 50)
38 (TurtleRight 30) ; angle the serpent a bit
39 (Dragon 1 n)
40 (gc)
43 (print "Try (DragonCurve 14 1)")