;; This is a very visually unappealing mathematical formula used to draw lines
;; at the proper intervals around the dartboard created using the definition below
(define (DRAW-NEW-LINE line_number outer-radius center-x center-y)
(draw-solid-line
(make-posn (+ center-x (* .1 outer-radius (cos (* pi (+ 0.5 line_number) 0.1)))) ; X-COORD just outside of bulls-eye
(+ center-y (* .1 outer-radius (sin (* pi (+ 0.5 line_number) 0.1))))) ; Y-COORD just outside of bulls-eye
(make-posn (+ center-x (* outer-radius (cos (* pi (+ 0.5 line_number) 0.1)))) ; X-COORD at outermost part of board
(+ center-y (* outer-radius (sin (* pi (+ 0.5 line_number) 0.1))))) ; Y-COORD at outermost part of board
'black))
;; create-dartboard consumes an number, posn, and 4 symbols (colors)
;;
;; (create-dartboard outer-radius center-posn color-one color-two color-bull-one color-bull-two)
;; creates a dartboard centered at posn center-posn, with an size of outer-radius
;; and a color scheme of color-one for the double score and triple score rings (in darts),
;; color-two for the single score rings, color-bull-one for single bull and color-bull-two for double bull.
;;
;; Note that if center-x or center-y is smaller than outer-radius then the dartboard will not fit in the display.
;; The same thing occurs if center-x + outer-radius is larger than the display width,
;; or if center-y + outer-radius is larger than the display height.
;;
;; sample usage
;; (create-dartboard 250 (make-posn 300 300) 'red 'blue 'green 'red)
;; (create-dartboard 60 (make-posn 75 75) 'red 'blue 'red 'blue)
;; This example if run in a 600 by 600 graphics window will produce a large dartboard in the middle of the screen
;; with a smaller one in the upper-left corner of the screen (assuming both were run together)
;; This funtcion requires that the teachpack draw.ss has been added and that start has already been called
;; Also, make sure that outer-radius is defined as greater than or equal to 20.
;;
(define (create-dartboard outer-radius center-posn color-one color-two color-bull-one color-bull-two)
(and
(draw-solid-disk center-posn outer-radius color-one)
(draw-solid-disk center-posn (floor (* .9 outer-radius)) color-two)
(draw-solid-disk center-posn (floor (* .5 outer-radius)) color-one)
(draw-solid-disk center-posn (floor (* .4 outer-radius)) color-two)
(draw-solid-disk center-posn (floor (* .1 outer-radius)) color-bull-one)
(draw-solid-disk center-posn (floor (* .05 outer-radius)) color-bull-two)
(DRAW-NEW-LINE 0 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 1 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 2 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 3 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 4 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 5 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 6 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 7 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 8 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 9 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 10 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 11 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 12 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 13 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 14 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 15 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 16 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 17 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 18 outer-radius (posn-x center-posn) (posn-y center-posn))
(DRAW-NEW-LINE 19 outer-radius (posn-x center-posn) (posn-y center-posn))
))
; My test code
;(define GRAPHICS-WIDTH 600)
;(define GRAPHICS-HEIGHT 600)
;(start GRAPHICS-WIDTH GRAPHICS-HEIGHT)
;(create-dartboard 250 (make-posn 300 300) 'red 'blue 'green 'red)
;(create-dartboard 45 (make-posn 60 60) 'red 'blue 'green 'red)
;(create-dartboard 47 (make-posn 60 540) 'red 'blue 'green 'red)
;(create-dartboard 27 (make-posn 540 60) 'red 'blue 'green 'red)
;(create-dartboard 33 (make-posn 540 540) 'red 'blue 'green 'red)