;; phases_of_moon consumes a posn, a number and a number (symbol)
;;
;; (phases_of_moon pos size phase_number) 
;;  will draw the phase of the moon specified by phase_number,
;;    starting at the x,y coordinates specified
;;    by the posn structure position, with a size specified by size
;;    (size = 0.5 reduces the picture by a scale of 2, 2 increase the picture by a scale of 2)
;;    
;;   There are 8 phases of the moon:
;;
;;             New Moon - Moon's unilluminated side is facing the Earth. The Moon is not visible (except during a solar eclipse).
;;                example: (draw-solid-disk(make-posn 150 150) 100 'Yellow) 
;;
;;             Waxing Crescent - Moon appears to be partly (less than 1/2) illuminated by sunlight. The fraction of the Moon's disk that is illuminated is increasing. 
;;                example: (draw-solid-disk(make-posn 150 150) 100 'Yellow) 
;;                         (draw-solid-disk(make-posn 100 150) 100 'Black)
;;
;;             First Quarter - One-half of the Moon appears to be illuminated by direct sunlight. The fraction of the Moon's disk that is illuminated is increasing.
;;               example: (draw-solid-disk(make-posn 150 150) 100 'Yellow) 
;;                        (draw-solid-rect(make-posn 0 0) 150  300 'Black)
;;
;;             Waxing Gibbous - Moon appears to be more than 1/2 but not fully illuminated by sunlight. The fraction of Moon's disk that is illuminated is increasing.
;;               example: (draw-solid-disk(make-posn 150 150) 100 'Yellow)
;;                        (draw-solid-disk(make-posn 0 150) 135 'Black)
;;
;;             Full Moon - The Moon's illuminated side is facing the Earth. The Moon appears to be completely illuminated by direct sunlight.
;;               example:(draw-circle(make-posn 150 150) 100 'Yellow) 
;;
;;             Waning Gibbous - Moon appears to be more than 1/2 but not fully illuminated by sunlight. The fraction of Moon's disk that is illuminated is decreasing.
;;               example: (draw-solid-disk(make-posn 150 150) 100 'Yellow)
;;                        (draw-solid-disk(make-posn 300 150) 135 'Black)
;;
;;             Last Quarter -  1/2 of the Moon appears to be illuminated by direct sunlight. The fraction of the Moon's disk that is illuminated is decreasing.
;;               example: (draw-solid-disk(make-posn 150 150) 100 'Yellow) 
;;                        (draw-solid-rect(make-posn 150 0) 300  300 'Black)
;;
;;             Waning Crescent - Moon appears to be partly but less than 1/2 illuminated by sunlight. The fraction of Moon's disk that is illuminated is decreasing.
;;               example: (draw-solid-disk(make-posn 150 150) 100 'Yellow)
;;                        (draw-solid-disk(make-posn 200 150) 100 'Black)
;;
;;    note that the picture formed is big to begin with
;;    
;; sample usage:
;; (phases_of_moon (make-posn 150 150) 1 8)
;; (phases_of_moon (make-posn 200 50) 0.5 7)
;; 
;; note that this requires the teachpack draw.ss and requires that the
;; start function has already been called to create a window. 
;;
;; suggested canvas size: (start 300 300)
;; suggested center: (150 150) 
;; suggested zize: 1



;(start 300 300)
;(draw-solid-rect(make-posn 0 0) 100000 100000 'Black)

(define (phases_of_moon pos size phase_number)
  (cond
    [(= phase_number 1) (draw-circle pos (* size 100) 'Yellow)] ;; New Moon
    
    [(= phase_number 2) (and (draw-solid-disk pos (* size 100) 'Yellow) ;; Waxing Crescent
                             (draw-solid-disk(make-posn (*(/ 2 3) (posn-x pos)) (posn-y pos)) (* size 100) 'Black))]  
    
    [(= phase_number 3) (and (draw-solid-disk pos (* size 100) 'Yellow);; First Quarter  
                             (draw-solid-rect(make-posn 0 0) (posn-x pos) (+ (posn-y pos) (* size 100)) 'Black))] 
    
    [(= phase_number 4) (and (draw-solid-disk pos (* size 100) 'Yellow) ;; Waxing Gibbous                             
                             (draw-solid-disk(make-posn 0 (posn-y pos)) (posn-x pos) 'Black))] 
    
    [(= phase_number 5) (draw-solid-disk pos (* size 100) 'Yellow)] ;; Full Moon
    
    [(= phase_number 6) (and (draw-solid-disk pos (* size 100) 'Yellow) ;; Waning Gibbous
                             (draw-solid-disk(make-posn (+(posn-x pos) (* size 100)) (posn-y pos)) (* size 100) 'Black))]    
    
    [(= phase_number 7) (and (draw-solid-disk pos (* size 100) 'Yellow) ;; Last Quarter
                          (draw-solid-rect(make-posn (posn-x pos) 0) (+ (posn-x pos) (* size 100)) (+ (posn-y pos) (* 2 size 100)) 'Black))]    
    
    [(= phase_number 8) (and (draw-solid-disk pos (* size 100) 'Yellow) ;; Waning Crescent
                             (draw-solid-disk(make-posn (+(posn-x pos) (* size 100 0.6)) (+(posn-y pos) size )) (* size 100) 'Black))]
    [else 'false]))

;(start 250 100)
;(draw-solid-rect(make-posn 0 0) 100000 100000 'Black)
;(define (primary_stages size)
;  (and (phases_of_moon (make-posn 100 50) size 3)
;       (phases_of_moon (make-posn 150 50) size 5)
;       (phases_of_moon (make-posn 200 50) size 7)
;       (phases_of_moon (make-posn 50 50) size 1)))  
;(primary_stages 0.1)