Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (require 2htdp/image)
- (require "iterated-images.rkt")
- ;; double: image -> image
- ;; Makes an image that looks like two copies of its input, side-by-side
- (define double
- (λ (image)
- (beside image image)))
- (check-expect (double (square 100 "outline" "black"))
- .)
- ;; triple: image -> image
- ;; Makes an image that looks like three copies of its input, side-by-side
- (define triple
- (λ (image)
- (beside image image image)))
- (check-expect (triple (square 50 "outline" "black"))
- .)
- ;; bracket: image image -> image
- ;; Makes an image with the center image surrounded on the left and right by the enclosing-image
- (define bracket
- (λ (center enclosing)
- (beside enclosing center enclosing)))
- (check-expect (bracket (square 100 "solid" "red")
- (circle 50 "solid" "blue"))
- .)
- ;; multiply: image number -> image
- ;; Makes an image that contains a specified number of copies of its input
- (define multiply
- (λ (image count)
- (iterated-beside (λ (image-number) ;; The image-making procedure
- image)
- ;; The number of times to call the image-making procedure
- count)))
- (check-expect (multiply (circle 30 "solid" "blue")
- 5)
- .)
- ;; bullseye: number -> image
- ;; Makes a pattern of concentric circles, starting with a 20 pixel circle, then a 40 pixel, etc.
- (define bullseye
- (λ (circle-count)
- (iterated-overlay (λ (circle-number)
- (circle (* 20 (+ 1 circle-number)) "outline" "black"))
- circle-count)))
- (check-expect (bullseye 5)
- .)
- ;; color-bullseye: number number -> image
- ;; Makes a pattern of concentric circles, starting with a 20 pixel circle, then a 40 pixel, etc.
- ;; The innermost circle should be black, the one surrounding it should have rate-of-brightening
- ;; units of green light, but not red or blue, the one around it should have (* 2 rate-of-brightening)
- ;; units of green, the one around it should have (* 3 rate-of-brightening) units of green, and so on.
- ;;(rgb red green blue)
- (define color-bullseye
- (λ (circle-count rate-of-brightening)
- (iterated-overlay (λ (circle-number)
- (circle (* 20 (+ 1 circle-number)) "solid" (color 0 (* rate-of-brightening circle-number) 0)))
- circle-count)))
- (check-expect (color-bullseye 5 50)
- .)
- ;; ziggurat: count color -> image
- ;; Make a stepped pyramid in the specified color with the specified number of steps.
- ;; The top step should be 10x10 pixels, and each successive step should be 20 pixels wider.
- (define ziggurat
- (λ (steps color)
- (iterated-above (λ (step-number)
- (rectangle (- (* 20 (+ 1 step-number)) 10) 10 "solid" color))
- steps)))
- (check-expect (ziggurat 10 "purple")
- .)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement