### COMPUTER SCIENCE LESSONS

GRAPHIC PROGRAMS
LESSONS
Scaled Cartisian Plane Code
Copy and Paste the code below into DrScheme and Execute.
 ```;;====================TEACH PACK SCALED COORDINATE PLANE==============| ;;--------------------> Constant Definitions <--------------------- (define L 400) ;; Length of Canvas (define M (/ L 2)) ;; Middle (define F 10) ;; Scale Factor (start L L) ;; Starts a drawing canvas ;;------------------- > X-AXIS and Y-AXIS <------------------------ (draw-solid-line (make-posn M 0) (make-posn M L)) (draw-solid-line (make-posn 0 M) (make-posn L M)) ;;-----------------------------> Drawing Commands <------------------------------- ;;line: posn posn color -> true ;;Draws a line given the start and end points and a color on a scaled cartesian plane (define (line start end color) (draw-solid-line (make-posn (+ (*(posn-x start)F)M) (- M (*(posn-y start)F))) (make-posn (+ (*(posn-x end)F) M) (- M (*(posn-y end)F))) color)) ;;circle: posn number color -> true ;;Draws a circle given the center point, radius and a color on a scaled cartesian plane (define (circle center radius color) (draw-circle (make-posn (+ M(*(posn-x center)F)) (- M (* F(posn-y center)))) (* F radius) color)) ;;disk: posn number color -> true ;;Draws a solid-disk given the center point, radius and a color on a scaled cartesian plane (define (disk center radius color) (draw-solid-disk (make-posn (+ M(* F(posn-x center))) (- M (* F(posn-y center)))) (* radius F) color)) ;;rect: posn number number color -> true ;;Draws a solid-rectangle given the top-left corner point, the length, width and color (define (rect corner L H color) (draw-solid-rect (make-posn (+ M (* F(posn-x corner))) (- M (* F(posn-y corner)))) (* L F)(* F H) color)) ;;======================== END OF TEACH PACK COORDINATE PLANE ============================| ;;--------------------> Grid Line Markers <----------------- (line (make-posn -.5 1) (make-posn .5 1) 'black) (line (make-posn -.5 2) (make-posn .5 2) 'black) (line (make-posn -.5 3) (make-posn .5 3) 'black) (line (make-posn -.5 4) (make-posn .5 4) 'black) (line (make-posn -.5 5) (make-posn .5 5) 'black) ;;--------------------> Sample Object <------------------ ;;Circle Inscribed in a Square with a Red Dot (rect (make-posn 0 4) 4 4 'blue) (disk (make-posn 2 2) .5 'red) (circle (make-posn 2 2) 2 'green) ;;-------------------> YOUR PRACTICE FOR MASTERY <------------- Following the above examples, plan on graph paper more inscribed circles. Then code your design. Planning is essential to learn the process. Please do NOT just guess and check. PLAN ON GRAPH PAPER FIRST!! ```