;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Title: The Strange Attractor ;;; ;;; Description: ;;; An exploding star ;;; scatters across the cosmos ;;; elements of life (define (replicate lst n) (if (= n 0) nil (append lst (replicate lst (- n 1))))) (define-macro (repeat lst n) (cons 'begin (replicate lst (eval n)))) (define (star size) (color "yellow") (define angle (- 180 (/ 180 15))) (begin_fill) (repeat ((forward size) (right angle) (forward size)) 15) (end_fill)) (define (sign x) (cond ((= x 0) 0) ((< x 0) -1) (else 1))) (define (update-x x y a b c) (- y (+ 1 (* (sqrt (abs (- (* b x) (+ 1 c)))) (sign (- x 1)))))) (define (update-y x y a b c) (- a (+ x 1))) (define (draw-pixel x y pencolor) (penup) (setposition x y) (pendown) (color pencolor) (circle 2)) (define (hopalong x y a b c n color) (if (= n 1) (draw-pixel x y color) (begin (draw-pixel x y color) (hopalong (update-x x y a b c) (update-y x y a b c) a b c (- n 1) color)))) (define (draw) (bgcolor "black") (speed 0) (star 20) (hopalong 100 0 2.2 3.3 9.4 200 "red") (hopalong 100 100 2.2 9.3 4.4 400 "orange") (hopalong 100 150 2.2 3.3 4.4 500 "yellow") (hopalong 100 200 2.2 3.3 5.4 500 "red") (hopalong 100 250 9.2 3.3 4.4 700 "orange") (hopalong 100 300 5.2 3.3 5.4 1000 "yellow") (hopalong 100 350 9.2 6.3 8.4 2500 "red") (hopalong 100 400 1.2 5.3 1.4 1000 "orange") (exitonclick)) ; Please leave this last line alone. You may add additional procedures above ; this line. (draw)