;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname entry15) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp"))))) ;; CSci 1301 Lab 3, ;;definitions ;;contract: draw-cloud: number number-> boolean ;; purpose: draws a cloud (define (draw-cloud x y) (and (draw-solid-disk (make-posn (+ x (random 50)) (+ y (random 50))) 30 'white) (draw-solid-disk (make-posn (+ x (random 50)) (+ y (random 50))) 30 'white) (draw-solid-disk (make-posn (+ x (random 50)) (+ y (random 50))) 30 'white) (draw-solid-disk (make-posn (+ x (random 50)) (+ y (random 50))) 30 'white) )) ;;contract: clear-cloud: number number -> boolean ;;purpose: clears a cloud (define (clear-cloud x y) (draw-solid-rect (make-posn (- x 30) (- y 30)) 110 110 'cyan)) ;;contract: draw-sun: number number -> boolean ;;purpose: draws a sun (define (draw-sun x y) (and (draw-solid-disk (make-posn x y) 60 'gold) (draw-solid-disk (make-posn x y) 50 'yellow) )) ;; contract: clear-sun: number number -> boolean ;; purpose: clears a sun (define (clear-sun x y) (draw-solid-disk (make-posn x y) 60 'cyan)) ;; contract: dac-sun-cloud: number number number number -> boolean ;;purpose: draws a sun and a cloud, waits, then clears the sun and cloud (define (dac-sun-cloud x1 y1 x2 y2) (and (draw-sun x1 y1) (draw-cloud x2 y2) (sleep-for-a-while 1) (clear-sun x1 y1) (clear-cloud x2 y2) )) ;;contract: draw-moon: number number -> boolean ;;purpose: draws a moon (define (draw-moon x y ) (and (draw-solid-disk (make-posn x y) 50 'white) (draw-solid-disk (make-posn (+ x 20) y) 50 'black ) )) ;;contract: dac-moon: number number -> boolean ;;purpose: draws a moon waits then clears the moon (define (dac-moon x y) (and (draw-moon x y) (sleep-for-a-while 1) (draw-solid-disk (make-posn x y) 50 'black) )) ;; contract: draw-star: number -> boolean ;; purpose: draws a star (define (draw-star n) (draw-solid-disk (make-posn ( +(random 700) n) (random 401)) ( + n (random 3)) 'white)) ;; contract : draw-sky: symbol -> boolean ;; purpose : draws the sky (define (draw-sky color) (draw-solid-rect (make-posn 0 0) 1000 500 color)) ;; contract: draw-earth: symbol -> boolean ;; purpose: draws the earth (define (draw-earth color) (draw-solid-disk (make-posn 500 5400 ) 5000 color)) ;; contract: draw-sky-earth: symbol symbol -> boolean ;; purpose: draws the sky then earth (define (draw-sky-earth color1 color2) (and (draw-sky color1) (draw-earth color2) )) ;; stuff actually happens (start 1000 500) (draw-sky-earth 'cyan 'sienna) (dac-sun-cloud 800 0 200 150) (dac-sun-cloud 740 175 300 200) (draw-sky 'orange) (draw-sun 680 384) (draw-earth 'sienna) (draw-cloud 525 200) (sleep-for-a-while 2) (draw-sky-earth 'teal 'sienna) (draw-cloud 900 200) (draw-cloud 300 300) (sleep-for-a-while 2) (draw-sky-earth 'black 'purple) (draw-star 1) (draw-star 1) (draw-star 1) (draw-star 1) (draw-star 1) (draw-star 1) (draw-star 1) (draw-star 1) (dac-moon 900 0) (dac-moon 840 150) (dac-moon 780 300) (stop)