Scheme Drawing Commands

Scheme Drawing Commands

<p> SCHEME DRAWING COMMANDS Commands are case-sensitive, use lower-case ;; Documentation, not a command, comments for human user start Opens a drawing canvas, 2 arguments – width and height make-posn Plots a point, a position, 2 arguments – X and Y coordinates draw-circle 3 arguments – center position, radius, color draw-solid-disk 3 arguments – center position, radius, color draw-solid-rect 4 parameters – top left corner, width, height, color draw-solid-line 4 parameters – left end point, right end point, color (color optiona l - defaults to black)</p><p>DEFINITIONS Uses open and close parenthesis define Defines a constant and a function</p><p>COLOR CONSTANTS Case-sensitive – use lower-case characters ‘white Can erase part of a shape if on top and background is white ‘black Used to outline objects ‘red R ‘blue B ‘green G RBG are basic colors in digital graphics ‘yellow More colors available in advanced graphics library</p><p>ARITHMETIC OPERATORS (operator operand..operand) (action data) + (+ 3 4) (+ ½ ¼) - (- 3 4) (- (+ 5 6) (- 8 9) ) / (/ 3 4) (+ (/ 5 6) -8) * (* 3 4) (- (* 9 8) (* 3 4) ) Can use the interaction window for parameter value planning</p><p>LOGICAL OPERATOR (Returns a Boolean value – true or false) and Used to combine shapes - drawing commands always returns true </p><p>Pre-defined FUNCTION CALLS Set library: Language / TeachPack / HTDP / draw.ss (start 640 480) ;; (start canvasWidth canvasHeight) (make-posn 320 240) ;; (make-posn x-coordinate y-coordinate) (draw-circle (make-posn 150 200) 38 ‘red) ;; (draw-circle centerPoint radius color) (draw-solid-disk (make-posn 320 150) 50) ;; (draw-solid disk centerPoint radius color) (draw-soilid-rect (make-posn 0 450) 640 30 ‘green) ;; (draw-solid-rect topLeftPostion width height color) (draw-solid-line (make-posn 150 240) (make-posn 150 350)) ;; (draw-solid-line startPoint endPoint color) ;; Note the color is optional, default to black</p><p>CONSTANT DEFINITIONS (define MID-X 320) ;;(define NAME value) (define MID-Y 240) ;;Midpoints of a 640 x 480 canvas</p><p>PROGRAM DEFINITIONS ;;contract showing input and output (define (centerCircle radius color) ;;centerCircle: number color -> Boolean (draw-circle (make-posn MID-X MID-Y) radius color)) ;;returns true and draws a circle centered on a 640x480 canvas of variable size and color</p><p>CALLS ;;call function by its name then the actual data (centerCircle 30 ‘red) ;; variable parameters are matched with input values (centerCircle 25 ‘blue) (functionName dataForRadius dataForColor)</p><p>| How to Design Programs, TeachScheme! Project, Software www.htdp.org See book for tutorial and more commands | | Graphic Programming Module Lessons www.knorth.info under Graphics link | </p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us