;; draw-tree consumes a posn, and a height
;;
;; (draw-sailboat pos height)
;; will draw a tree starting at the x,y coordinates specified
;; by the posn structure position, with a height specified
;; by height as the height of the tree
;;
;; note that the position is used as the bottom of the tree
;;
;; sample usage:
;; (draw-tree (make-posn 100 100) 30)
;;
;; note that this requires the teachpack draw.ss and requires that the
;; start function has already been called to create a window.
;;
(define (draw-tree pos height)
(and
;; draw trunk
(draw-solid-line (make-posn (- (posn-x pos) 1) (posn-y pos))
(make-posn (- (posn-x pos) 1) (- (posn-y pos) height))
'brown)
(draw-solid-line pos (make-posn (posn-x pos) (- (posn-y pos) height)) 'brown)
(draw-solid-line (make-posn (+ (posn-x pos) 1) (posn-y pos))
(make-posn (+ (posn-x pos) 1) (- (posn-y pos) height))
'brown)
;; draw "leaves"
(draw-solid-disk (make-posn (posn-x pos) (- (posn-y pos) height))
(* height .2)
'green)
)
)
;;(start 300 300)
;;(draw-tree (make-posn 100 100) 30)