Tiny 01

Confirmation of basics: key and mouse.

Use the following variables:

(define w (square 50 "outline" "black"))
(define p (square 5 "solid" "transparent"))
(define r (rhombus 50 35 "outline" "black"))
(define (good img)
  (overlay/align "left" "middle" img (empty-scene 300 200)))
(big-bang w (to-draw good)) ;; add more to this later

Part I: Identify the Mistake

  1. The function square-mover will be used as the key handler. It is supposed to make the current image move right 4 p’s. It currently has multiple mistakes. Fix it.

     (define (square-mover img)
         (beside w p p p p))
    
  2. You want to shrink the square when you hit the “s” key. Explain what is wrong with this code in one phrase.

     (define (shrinker img "s")
          (scale 0.8 img))
    
  3. Suppose you are Using shrinker above as your key handler. Imagine that your model is a rhombus with side length 100 (stored in the variable r above), and you hit the “x” key. Is shrinker called? If so, write down the value of each parameters. If not, explain why not.

Part II: Writing

  1. (Add Another.) Write the signature and code for a mouse handler called adan that will add another full-sized square w on the left side of the current model image.

    Input Output
  2. (Sticky) Write the signature and two good check-expects for a key handler sticky that will replace whatever image you are pushing on the screen with bigstick (below). No function coding is needed.

     (define bigstick (scale 4 pic:stick-figure))
    
Last modified October 12, 2023: Rephrase. (f5c664d)