Advertisement
Fhernd

M2S8U1_boxify-starter.rkt

Jun 17th, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 2.52 KB | None | 0 0
  1. (require 2htdp/image)
  2.  
  3. ;; boxify-starter.rkt
  4.  
  5.  
  6. ;; Image -> Image (boxed in a rectangle)
  7. ;; Produces an image boxed in a rectangle
  8. (check-expect (boxit (circle 30 "solid" "orange")) (underlay (rectangle (image-width (circle 30 "solid" "orange")) (image-height (circle 30 "solid" "orange")) "outline" "black") (circle 30 "solid" "orange")))
  9. (check-expect (boxit (triangle 30 "solid" "blue")) (underlay (rectangle (image-width (triangle 30 "solid" "blue")) (image-height (triangle 30 "solid" "blue")) "outline" "black") (triangle 30 "solid" "blue")))
  10. (check-expect (boxit (star 40 "solid" "gray")) (underlay (rectangle (image-width (star 40 "solid" "gray")) (image-height (star 40 "solid" "gray")) "outline" "black") (star 40 "solid" "gray")))
  11. (check-expect (boxit (polygon (list (make-posn 0 0)
  12.                  (make-posn 0 40)
  13.                  (make-posn 20 40)
  14.                  (make-posn 20 60)
  15.                  (make-posn 40 60)
  16.                  (make-posn 40 20)
  17.                  (make-posn 20 20)
  18.                  (make-posn 20 0))
  19.            "solid"
  20.            "plum")) (underlay (rectangle (image-width (polygon (list (make-posn 0 0)
  21.                  (make-posn 0 40)
  22.                  (make-posn 20 40)
  23.                  (make-posn 20 60)
  24.                  (make-posn 40 60)
  25.                  (make-posn 40 20)
  26.                  (make-posn 20 20)
  27.                  (make-posn 20 0))
  28.            "solid"
  29.            "plum")) (image-height (polygon (list (make-posn 0 0)
  30.                  (make-posn 0 40)
  31.                  (make-posn 20 40)
  32.                  (make-posn 20 60)
  33.                  (make-posn 40 60)
  34.                  (make-posn 40 20)
  35.                  (make-posn 20 20)
  36.                  (make-posn 20 0))
  37.            "solid"
  38.            "plum")) "outline" "black") (polygon (list (make-posn 0 0)
  39.                  (make-posn 0 40)
  40.                  (make-posn 20 40)
  41.                  (make-posn 20 60)
  42.                  (make-posn 40 60)
  43.                  (make-posn 40 20)
  44.                  (make-posn 20 20)
  45.                  (make-posn 20 0))
  46.            "solid"
  47.            "plum")))
  48. (check-expect (boxit (ellipse 60 30 "outline" "black")) (underlay (rectangle (image-width (ellipse 60 30 "outline" "black")) (image-height (ellipse 60 30 "outline" "black")) "outline" "black") (ellipse 60 30 "outline" "black")))
  49.  
  50.  
  51. ;(define (boxit img) (rectangle 1 1 "outline" "black")) ; stub
  52.  
  53. ;(define (boxit img)
  54. ;  (... img))
  55.  
  56. (define (boxit img)
  57.   (underlay (rectangle (image-width img) (image-height img) "outline" "black") img)
  58.   )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement