added documentation for the flipping functions
|
@ -38,7 +38,7 @@
|
|||
(with-handlers ([exn:fail?
|
||||
(λ (x)
|
||||
(printf "\nerror evaluating:\n")
|
||||
(pretty-print exp)
|
||||
(pretty-write exp)
|
||||
(raise x))])
|
||||
(parameterize ([current-namespace image-ns]) (eval exp)))])
|
||||
(cond
|
||||
|
@ -107,7 +107,7 @@
|
|||
(λ (port)
|
||||
(fprintf port "#lang racket/base\n(provide mapping)\n")
|
||||
(fprintf port ";; this file is generated by image-gen.ss -- do not edit\n;; note that the file that creates this file depends on this file\n;; it is always safe to simply define (and provide) mapping as the empty list\n\n")
|
||||
(pretty-print
|
||||
(pretty-write
|
||||
`(define mapping (list ,@mapping))
|
||||
port))
|
||||
#:exists 'truncate)])
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#lang scheme/base
|
||||
#lang racket/base
|
||||
(provide mapping)
|
||||
;; this file is generated by image-gen.ss -- do not edit
|
||||
;; note that the file that creates this file depends on this file
|
||||
|
@ -53,6 +53,18 @@
|
|||
'(crop 0 0 40 40 (circle 40 "solid" "chocolate"))
|
||||
'image
|
||||
"8e7c1870c7.png")
|
||||
(list
|
||||
'(above
|
||||
(star 40 "solid" "firebrick")
|
||||
(scale/xy 1 1/2 (flip-vertical (star 40 "solid" "gray"))))
|
||||
'image
|
||||
"25bd9b1ac5a.png")
|
||||
(list
|
||||
'(beside
|
||||
(rotate 30 (square 50 "solid" "red"))
|
||||
(flip-horizontal (rotate 30 (square 50 "solid" "blue"))))
|
||||
'image
|
||||
"e58911226.png")
|
||||
(list '(ellipse 60 60 "solid" "blue") 'image "d92d6a49f1.png")
|
||||
(list
|
||||
'(scale/xy 3 2 (ellipse 20 30 "solid" "blue"))
|
||||
|
|
|
@ -764,7 +764,7 @@ the parts that fit onto @racket[scene].
|
|||
}
|
||||
|
||||
|
||||
@section{Rotating, Scaling, Cropping, and Framing Images}
|
||||
@section{Rotating, Scaling, Flipping, Cropping, and Framing Images}
|
||||
|
||||
@defproc[(rotate [angle angle?] [image image?]) image?]{
|
||||
Rotates @racket[image] by @racket[angle] degrees in a counter-clockwise direction.
|
||||
|
@ -809,6 +809,23 @@ the parts that fit onto @racket[scene].
|
|||
(ellipse 60 60 "solid" "blue")]
|
||||
}
|
||||
|
||||
@defproc[(flip-horizontal [image image?]) image?]{
|
||||
Flips @scheme[image] left to right.
|
||||
|
||||
@image-examples[(beside
|
||||
(rotate 30 (square 50 "solid" "red"))
|
||||
(flip-horizontal
|
||||
(rotate 30 (square 50 "solid" "blue"))))]
|
||||
}
|
||||
|
||||
@defproc[(flip-vertical [image image?]) image?]{
|
||||
Flips @scheme[image] top to bottom.
|
||||
|
||||
@image-examples[(above
|
||||
(star 40 "solid" "firebrick")
|
||||
(scale/xy 1 1/2 (flip-vertical (star 40 "solid" "gray"))))]
|
||||
}
|
||||
|
||||
@defproc[(crop [x real?] [y real?]
|
||||
[width (and/c real? (not/c negative?))]
|
||||
[height (and/c real? (not/c negative?))]
|
||||
|
|
Before Width: | Height: | Size: 1007 B After Width: | Height: | Size: 1005 B |
BIN
collects/teachpack/2htdp/scribblings/img/25bd9b1ac5a.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
collects/teachpack/2htdp/scribblings/img/2a03b18c0c.png
Normal file
After Width: | Height: | Size: 355 B |
BIN
collects/teachpack/2htdp/scribblings/img/8aebbc110e.png
Normal file
After Width: | Height: | Size: 359 B |
BIN
collects/teachpack/2htdp/scribblings/img/e58911226.png
Normal file
After Width: | Height: | Size: 2.0 KiB |