;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Title: Falling ;;; ;;; Description: ;;; Even though there is ;;; inverse-square force, these are not ;;; isopotentials ;;; NOTE: Since I had to do a lot of refactoring to get this code into the lightweight division, a lot of comments ;;; were cut out and a lot of constants were replaced by their values (define (square n) (* n n)) (define (arc_helper angle_left r) (if (<= angle_left 0) () (begin (forward (* 2 r 0.008726646259971648)) (rt 1) (arc_helper (- angle_left 1) r)) ) ) (define (gray_helper n last_color) (if (zero? n) () (let ((new_gray (map (lambda (x) (- x 3)) last_color))) (cons new_gray (gray_helper (- n 1) new_gray))) ) ) ; because why the heck is it scaled 0 to 1??? (define (to_rgb c) (rgb (/ (car c) 255) (/ (car (cdr c)) 255) (/ (car (cdr (cdr c))) 255)) ) ; Draws a bunch of gray stuff (define (drawbg r scale colors) (if (null? colors) () (begin (begin_fill) (color (to_rgb (car colors))) (setpos (- r) -200) (pendown) (seth 0) ; When the remaining angle is 0, stop recursion (arc_helper 360 (+ 200 r)) (end_fill) (penup) (drawbg (- r scale) scale (cdr colors))) ) ) (define (orbit_update x y vx vy c dt) (cond ((< x -420) ()) ((> y 395) ()) (else (let ((angle (atan (/ (+ y 1800) (+ x 1000)))) (k (/ 8 (+ (square (+ x 1000)) (square (+ y 1800)))))) (setpos x y) (pendown) (color (to_rgb c)) (orbit_update (+ x (* dt vx)) (+ y (* dt vy)) (+ vx (* dt k (abs (cos angle)) (if (> x -1000) -1 1))) (+ vy (* dt k (abs (sin angle)) (if (> y -1800) -1 1))) (map (lambda (n) (if (>= n 254) 255 (+ 0.15 n))) c) dt ) ) ) ) ) ; Draws n orbits with starting velocity v, angle from 180° angle0, and cw change adj (define (draworbits n vx vy r) (if (zero? n) () (begin (penup) (orbit_update 420 -393.5 vx vy '(120 0 0) 30) (draworbits (- n 1) (* vx 0.89) (+ vy 0.003) r) ) ) ) (define (draw) ; YOUR CODE HERE (speed 0) (bgcolor "#c0c8d2") (drawbg 630 9 (gray_helper 64 '(192 200 210))) (draworbits 60 -0.08 0.01 0) (hideturtle) (exitonclick)) ; Please leave this last line alone. You may add additional procedures above ; this line. (draw)