Adjusted 2htdp/image's frame primitive so that it does not draw
outside of the bounding box.
This commit is contained in:
parent
9d35548997
commit
31685bc496
|
@ -432,12 +432,15 @@
|
||||||
;; (useful for debugging images)
|
;; (useful for debugging images)
|
||||||
|
|
||||||
(define/chk (frame image)
|
(define/chk (frame image)
|
||||||
(make-image (make-overlay (image-shape image)
|
(make-image (make-overlay (image-shape
|
||||||
(image-shape
|
(crop 0 0
|
||||||
(rectangle (get-right image)
|
(get-right image)
|
||||||
(get-bottom image)
|
(get-bottom image)
|
||||||
'outline
|
(rectangle (get-right image)
|
||||||
'black)))
|
(get-bottom image)
|
||||||
|
'outline
|
||||||
|
(pen "black" 2 'solid 'round 'round))))
|
||||||
|
(image-shape image))
|
||||||
(make-bb (get-right image)
|
(make-bb (get-right image)
|
||||||
(get-bottom image)
|
(get-bottom image)
|
||||||
(get-baseline image))
|
(get-baseline image))
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
(ellipse 20 10 "solid" "navy"))
|
(ellipse 20 10 "solid" "navy"))
|
||||||
'image
|
'image
|
||||||
"54a488e1a5.png")
|
"54a488e1a5.png")
|
||||||
(list '(frame (ellipse 20 20 "outline" "black")) 'image "6a5a617f28.png")
|
(list '(frame (ellipse 40 40 "solid" "gray")) 'image "1a74ac09f8a.png")
|
||||||
(list
|
(list
|
||||||
'(above
|
'(above
|
||||||
(beside
|
(beside
|
||||||
|
|
|
@ -1035,7 +1035,7 @@ the parts that fit onto @racket[scene].
|
||||||
with a black, single pixel frame drawn around the
|
with a black, single pixel frame drawn around the
|
||||||
bounding box of the image.
|
bounding box of the image.
|
||||||
|
|
||||||
@image-examples[(frame (ellipse 20 20 "outline" "black"))]
|
@image-examples[(frame (ellipse 40 40 "solid" "gray"))]
|
||||||
|
|
||||||
Generally speaking, this function is useful to
|
Generally speaking, this function is useful to
|
||||||
debug image constructions, i.e., to see where
|
debug image constructions, i.e., to see where
|
||||||
|
@ -1434,6 +1434,12 @@ interior.
|
||||||
[r (beside s s s s s s)])
|
[r (beside s s s s s s)])
|
||||||
(above r r r r r r))]
|
(above r r r r r r))]
|
||||||
|
|
||||||
|
While this kind of rectangle is not useful for building grids, it
|
||||||
|
is important to be able to build rectangles whose drawing does not
|
||||||
|
exceed its bounding box. Specifically, this kind of drawing is used
|
||||||
|
by @racket[frame] and @racket[empty-scene] so that the extra drawn pixels
|
||||||
|
are not lost if the image is later clipped to its bounding box.
|
||||||
|
|
||||||
@;-----------------------------------------------------------------------------
|
@;-----------------------------------------------------------------------------
|
||||||
@section{Exporting Images to Disk}
|
@section{Exporting Images to Disk}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB |
BIN
collects/teachpack/2htdp/scribblings/img/1a74ac09f8a.png
Normal file
BIN
collects/teachpack/2htdp/scribblings/img/1a74ac09f8a.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 494 B |
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 446 B |
Loading…
Reference in New Issue
Block a user