;;; Your entry for the Scheme contest ;;; ;;; Title: ;;; Ammonite ;;; ;;; Description: ;;; Within a spiral ;;; There is another spiral ;;; Containing spirals ;;; be advised that this particular routine takes a long time to run ;;; it is a bit faster but worse looking if minlen is greater than 1 (showturtle) (clear) (penup) (goto (- 350) 350) (color 'black) (begin_fill) (goto (- 350) (- 350)) (goto 350 (- 350)) (goto 350 350) (goto (- 350) 350) (end_fill) (goto 308 (- 170)) (setheading 0) (speed 1000) (hideturtle) (define minlen 1) (define ang 32) (define offspringang 1) (define lenfactor .95) (define offspringfactor .23) (define (spiral len ang heading lenfactor offspringang offspringfactor col) ;heading is 1 for CCW, -1 for CW ;use cooler colors ; (define (nextcolor col) (case col ; (('|#000000|) '|#080000|) ; (('|#080000|) '|#100000|) ; (('|#100000|) '|#180000|) ; (('|#180000|) '|#200000|) ; (('|#200000|) '|#280000|) ; (('|#280000|) '|#300000|) ; (('|#300000|) '|#380000|) ; (('|#380000|) '|#400000|) ; (('|#400000|) '|#480000|) ; (('|#480000|) '|#500000|) ; (('|#500000|) '|#580000|) ; (('|#580000|) '|#600000|) ; (('|#600000|) '|#680000|) ; (('|#680000|) '|#700000|) ; (('|#700000|) '|#780000|) ; (('|#780000|) '|#800000|) ; (('|#800000|) '|#880000|) ; (('|#880000|) '|#900000|) ; (('|#900000|) '|#980000|) ; (('|#980000|) '|#A00000|) ; (('|#A00000|) '|#A80000|) ; (('|#A80000|) '|#B00000|) ; (('|#B00000|) '|#B80000|) ; (('|#B80000|) '|#C00000|) ; (('|#C00000|) '|#C80000|) ; (('|#C80000|) '|#D00000|) ; (('|#D00000|) '|#D80000|) ; (('|#D80000|) '|#E00000|) ; (('|#E00000|) '|#E80000|) ; (('|#E80000|) '|#F00000|) ; (('|#F00000|) '|#F80000|) ; (('|#F80000|) '|#000000|) ; )) (define (oldnextcolor col) (case col ((red) 'orange) ((orange) 'yellow) ((yellow) 'green) ((green) 'blue) ((blue) 'purple) ((purple) 'red) )) ;base case: if length < 1, then abort recursion (if (< len minlen) #t ; return value indicating completion (begin ; the rest of the function - draw self, and then offspring into 2 spirals ;everything needs to be done kind of recursively - move forward, branch, move back (color col) (pendown) (forward len) (penup) ;we'll try one branch for now (left (* ang heading)) (spiral (* len lenfactor) ang heading lenfactor offspringang offspringfactor col) ;now for the other branch (spiral (* len offspringfactor) (* ang offspringang) heading lenfactor offspringang offspringfactor (oldnextcolor col)) (right (* ang heading)) (backward len) ) ) #t ) ;(spiral 170 ang 1 lenfactor offspringang offspringfactor '|#000000|) (spiral 205 ang 1 lenfactor offspringang offspringfactor 'blue) ;(exitonclick)