;; draw-bus consumes a posn, a number and three colors (symbol)
;;
;; (draw-bus a-posn size color1 color2 color3)
;;  will draw a bus starting at the x,y coordinates specified
;;    by the posn structure position, with a size specified by the
;;    width of the bus excluding the side mirrors
;;
;;    note that the x coordiate in a-posn is used as the left corner
;;    of the side mirror while the y coordinate is used for the
;;    top edge of the bus
;;
;;    color1 is used to specify the color of the main body of the bus
;;    color2 is used to specify the color of the two stripes on the bus
;;      and the handle if driver is drawn
;;    color3 is used to specify the color of the driver's outfit
;;
;;    *also note that the size has to be a multiple of 100 due to
;;    the conflicts with using decimal numbers as coordinates
;;    
;; sample usage:
;; (draw-bus (make-posn 100 200) 100 'red 'green 'blue)
;; (draw-bus (make-posn 200 200) 400 'blue 'black 'orange)
;; 
;; note that this requires the teachpack draw.ss and requires that the
;; start function has already been called to create a window.
;;

(define (draw-bus a-posn size color1 color2 color3)
  (and
   ;; draw top of the main body of the bus
   (draw-solid-rect (make-posn (+ (posn-x a-posn) (* size .1)) (posn-y a-posn)) size (* size .2) color1)
   (draw-solid-rect (make-posn (+ (posn-x a-posn) (* size .1)) (+ (posn-y a-posn) (* size .2))) size (* size .05) color2)
   
   ;; draw the front window
   (draw-solid-rect (make-posn (+ (posn-x a-posn) (* size .1)) (+ (posn-y a-posn) (* size .25))) size (* size .5) 'skyblue)
   
   ;; function call to draw a bus driver - could be commented out to have a bus with no driver
   (draw-bus-driver a-posn size color2 color3)
   ;; has to be positioned between these two comment lines
   
   ;; draw bottom of the body of the bus
   (draw-solid-rect (make-posn (+ (posn-x a-posn) (* size .1)) (+ (posn-y a-posn) (* size .75))) size (* size .3) color1)
   (draw-solid-rect (make-posn (+ (posn-x a-posn) (* size .1)) (+ (posn-y a-posn) (* size 1.05))) size (* size .05) color2)
   
   ;; draw the two wheels
   (draw-solid-rect (make-posn (+ (posn-x a-posn) (* size .2)) (+ (posn-y a-posn) (* size 1.1))) (* size .15) (* size .15) 'black)
   (draw-solid-rect (make-posn (+ (posn-x a-posn) (- (+ size (* size .1)) (* size .25))) (+ (posn-y a-posn) (* size 1.1))) (* size .15) (* size .15) 'black)
   
   ;; draw the two headlights
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .25)) (+ (posn-y a-posn) (* size .9))) (* size .05) 'yellow)
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (- (+ size (* size .1)) (* size .15))) (+ (posn-y a-posn) (* size .9))) (* size .05) 'yellow)
   
   ;; draw the two side mirrors
   (draw-solid-rect (make-posn (posn-x a-posn) (+ (posn-y a-posn) (* size .65))) (* size .1) (* size .1) 'gray)
   (draw-solid-rect (make-posn (+ (posn-x a-posn) size (* size .1)) (+ (posn-y a-posn) (* size .65))) (* size .1) (* size .1) 'gray)
   
   ;; draw some lines on the tires
   (draw-solid-line (make-posn (+ (posn-x a-posn) (* size .25)) (+ (posn-y a-posn) (* size 1.1))) (make-posn (+ (posn-x a-posn) (* size .25)) (+ (posn-y a-posn) (* size 1.1) (* size .15))) 'white)
   (draw-solid-line (make-posn (+ (posn-x a-posn) (* size .3)) (+ (posn-y a-posn) (* size 1.1))) (make-posn (+ (posn-x a-posn) (* size .3)) (+ (posn-y a-posn) (* size 1.1) (* size .15))) 'white)
   (draw-solid-line (make-posn (+ (posn-x a-posn) (- (+ size (* size .1)) (* size .2))) (+ (posn-y a-posn) (* size 1.1))) (make-posn (+ (posn-x a-posn) (- (+ size .1) (* size .1))) (+ (posn-y a-posn) (* size 1.1) (* size .15))) 'white)
   (draw-solid-line (make-posn (+ (posn-x a-posn) (- (+ size (* size .1)) (* size .15))) (+ (posn-y a-posn) (* size 1.1))) (make-posn (+ (posn-x a-posn) (- (+ size .1) (* size .05))) (+ (posn-y a-posn) (* size 1.1) (* size .15))) 'white)
   ))

;; draw-bus-driver consumes a posn, a number and two colors (symbol)
;;
;; (draw-snowman a-posn size color1 color2)
;;  will draw a bus driver given the x,y coordinates and two colors
;;    that were given to the draw-bus function
;;
;;  note that this function is called within the draw-bus function
(define (draw-bus-driver a-posn size color1 color2)
  (and
   ;; draw the head
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .78)) (+ (posn-y a-posn) (* size .65))) (- (* size .75) (* size .65)) 'khaki)
   (draw-circle (make-posn (+ (posn-x a-posn) (* size .78)) (+ (posn-y a-posn) (* size .65))) (- (* size .75) (* size .65)) 'black)
   
   ;; draw the hat
   (draw-solid-rect (make-posn (- (+ (posn-x a-posn) (* size .78)) (- (* size .75) (* size .63))) (+ (posn-y a-posn) (* size .58))) (* (- (* size .75) (* size .63)) 2) (* size .01) color2)
   (draw-solid-rect (make-posn (- (+ (posn-x a-posn) (* size .78)) (- (* size .75) (* size .67))) (+ (posn-y a-posn) (* size .53))) (* (- (* size .75) (* size .67)) 2) (* size .05) color2)
   
   ;; draw the eyes
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .73)) (+ (posn-y a-posn) (* size .63))) (* size .01) 'black)
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .83)) (+ (posn-y a-posn) (* size .63))) (* size .01) 'black)
   
   ;; draw the mouth
   (draw-solid-line (make-posn (+ (posn-x a-posn) (* size .75)) (+ (posn-y a-posn) (* size .66))) (make-posn (+ (posn-x a-posn) (* size .78)) (+ (posn-y a-posn) (* size .68))) 'black)
   (draw-solid-line (make-posn (+ (posn-x a-posn) (* size .81)) (+ (posn-y a-posn) (* size .66))) (make-posn (+ (posn-x a-posn) (* size .78)) (+ (posn-y a-posn) (* size .68))) 'black)
   
   ;; draw the handle
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .78)) (+ (posn-y a-posn) (* size .8))) (- (* size .75) (* size .66)) color1)
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .78)) (+ (posn-y a-posn) (* size .8))) (- (* size .75) (* size .68)) color2)
   
   ;; draw the hands
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .7)) (+ (posn-y a-posn) (* size .73))) (- (* size .75) (* size .72)) 'khaki)
   (draw-solid-disk (make-posn (+ (posn-x a-posn) (* size .86)) (+ (posn-y a-posn) (* size .73))) (- (* size .75) (* size .72)) 'khaki)
   (draw-circle (make-posn (+ (posn-x a-posn) (* size .7)) (+ (posn-y a-posn) (* size .73))) (- (* size .75) (* size .72)) 'black)
   (draw-circle (make-posn (+ (posn-x a-posn) (* size .86)) (+ (posn-y a-posn) (* size .73))) (- (* size .75) (* size .72)) 'black)
   ))

;(start 800 800)
;(draw-bus (make-posn 20 20) 600 'red 'orange 'brown)