;; 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 entry5) (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"))))) ;; 1301 Lab 3 Final ;; ;; The structure represents a face (define-struct face (center)) ;; drawFace: face posn -> boolean ;; to draw the the face with the given center (define (drawFace face) (and (draw-circle (face-center face) 100 'Red) (draw-solid-disk (face-center face) 90 'Red) (draw-solid-rect (face-center face) (* 1.6 90) 40) (draw-solid-disk (make-posn (- (posn-x (face-center face)) 20) (- (posn-y (face-center face)) 20)) 20 'White) (draw-solid-disk (make-posn (+ (posn-x (face-center face)) 20) (- (posn-y (face-center face)) 20)) 20 'White) (draw-solid-disk (make-posn (- (posn-x (face-center face)) 8) (- (posn-y (face-center face)) 20)) 8 'Yellow) (draw-solid-disk (make-posn (+ (posn-x (face-center face)) 8) (- (posn-y (face-center face)) 20)) 8 'Yellow) (draw-solid-disk (make-posn (posn-x (face-center face)) (+ (posn-y (face-center face)) 70)) 15 'White) )) ;; clearFace: face -> boolean ;; to clear a drawing of a face structure (define (clearFace face) (clear-solid-disk (face-center face) 150)) ;; drawAndClearFace: face -> boolean ;;to draw the the face with the given center, wait for a sec, and then clean it (define (drawAndClearFace face) (and (drawFace face) (sleep-for-a-while 1) (clearFace face))) ;; main() ;; to draw a face at a randomized center 10 times (start 600 600) (define counter 0) (define Face1 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face1) (define Face2 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face2) (define Face3 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face3) (define Face4 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face4) (define Face5 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face5) (define Face6 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face6) (define Face7 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face7) (define Face8 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face8) (define Face9 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face9) (define Face10 (make-face (make-posn (+ (random 400) 100) (+ (random 400) 100)))) (drawAndClearFace Face10) (stop)