;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-beginner-reader.ss" "lang")((modname entry8) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp"))))) (start 400 400) ; The starting position of the animation is the horizontal guitar. Pretty self explanitory. (define (horizontalguitar x) (and (draw-solid-disk (make-posn 100 265) 50 'brown) (draw-solid-disk (make-posn 165 265) 40 'brown) (draw-solid-disk (make-posn 100 265) 20 'black) (draw-solid-rect (make-posn 200 250) 105 20 'black) (draw-solid-rect (make-posn 305 245) 35 30 'black) ) ) ; Replace-guitar is used to switch from a horizontal guitar to a vertical one later on in the show. (define (replace-guitar x) (and (clear-solid-disk (make-posn 165 265) 40 'brown) (clear-solid-rect (make-posn 200 250) 105 20 'black) (clear-solid-rect (make-posn 305 245) 35 30 'black) (clear-solid-disk (make-posn 100 265) 50 'brown) (draw-solid-disk (make-posn 100 265) 50 'brown) (draw-solid-disk (make-posn 100 265) 20 'black) (draw-solid-disk (make-posn 100 195) 40 'brown) (draw-solid-rect (make-posn 90 55) 20 105 'black) (draw-solid-rect (make-posn 85 30) 30 35 'black) ) ) ; Random-hand creates a random "hand" on the neck of the guitar. Used a "random" function to show where on the x axis it shows up within the range of 210-300. (define (random-hand y) (and (draw-solid-disk (make-posn (+ 210 (random 90)) y) 9 'tan) (sleep-for-a-while 2) (draw-solid-rect (make-posn 200 250) 105 20 'black) )) ; The goal with makenote is to make a musical note at position (x,y) in order to not have to code it repeatedly. (define (makenote x y) (and (random-hand 260) (draw-solid-disk (make-posn x y) 10 'black) (draw-solid-line (make-posn (+ x 10) y) (make-posn (+ x 10) (- y 40)) 'black) (draw-solid-line (make-posn (+ x 10) (- y 40)) (make-posn (+ x 25) (- y 40)) 'black) (sleep-for-a-while 2) (clear-solid-disk (make-posn x y) 10 'black) (clear-solid-line (make-posn (+ x 10) y) (make-posn (+ x 10) (- y 40)) 'black) (clear-solid-line (make-posn (+ x 10) (- y 40)) (make-posn (+ x 25) (- y 40)) 'black) ) ) ; The function doublenote is used to make a pair of 8th notes in the drawing. (define (doublenote x y) (and (random-hand 260) (draw-solid-disk (make-posn x y) 10 'black) (draw-solid-disk (make-posn (+ x 40) y) 10 'black) (draw-solid-line (make-posn (+ x 10) y) (make-posn (+ x 10) (- y 40)) 'black) (draw-solid-line (make-posn (+ x 10) (- y 40)) (make-posn (+ x 50) (- y 40)) 'black) (draw-solid-line (make-posn (+ x 50) y) (make-posn (+ x 50) (- y 40)) 'black) (sleep-for-a-while 2) (clear-solid-disk (make-posn x y) 10 'black) (clear-solid-line (make-posn (+ x 10) y) (make-posn (+ x 10) (- y 40)) 'black) (clear-solid-line (make-posn (+ x 10) (- y 40)) (make-posn (+ x 50) (- y 40)) 'black) (clear-solid-line (make-posn (+ x 50) y) (make-posn (+ x 50) (- y 40)) 'black) (clear-solid-disk (make-posn (+ x 40) y) 10 'black) ) ) ; Structure here is to make a fan at position (head-x, head-y) with a head radius "radius" (define-struct fan (head-x head-y radius)) (define (draw-fan a-fan) (and (draw-solid-disk (make-posn (fan-head-x a-fan) (fan-head-y a-fan)) (fan-radius a-fan) 'tan) (draw-solid-rect (make-posn (- (fan-head-x a-fan) 20) (+ (fan-head-y a-fan) 20)) 40 75 'darkgreen) (draw-solid-rect (make-posn (- (fan-head-x a-fan) 35) (fan-head-y a-fan)) 15 40 'tan) (draw-solid-rect (make-posn (+ (fan-head-x a-fan) 20) (fan-head-y a-fan)) 15 40 'tan) (draw-solid-rect (make-posn (- (fan-head-x a-fan) 35) (+ (fan-head-y a-fan) 15)) 15 25 'darkgreen) (draw-solid-rect (make-posn (+ (fan-head-x a-fan) 20) (+ (fan-head-y a-fan) 15)) 15 25 'darkgreen) (draw-solid-string (make-posn (- (fan-head-x a-fan) 45) (- (fan-head-y a-fan) 35)) "WOOOOOOO!") ) ) (horizontalguitar 1) (makenote 100 75) (doublenote 200 190) (makenote 150 75) (doublenote 100 100) (makenote 325 100) (doublenote 200 75) (makenote 250 150) (replace-guitar 1) (draw-fan (make-fan 300 325 20))