Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (require 2htdp/image)
- ;; boxify-starter.rkt
- ;; Image -> Image (boxed in a rectangle)
- ;; Produces an image boxed in a rectangle
- (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")))
- (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")))
- (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")))
- (check-expect (boxit (polygon (list (make-posn 0 0)
- (make-posn 0 40)
- (make-posn 20 40)
- (make-posn 20 60)
- (make-posn 40 60)
- (make-posn 40 20)
- (make-posn 20 20)
- (make-posn 20 0))
- "solid"
- "plum")) (underlay (rectangle (image-width (polygon (list (make-posn 0 0)
- (make-posn 0 40)
- (make-posn 20 40)
- (make-posn 20 60)
- (make-posn 40 60)
- (make-posn 40 20)
- (make-posn 20 20)
- (make-posn 20 0))
- "solid"
- "plum")) (image-height (polygon (list (make-posn 0 0)
- (make-posn 0 40)
- (make-posn 20 40)
- (make-posn 20 60)
- (make-posn 40 60)
- (make-posn 40 20)
- (make-posn 20 20)
- (make-posn 20 0))
- "solid"
- "plum")) "outline" "black") (polygon (list (make-posn 0 0)
- (make-posn 0 40)
- (make-posn 20 40)
- (make-posn 20 60)
- (make-posn 40 60)
- (make-posn 40 20)
- (make-posn 20 20)
- (make-posn 20 0))
- "solid"
- "plum")))
- (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")))
- ;(define (boxit img) (rectangle 1 1 "outline" "black")) ; stub
- ;(define (boxit img)
- ; (... img))
- (define (boxit img)
- (underlay (rectangle (image-width img) (image-height img) "outline" "black") img)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement