;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Title: ;;; ;;; Description: ;;; (define (draw) ; *YOUR CODE HERE* (speed 0) (ht) (pu) (setposition -200 -200) (define (christmas_dict index) (cond ((= index 0) "#66df9a") ((= index 1) "#CC0000") ((= index 2) "#E60000") ((= index 3) "#FF0000") ((= index 4) "#FF1919") ((= index 5) "#FF3333") ((= index 6) "#FF4D4D") ((= index 7) "#FF6666") ((= index 8) "#FF8080") ((= index 9) "#007A5C") ((= index 10) "#008F6B") ((= index 11) "#00A37A") ((= index 12) "#00B88A") ((= index 13) "#00CC99") ((= index 14) "#19D1A3") ((= index 15) "#33D6AD") ((= index 16) "#4DDBB8") ((= index 17) "#66E0C2") ((= index 18) "#80E6CC"))) ;changes the color of pen (define (rand_color) (color (christmas_dict (random 19)))) ;draw recursively smaller concentric squares around point(x, y) (define (concentric_squares x y len) (if (> len 5) (begin (rand_color) (pu) (goto (- x (/ len 2)) y) (pd) (begin_fill) (goto (- x (/ len 2)) (- y (/ len 2))) (goto (+ x (/ len 2)) (- y (/ len 2))) (goto (+ x (/ len 2)) (+ y (/ len 2))) (goto (- x (/ len 2)) (+ y (/ len 2))) (goto (- x (/ len 2)) y) (end_fill) (concentric_squares x y (- len 10))))) ;draw recursively smaller concentric circles around point (x, y) (define (concentric_circles x y rad) (if (> rad 0) (begin (rand_color) (pu) (goto (+ x rad) y) (pd) (begin_fill) (circle rad) (end_fill) (concentric_circles x y (- rad 5))))) ;draw concentric squares from point (a, b) to point (x, y) (define (draw_squares a b x y numsteps len) (begin (rand_color) (pu) (if (> numsteps 0) (begin (concentric_squares a b len) (draw_squares (+ (/ (- x a) (+ numsteps 1)) a) (+ (/ (- y b) (+ numsteps 1)) b) x y (- numsteps 1) len)) (goto x y)))) ;draw concentric circles from point (a, b) to point (x, y) (define (draw_circles a b x y numsteps rad) (begin (rand_color) (pu) (if (> numsteps 0) (begin (concentric_circles a b rad) (draw_circles (+ (/ (- x a) (+ numsteps 1)) a) (+ (/ (- y b) (+ numsteps 1)) b) x y (- numsteps 1) rad)) (goto x y)))) ;base point (x0, y0), unit vectors defined by (xi, xj) and (yi, yj), number of recursions n (define (recursive_art x0 y0 xi xj yi yj n) (begin (pu) (if (> n 0) (begin (recursive_art x0 y0 (/ yi 2) (/ yj 2) (/ xi 2) (/ xj 2) (- n 1)) (draw_circles (+ x0 (/ xi 2)) (+ y0 (/ xj 2)) (+ x0 (/ (+ xi yi) 2)) (+ y0 (/ (+ xj yj) 2)) 2 30) (recursive_art (+ x0 (/ xi 2)) (+ y0 (/ xj 2)) (/ xi 2) (/ xj 2) (/ yi 2) (/ yj 2) (- n 1)) (draw_circles (+ x0 (/ xi 2)) (+ y0 (/ xj 2)) (+ x0 (/ (+ xi yi) 2)) (+ y0 (/ (+ xj yj) 2)) 5 10) (recursive_art (+ x0 (/ xi 2) (/ yi 2)) (+ y0 (/ xj 2) (/ yj 2)) (/ xi 2) (/ xj 2) (/ yi 2) (/ yj 2) (- n 1)) (draw_circles (+ x0 (/ xi 2) (/ yi 2)) (+ y0 (/ xj 4) (/ yj 4)) (+ x0 (/ (+ xi yi) 2)) (+ y0 (/ (+ xj yj) 2)) 1 20) (draw_squares (+ x0 (/ xi 2) (/ yi 2)) (+ y0 (/ xj 2) (/ yj 2)) (+ x0 (/ (+ xi yi) 2)) (+ y0 (/ (+ xj yj) 2)) 1 100) (recursive_art (+ x0 (/ xi 2) yi) (+ y0 (/ xj 2) yj) (/ (- yi) 2) (/ (- yj) 2) (/ (- xi) 2) (/ (- xj) 2) (- n 1)) (draw_circles (+ x0 (/ xi 2) yi) (+ y0 (/ xj 2) yj) (+ x0 (/ (+ xi yi) 2)) (+ y0 (/ (+ xj yj) 2)) 5 10) (recursive_art x0 y0 xi xj yi yj (- n 1)))))) (recursive_art -200 -200 450 0 0 450 3) (exitonclick)) ;Inspired by the hilbert-curve ; Please leave this last line alone. You may add additional procedures above ; this line. All Scheme tokens in this file (including the one below) count ; toward the token limit. (draw)