
;;;Procedures needed to draw stars
(define image-string-art-color-variation!
  (lambda (image num colors edge-col edge-row width height theta1 theta2)
    (let ((col-spacing (/ width (- num 1)))
          (row-spacing (/ height (- num 1))))
      (let kernel ((i 0))
        (cond ((< i num)
               (let ((col1 (+ edge-col (* (* (- num 1 i) row-spacing) (sin theta1))))
                     (row1 (+ edge-row (* (* (- num 1 i) row-spacing) (cos theta1))))
                     (col2 (+ edge-col (* (* i col-spacing) (cos (- theta2)))))
                     (row2 (+ edge-row (* (* i col-spacing) (sin (- theta2))))))
                 ;(print (list col1 row1 col2 row2)) ; for debugging
                 (context-set-fgcolor! (list-ref colors (modulo i (length colors))))
                 (image-draw-line! image
                                   col1 row1
                                   col2 row2))
               (context-update-displays!)
               (kernel (+ i 1))))))))

(define image-string-star-colors!
  (lambda (image colors number points edge-col edge-row width height theta)
    (let ((thetaChange (/ (* 2 pi) points)))
      ;(print thetaChange) ;for debugging
      (let kernel1 ((i 0))
        (cond ((< i points)
               (let ((theta1 (+ (* i thetaChange) theta)))
                 ;(print theta1) ;for debugging
                 (image-string-art-color-variation! image number colors edge-col edge-row width height
                                    theta1
                                    (+ theta1 (- thetaChange (/ pi 2)))))
               (kernel1 (+ i 1))))))))

;;;This procedure is used to draw sunbursts, which are used twice.
(define image-draw-sun!
 (lambda (image colors number points edge-col edge-row width height n)
   (context-set-brush! "Circle (01)")
   (image-string-star-colors! image colors number points edge-col edge-row (sin-square width n 30 1) (sin-square height n 30 1) (* .01 n))
   (image-string-star-colors! image colors number points edge-col edge-row (cos-square width n 30 1) (cos-square width n 30 1) (+ (/ pi points) (* -.01 n)))))

;;;This procedure draws a house.  Depending on the time of day, the lights will be on inside the house.
(define image-draw-happy-hollow!
 (lambda (image x y width height n)
   (context-set-brush! "Circle (01)")
   (context-set-fgcolor! "black")
     (let* ((c  (* .1 width))
            (j  (* .8 width))
            (h  (* .2 height))
            (b  (* .5 height))
            (k  (* .3 height)))
            ;drawing the square of the house
       (image-select-polygon! image selection-replace
                              (list (point-new (+ x c) (- y h))
                                    (point-new (+ x c) (- y h b))
                                    (point-new (+ x c j) (- y h b))
                                    (point-new (+ x c j) (- y h))))
       (image-stroke! image)
       ;drawing the roof of the house
       (image-select-polygon! image selection-replace
                              (list
                               (point-new x (- y h b))
                               (point-new (+ x c (/ j 2)) (- y h b k))
                               (point-new (+ x (* 2 c) j) (- y h b))))
       (image-stroke! image)
       ;drawing the stilts of the house
       (image-select-polygon! image selection-replace
                              (list (point-new x y)
                                    (point-new x (- y h))
                                    (point-new (+ x c) (- y h))
                                    (point-new (+ x c) y)))
       (image-stroke! image)
       
       (image-select-polygon! image selection-replace
                              (list (point-new (+ x c j) y)
                                    (point-new (+ x c j) (- y h))
                                    (point-new (+ x (* 2 c) j)  (- y h))
                                    (point-new (+ x (* 2 c) j) y)))
       (image-stroke! image)
       ;drawing the door of the house
       (image-select-polygon! image selection-replace
                              (list (point-new (+ x c (* .4 j)) (- y h))
                                    (point-new (+ x c (* .6 j)) (- y h))
                                    (point-new (+ x c (* .6 j)) (- y h (* .6 b)))
                                    (point-new (+ x c (* .4 j)) (- y h (* .6 b)))))
       (image-fill! image)
       ;drawing a window of the house
       (image-select-polygon! image selection-replace
                              (list (point-new (+ x c (* .2 j)) (- y h (* .6 b)))
                                    (point-new (+ x c (* .3 j)) (- y h (* .6 b)))
                                    (point-new (+ x c (* .3 j)) (- y h (* .8 b)))
                                    (point-new (+ x c (* .2 j)) (- y h (* .8 b)))))
       (cond ((> (modulo n 1000) 500)  ;;;THIS WILL NEED TO BE EDITED DEPENDING ON WHEN NIGHT IS!!!
              (context-set-fgcolor! "yellow")
              (image-fill! image)
              (context-set-fgcolor! "black")
              (image-stroke! image))
             (else (image-stroke! image)))
       (image-stroke! image)
       
       (image-select-polygon! image selection-replace
                              (list (point-new (+ x c (* .7 j)) (- y h (* .6 b)))
                                    (point-new (+ x c (* .8 j)) (- y h (* .6 b)))
                                    (point-new (+ x c (* .8 j)) (- y h (* .8 b)))
                                    (point-new (+ x c (* .7 j)) (- y h (* .8 b)))))
       (cond ((> (modulo n 1000) 500) ;;;THIS WILL NEED TO BE EDITED DEPENDING ON WHEN NIGHT IS!!!
              (context-set-fgcolor! "yellow")
              (image-fill! image)
              (context-set-fgcolor! "black")
              (image-stroke! image)))
       (image-stroke! image)
       
       (image-select-nothing! image))))

;;;This function draws the shore
(define draw-shore
  (lambda (image row width height n)
    (image-compute-pixels! image  0  (- row (* .1 height))  width  (+ row (* .03 height)) 
                           (lambda (pos)
                             (if (> (position-row pos)
                                    (+ row (* (sin (/ n 31)) (* (* .025 height) (sin (/ (position-col pos) 10))))))
                                 (rgb-new 0 0 128)
                                 (rgb-new 219 147 112))))))

;;;This draws the lighthouse
;The Lighthouse
(define draw-lighthouse
  (let ((lighthousemap (list
                        (rgb-new 255 255 60)
                        (rgb-new 255 255 70)
                        (rgb-new 255 255 80)
                        (rgb-new 255 255 90)
                        (rgb-new 255 255 100)
                        (rgb-new 255 255 110)
                        (rgb-new 255 255 120)
                        (rgb-new 255 255 130)
                        (rgb-new 255 255 140)
                        (rgb-new 255 255 150)
                        (rgb-new 255 255 160)
                        (rgb-new 255 255 170)
                        (rgb-new 255 255 180)
                        (rgb-new 255 255 190)
                        (rgb-new 255 255 200)
                        (rgb-new 255 255 210)
                        (rgb-new 255 255 200)
                        (rgb-new 255 255 190)
                        (rgb-new 255 255 180)
                        (rgb-new 255 255 170)
                        (rgb-new 255 255 160)
                        (rgb-new 255 255 150)
                        (rgb-new 255 255 140)
                        (rgb-new 255 255 130)
                        (rgb-new 255 255 120)
                        (rgb-new 255 255 110)
                        (rgb-new 255 255 100)
                        (rgb-new 255 255 90)
                        (rgb-new 255 255 80)
                        (rgb-new 255 255 70))))
    (lambda (image n)
      (let ((width (image-width image))
            (height (image-height image)))
        (context-set-brush! "Circle (01)")
        (context-set-fgcolor! "red")
        ;base
        (image-select-polygon! image selection-replace
                               (list (point-new 0 (* .39 height))
                                     (point-new (* .19 width) (* .39 height))
                                     (point-new (* .17 width) (* .14 height))
                                     (point-new (* .02 width) (* .14 height))))
        (image-fill! image)
        (context-set-fgcolor! "black")
        (image-stroke! image)
        ;top
        (image-select-ellipse! image selection-replace
                               (* .06 width) (* .02 height) (* .07 width) (* .07 height))
        (image-fill! image)
        (image-select-polygon! image selection-replace
                               (list (point-new (* .06 width) (* .14 height))
                                     (point-new (* .06 width) (* .06 height))
                                     (point-new (* .13 width) (* .06 height))
                                     (point-new (* .13 width) (* .14 height))))
        (context-set-fgcolor! "white")
        (image-fill! image)
        (context-set-fgcolor! "black")
        (image-stroke! image)
        ;stripes
        (context-set-fgcolor! "white")
        (image-select-polygon! image selection-replace
                               (list (point-new (* .08 width) (* .15 height))
                                     (point-new (* .12 width) (* .15 height))
                                     (point-new (* .17 width) (* .21 height))
                                     (point-new (* .17 width) (* .24 height))))
        (image-select-polygon! image selection-add
                               (list (point-new (* .03 width) (* .14 height))
                                     (point-new (* .18 width) (* .30 height))
                                     (point-new (* .18 width) (* .32 height))
                                     (point-new (* .03 width) (* .17 height))))
        (image-select-polygon! image selection-add
                               (list (point-new (* .02 width) (* .23 height))
                                     (point-new (* .02 width) (* .25 height))
                                     (point-new (* .16 width) (* .39 height))
                                     (point-new (* .18 width) (* .39 height))))
        (image-select-polygon! image selection-add
                               (list (point-new (* .02 width) (* .29 height))
                                     (point-new (* .02 width) (* .31 height))
                                     (point-new (* .10 width) (* .39 height))
                                     (point-new (* .12 width) (* .39 height))))
        (image-select-polygon! image selection-add
                               (list (point-new 0 (* .34 height))
                                     (point-new 0 (* .35 height))
                                     (point-new (* .05 width) (* .39 height))
                                     (point-new (* .04 width) (* .39 height))))
        (image-fill! image)
        (image-select-nothing! image)
        (image-draw-sun! image lighthousemap 30 7 (* 0.094 width) (* .1 height) (* .04 width) (* .04 height) n)
        (context-update-displays!)))))

;;;This procedure draws the clouds
;The Cloud Procedure
(define cloud
  (lambda (image start-col start-row width height)
    (context-set-brush! "Circle Fuzzy (15)")
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .12 width)) (+ start-row (* .40 height)) (* .15 width ) (* .15 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .80 width)) (+ start-row (* .35 height)) (* .15 width) (* .15 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .15 width)) (+ start-row (* .15 height)) (* .35 width) (* .35 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .30 width)) (+ start-row (* .05 height)) (* .35 width) (* .35 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .25 width)) (+ start-row (* .40 height)) (* .20 width) (* .20 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .40 width)) (+ start-row (* .40 height)) (* .25 width ) (* .25 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .55 width)) (+ start-row (* .30 height)) (* .30 width) (* .30 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    ;ball
    (context-set-fgcolor! (rgb-new 245 245 245))
    (image-select-ellipse! image selection-replace
                           (+ start-col (* .55 width)) (+ start-row (* .15 height)) (* .35 width) (* .35 height))
    (image-fill! image)
    (context-set-fgcolor! "white")
    (image-stroke! image)
    (image-select-nothing! image)
    (context-update-displays!)))

;;;This draws the stairs
(define image-draw-stairs
  (lambda (image)
    (define turtle1 (turtle-new image))
    (turtle-down! turtle1 image)
    (turtle-teleport!
     turtle1
     ;col
     (* .6 (- (image-width image) 1))
     ;row
     (* .7 (- (image-height image) 1)))
    (turtle-turn! turtle1 180)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 90)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 270)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 90)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 270)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    ;5
    (turtle-turn! turtle1 90)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 270)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 90)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 270)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 90)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    ;10
    (turtle-turn! turtle1 270)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 90)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    (turtle-turn! turtle1 270)
    (turtle-forward! turtle1 (* .05 (image-height image)))
    ;12
    (context-update-displays!)))
 
;Drawing standing stick-figure
(define draw-circle!
  (lambda (image col row radius)
    (image-select-ellipse! image selection-replace
                           (- col radius) (- row radius)
                           (+ radius radius) (+ radius radius))
    (image-stroke! image)
    (image-select-nothing! image)))
 
(define image-draw-stick-figure-standing!
(lambda (image col row head-radius)
   (let* ((turtle1 (turtle-new image))
          (turtle2 (turtle-new image))
          (turtle3 (turtle-new image))
          (turtle4 (turtle-new image)))
   (context-set-brush! "Circle (01)")
   (context-set-fgcolor! "black")
     ;drawing the head
   (draw-circle! image col row head-radius)
   ;drawing the torso
   (image-draw-line!
    image
    ;start-col
    col
    ;start-row                
    (+ row head-radius)
    ;end-col
    col
    ;end-row
    (+ (* .025 (image-height image)) (+ row head-radius)))
   ;drawing the arms
     (turtle-set-brush! turtle1 "Circle (01)")
     (turtle-teleport! turtle1
                     col
                     ;row
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle1 315)
     (turtle-down! turtle1)
     (turtle-forward! turtle1 (* 1.75 head-radius))
     (turtle-set-brush! turtle2 "Circle (01)")
     (turtle-teleport! turtle2
                     col
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle2 225)
     (turtle-down! turtle2)
     (turtle-forward! turtle2 (* 1.75 head-radius))
     ;drawing the bottom half
     (image-draw-line!
      image
      ;start-col
      col
      ;start-row                
      (+ (* .025 (image-height image)) (+ row head-radius))
      ;end-col
      col
      ;end-row
      (+ (* .05 (image-height image)) (+ row head-radius)))
     ;drawing the legs
     (turtle-set-brush! turtle3 "Circle (01)")
     (turtle-teleport! turtle3
                     col
                     (+ (* .05 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle3 45)
     (turtle-down! turtle3)
     (turtle-forward! turtle3 (* 1.75 head-radius))
     (turtle-set-brush! turtle4 "Circle (01)")
     (turtle-teleport! turtle4
                     col
                     (+ (* .05 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle4 135)
     (turtle-down! turtle4)
     (turtle-forward! turtle4 (* 1.75 head-radius)))))
 
;Drawing stick figure climbing
(define image-draw-stick-figure-climbing!
(lambda (image col row head-radius)
   ;defining turtles for later
   (let* ((turtle1 (turtle-new image))
          (turtle2 (turtle-new image))
          (turtle3 (turtle-new image))
          (turtle4 (turtle-new image)))
   ;setting brushes and color
     (context-set-brush! "Circle (01)")
     (context-set-fgcolor! "black")
     ;drawing the head
     (draw-circle! image col row head-radius)
     ;drawing the torso
     (image-draw-line!
    image
    ;start-col
    col
    ;start-row                
    (+ row head-radius)
    ;end-col
    col
    ;end-row
    (+ (* .025 (image-height image)) (+ row head-radius)))
   ;drawing the arms
     (turtle-set-brush! turtle1 "Circle (01)")
     (turtle-teleport! turtle1
                     col
                     ;row
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle1 315)
     (turtle-down! turtle1)
     (turtle-forward! turtle1 (* 1.75 head-radius))
     (turtle-set-brush! turtle2 "Circle (01)")
     (turtle-teleport! turtle2
                     col
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle2 225)
     (turtle-down! turtle2)
     (turtle-forward! turtle2 (* 1.75 head-radius))
     ;drawing the bottom half
     (image-draw-line!
      image
      ;start-col
      col
      ;start-row                
      (+ (* .025 (image-height image)) (+ row head-radius))
      ;end-col
      col
      ;end-row
      (+ (* .0375 (image-height image)) (+ row head-radius)))
     ;drawing the legs
     (turtle-set-brush! turtle3 "Circle (01)")
     (turtle-teleport! turtle3 col
                     (+ (* .0375 (image-height image)) (+ row head-radius)))
   ;straightening a leg to give the illusion of walking
     (turtle-turn! turtle3 90)
     (turtle-down! turtle3)
     (turtle-forward! turtle3 (* 2 head-radius))
     (turtle-set-brush! turtle4 "Circle (01)")
     (turtle-teleport! turtle4 col
                       (+ (* .0375 (image-height image)) (+ row head-radius)))
   ;curving one leg to give the illusion of walking up
     (turtle-turn! turtle4 180)
     (turtle-down! turtle4)
     (turtle-forward! turtle4 (* .875 head-radius))
     (turtle-turn! turtle4 270)
     (turtle-forward! turtle4 (* .875 head-radius)))))
 

 
 
;Stickman Dance
(define image-draw-stickdance-position1
(lambda (image col row head-radius)
   ;defining turtles for later
   (let* ((turtle1 (turtle-new image))
          (turtle2 (turtle-new image))
          (turtle3 (turtle-new image))
          (turtle4 (turtle-new image)))
   ;setting brushes and color
     (context-set-brush! "Circle (01)")
     (context-set-fgcolor! "black")
     ;drawing the head
     (draw-circle! image col row head-radius)
     ;drawing the torso
     (image-draw-line!
    image
    ;start-col
    col
    ;start-row                
    (+ row head-radius)
    ;end-col
    col
    ;end-row
    (+ (* .025 (image-height image)) (+ row head-radius)))
   ;drawing the arms
     (turtle-set-brush! turtle1 "Circle (01)")
     (turtle-teleport! turtle1
                     col
                     ;row
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle1 45)
     (turtle-down! turtle1)
     (turtle-forward! turtle1 (* 1.75 head-radius))
     (turtle-set-brush! turtle2 "Circle (01)")
     (turtle-teleport! turtle2
                     col
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle2 270)
     (turtle-down! turtle2)
     (turtle-forward! turtle2 (* 1.75 head-radius))
     ;drawing the bottom half
     (image-draw-line!
      image
      ;start-col
      col
      ;start-row                
      (+ (* .025 (image-height image)) (+ row head-radius))
      ;end-col
      col
      ;end-row
      (+ (* .05 (image-height image)) (+ row head-radius)))
     ;drawing the legs
     (turtle-set-brush! turtle3 "Circle (01)")
     (turtle-teleport! turtle3 col
                     (+ (* .05 (image-height image)) (+ row head-radius)))
   ;drawing
     (turtle-turn! turtle3 45)
     (turtle-down! turtle3)
     (turtle-forward! turtle3 (* 1.75 head-radius))
     (turtle-set-brush! turtle4 "Circle (01)")
     (turtle-teleport! turtle4 col
                       (+ (* .05 (image-height image)) (+ row head-radius)))
   ;drawing the legs
     (turtle-down! turtle4)
     (turtle-turn! turtle4 270)
     (turtle-forward! turtle4 (* 1.75 head-radius)))))
 
(define image-draw-stickdance-position2
(lambda (image col row head-radius)
   ;defining turtles for later
   (let* ((turtle1 (turtle-new image))
          (turtle2 (turtle-new image))
          (turtle3 (turtle-new image))
          (turtle4 (turtle-new image)))
   ;setting brushes and color
     (context-set-brush! "Circle (01)")
     (context-set-fgcolor! "black")
     ;drawing the head
     (draw-circle! image col row head-radius)
     ;drawing the torso
     (image-draw-line!
    image
    ;start-col
    col
    ;start-row                
    (+ row head-radius)
    ;end-col
    col
    ;end-row
    (+ (* .025 (image-height image)) (+ row head-radius)))
   ;drawing the arms
     (turtle-set-brush! turtle1 "Circle (01)")
     (turtle-teleport! turtle1
                     col
                     ;row
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle1 45)
     (turtle-down! turtle1)
     (turtle-forward! turtle1 (* 1.75 head-radius))
     (turtle-set-brush! turtle2 "Circle (01)")
     (turtle-teleport! turtle2
                     col
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle2 180)
     (turtle-down! turtle2)
     (turtle-forward! turtle2 (* 1.75 head-radius))
     ;drawing the bottom half
     (image-draw-line!
      image
      ;start-col
      col
      ;start-row                
      (+ (* .025 (image-height image)) (+ row head-radius))
      ;end-col
      col
      ;end-row
      (+ (* .05 (image-height image)) (+ row head-radius)))
     ;drawing the legs
     (turtle-set-brush! turtle3 "Circle (01)")
     (turtle-teleport! turtle3 col
                     (+ (* .05 (image-height image)) (+ row head-radius)))
     ;straightening a leg for supporting the dance
     (turtle-turn! turtle3 90)
     (turtle-down! turtle3)
     (turtle-forward! turtle3 (* 1.75 head-radius))
     (turtle-set-brush! turtle4 "Circle (01)")
     (turtle-teleport! turtle4 col
                       (+ (* .05 (image-height image)) (+ row head-radius)))
   ;curving left leg for the dance
     (turtle-turn! turtle4 180)
     (turtle-down! turtle4)
     (turtle-forward! turtle4 (* .875 head-radius))
     (turtle-turn! turtle4 270)
     (turtle-forward! turtle4 (* .875 head-radius)))))
  (define image-draw-stick-figure-walking!
(lambda (image col row head-radius)
   ;defining turtles for later
   (let* ((turtle1 (turtle-new image))
          (turtle2 (turtle-new image))
          (turtle3 (turtle-new image))
          (turtle4 (turtle-new image)))
   ;setting brushes and color
     (context-set-brush! "Circle (01)")
     (context-set-fgcolor! "black")
     ;drawing the head
     (draw-circle! image col row head-radius)
     ;drawing the torso
     (image-draw-line!
    image
    ;start-col
    col
    ;start-row                
    (+ row head-radius)
    ;end-col
    col
    ;end-row
    (+ (* .025 (image-height image)) (+ row head-radius)))
   ;drawing the arms
     (turtle-set-brush! turtle1 "Circle (01)")
     (turtle-teleport! turtle1
                     col
                     ;row
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle1 315)
     (turtle-down! turtle1)
     (turtle-forward! turtle1 (* 1.75 head-radius))
     (turtle-set-brush! turtle2 "Circle (01)")
     (turtle-teleport! turtle2
                     col
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle2 225)
     (turtle-down! turtle2)
     (turtle-forward! turtle2 (* 1.75 head-radius))
     ;drawing the bottom half
     (image-draw-line!
      image
      ;start-col
      col
      ;start-row                
      (+ (* .025 (image-height image)) (+ row head-radius))
      ;end-col
      col
      ;end-row
      (+ (* .05 (image-height image)) (+ row head-radius)))
     ;drawing the legs
     (turtle-set-brush! turtle3 "Circle (01)")
     (turtle-teleport! turtle3 col
                     (+ (* .05 (image-height image)) (+ row head-radius)))
      ;straightening a leg for supporting the dance
     (turtle-turn! turtle3 90)
     (turtle-down! turtle3)
     (turtle-forward! turtle3 (* 1.75 head-radius))
     (turtle-set-brush! turtle4 "Circle (01)")
     (turtle-teleport! turtle4 col
                       (+ (* .05 (image-height image)) (+ row head-radius)))
   ;curving left leg for the dance
     (turtle-turn! turtle4 180)
     (turtle-down! turtle4)
     (turtle-forward! turtle4 (* .875 head-radius))
     (turtle-turn! turtle4 270)
     (turtle-forward! turtle4 (* .875 head-radius)))))
(define image-draw-stickdance-position4
(lambda (image col row head-radius)
   ;defining turtles for later
   (let* ((turtle1 (turtle-new image))
          (turtle2 (turtle-new image))
          (turtle3 (turtle-new image))
          (turtle4 (turtle-new image)))
   ;setting brushes and color
     (context-set-brush! "Circle (01)")
     (context-set-fgcolor! "black")
     ;drawing the head
     (draw-circle! image col row head-radius)
     ;drawing the torso
     (image-draw-line!
    image
    ;start-col
    col
    ;start-row                
    (+ row head-radius)
    ;end-col
    col
    ;end-row
    (+ (* .025 (image-height image)) (+ row head-radius)))
   ;drawing the arms
     (turtle-set-brush! turtle1 "Circle (01)")
     (turtle-teleport! turtle1
                     col
                     ;row
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle1 45)
     (turtle-down! turtle1)
     (turtle-forward! turtle1 (* 1.75 head-radius))
     (turtle-set-brush! turtle2 "Circle (01)")
     (turtle-teleport! turtle2
                     col
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle2 180)
     (turtle-down! turtle2)
     (turtle-forward! turtle2 (* 1.75 head-radius))
     ;drawing the bottom half
     (image-draw-line!
      image
      ;start-col
      col
      ;start-row                
      (+ (* .025 (image-height image)) (+ row head-radius))
      ;end-col
      col
      ;end-row
      (+ (* .05 (image-height image)) (+ row head-radius)))
     ;drawing the legs
     (turtle-set-brush! turtle3 "Circle (01)")
     (turtle-teleport! turtle3 col
                     (+ (* .05 (image-height image)) (+ row head-radius)))
      ;straightening a leg for supporting the dance
     (turtle-turn! turtle3 90)
     (turtle-down! turtle3)
     (turtle-forward! turtle3 (* 1.75 head-radius))
     (turtle-set-brush! turtle4 "Circle (01)")
     (turtle-teleport! turtle4 col
                       (+ (* .05 (image-height image)) (+ row head-radius)))
   ;curving right leg for the dance
     (turtle-down! turtle4)
     (turtle-forward! turtle4 (* .875 head-radius))
     (turtle-turn! turtle4 90)
     (turtle-forward! turtle4 (* .875 head-radius)))))
(define image-draw-stickdance-position5
(lambda (image col row head-radius)
   ;defining turtles for later
   (let* ((turtle1 (turtle-new image))
          (turtle2 (turtle-new image))
          (turtle3 (turtle-new image))
          (turtle4 (turtle-new image)))
   ;setting brushes and color
     (context-set-brush! "Circle (01)")
     (context-set-fgcolor! "black")
     ;drawing the head
     (draw-circle! image col row head-radius)
     ;drawing the torso
     (image-draw-line!
    image
    ;start-col
    col
    ;start-row                
    (+ row head-radius)
    ;end-col
    col
    ;end-row
    (+ (* .025 (image-height image)) (+ row head-radius)))
   ;raising the arms
     (turtle-set-brush! turtle1 "Circle (01)")
     (turtle-teleport! turtle1
                     col
                     ;row
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle1 315)
     (turtle-down! turtle1)
     (turtle-forward! turtle1 (* 1.75 head-radius))
     (turtle-set-brush! turtle2 "Circle (01)")
     (turtle-teleport! turtle2
                     col
                     (+ (* .025 (image-height image)) (+ row head-radius)))
     (turtle-turn! turtle2 225)
     (turtle-down! turtle2)
     (turtle-forward! turtle2 (* 1.75 head-radius))
     ;drawing the bottom half
     (image-draw-line!
      image
      ;start-col
      col
      ;start-row                
      (+ (* .025 (image-height image)) (+ row head-radius))
      ;end-col
      col
      ;end-row
      (+ (* .05 (image-height image)) (+ row head-radius)))
     ;drawing the legs
     (turtle-set-brush! turtle3 "Circle (01)")
     (turtle-teleport! turtle3 col
                     (+ (* .05 (image-height image)) (+ row head-radius)))
   ;straightening a leg for supporting the dance
     (turtle-turn! turtle3 90)
     (turtle-down! turtle3)
     (turtle-forward! turtle3 (* 1.75 head-radius))
     (turtle-set-brush! turtle4 "Circle (01)")
     (turtle-teleport! turtle4 col
                       (+ (* .05 (image-height image)) (+ row head-radius)))
   ;curving right leg for the dance
     (turtle-down! turtle4)
     (turtle-forward! turtle4 (* .875 head-radius))
     (turtle-turn! turtle4 90)
     (turtle-forward! turtle4 (* .875 head-radius)))))
 

;;;These procedures are used to compute various things with sine and cosine.  It's somewhat easier to use them than to write each function out each time.
(define sin-osc
  (lambda (input n slowness)
    (* 
     (sin
      (/ n slowness))
     input)))

(define cos-osc
  (lambda (input n slowness)
    (* 
     (sin
      (/ n slowness))
     input)))

(define cos-bounce
  (lambda (input n slowness negative01)
    (* 
     (+ 1
        (abs 
         (- 
          (cos 
           (/ n slowness))
          negative01)))
     input)))

(define cos-square
  (lambda (input n slowness negative01)
    (* 
     (+ 1
         (square 
          (- 
           (cos 
            (/ n slowness)) 
           negative01)))
     input)))

(define sin-bounce
  (lambda (input n slowness negative01)
    (* 
     (+ 1
        (abs 
         (- 
          (sin 
           (/ n slowness))
          negative01)))
     input)))

(define sin-square
  (lambda (input n slowness negative01)
    (* 
     (+ 1
         (square 
          (- 
           (sin 
            (/ n slowness)) 
           negative01)))
     input)))

;;;Sun color palette
(define sunmap
  (list 
   (rgb-new 255 80 0)
   (rgb-new 255 90 0)
   (rgb-new 255 100 0)
   (rgb-new 255 110 0)
   (rgb-new 255 120 0)
   (rgb-new 255 130 0)
   (rgb-new 255 140 0)
   (rgb-new 255 150 0)
   (rgb-new 255 160 0)
   (rgb-new 255 170 0)
   (rgb-new 255 180 0)
   (rgb-new 255 190 0)
   (rgb-new 255 200 0)
   (rgb-new 255 210 0)
   (rgb-new 255 220 0)
   (rgb-new 255 230 0)
   (rgb-new 255 220 0)
   (rgb-new 255 210 0)
   (rgb-new 255 200 0)
   (rgb-new 255 190 0)
   (rgb-new 255 180 0)
   (rgb-new 255 170 0)
   (rgb-new 255 160 0)
   (rgb-new 255 150 0)
   (rgb-new 255 140 0)
   (rgb-new 255 130 0)
   (rgb-new 255 120 0)
   (rgb-new 255 110 0)
   (rgb-new 255 100 0)
   (rgb-new 255 90 0)))


(define image-series
  (lambda (n width height)
    (let ((image (image-new width height)))
      (context-set-brush! "Circle (01)")
      (context-set-fgcolor! "black")
      (context-set-bgcolor! "white")
      ;;;This next bit draws the sky
      (image-select-rectangle! image selection-replace 0 0 (- width 1) (* .3 height))
      (context-set-fgcolor! "light blue")
      (image-fill! image)
      ;;;This is the sun
      (image-draw-sun! image sunmap 30 7 (* .9 width) (- (* .3 height) (* .2 height (sin (/ n (/ 1000 (* pi 2)))))) (* .02 width) (* .02 height) n)
      ;;;These are the clouds ;so, there is a problem.  n in the modulo term scrolls across a smaller image faster than a larger one.  fix it somehow.
      (cloud image (modulo (inexact->exact (+ n (* .1 width))) width) (* .07 height) (* .13 width) (* .13 height))
      (cloud image (modulo (inexact->exact (+ n (* .4 width))) width) (* .03 height) (* .1 width) (* .1 height))
      (cloud image (modulo (inexact->exact (+ n (* .5 width))) width) (* .15 height) (* .2 width) (* .2 height))
      ;;;Sand
      (image-select-rectangle! image selection-replace 0 (* .3 height) (- width 1) (* .4 height))
      (context-set-fgcolor! "tan")
      (image-fill! image)
      ;;;Ocean
      (image-select-rectangle! image selection-replace 0 (* .7 height) (- width 1) (* .3 (- height 1)))
      (context-set-fgcolor! "ocean blue")
      (image-fill! image)
      ;;;Shore
      ;(draw-shore image (* .7 height) (- width 1) height n)
      ;image-compute-pixels fails to properly compute the shore, so we have commented it out.  If it worked properly, it would draw a sine wave that grew and shrank, using the colors of the shore.  But as it stands, it messes up other things.
      ;;;Houses
      (image-draw-happy-hollow! image (* .4 (- width 1)) (* .45 (- height 1)) (* .1 width) (sin-bounce (* .07 height) n 23 0) n)
      (image-draw-happy-hollow! image (* .5 (- width 1)) (* .6 (- height 1)) (* .1 width) (sin-bounce (* .07 height) n 23 0) n)
      (image-draw-happy-hollow! image (* .6 (- width 1)) (* .45 (- height 1)) (* .1 width) (sin-bounce (* .07 height) n 23 0) n)
      (image-draw-happy-hollow! image (* .7 (- width 1)) (* .6 (- height 1)) (* .1 width) (sin-bounce (* .07 height) n 23 0) n)
      (image-draw-happy-hollow! image (* .80 (- width 1)) (* .45 (- height 1)) (* .1 width) (sin-bounce (* .07 height) n 23 0) n)
      ;;;Stairs
      ;(image-draw-stairs image)
      ;;;Draw the lighthouse!
      (draw-lighthouse image n)
      
      ;;;end of line
      (image-select-nothing! image)
      (context-update-displays!)
      (image-show image))))
      