;; The structrure represents a ring; center is a position (posn) ;; of the center, inner-rad and outer-rad are the inner and the ;; oter raduius values, respectively, and color is a symbol ;; that represents the color (define-struct ring (center inner-rad outer-rad color)) ;; draw-ring: ring -> boolean ;; Purpose: to draw a ring structure (define (draw-ring a-ring) (and (draw-solid-disk (ring-center a-ring) (ring-outer-rad a-ring) (ring-color a-ring)) (draw-solid-disk (ring-center a-ring) (ring-inner-rad a-ring) 'white) ) ) (start 300 300) (define ring1 (make-ring (make-posn 150 150) 50 100 'red)) (draw-ring ring1) ;; clear-ring: ring -> boolean ;; Purpose: to clear a drawing of a ring structure (define (clear-ring a-ring) (clear-solid-disk (ring-center a-ring) (ring-outer-rad a-ring)) ) (sleep-for-a-while 1) (clear-ring ring1) (define ring2 (make-ring (make-posn 150 150) 40 90 'red)) ;; draw-and-clear-ring: ring -> boolean ;; Purpose: to draw a ring structure, wait for 1 sec and ;; then clear it (define (draw-and-clear-ring a-ring) (and (draw-ring a-ring) (sleep-for-a-while 1) (clear-ring a-ring) ) ) (draw-and-clear-ring ring2) (define ring3 (make-ring (make-posn 150 150) 30 80 'red)) (draw-and-clear-ring ring3) (define ring4 (make-ring (make-posn 150 150) 20 70 'red)) (draw-and-clear-ring ring4) (define ring5 (make-ring (make-posn 150 150) 10 60 'red)) (draw-and-clear-ring ring5)