Adjusted 2htdp/image's frame primitive so that it does not draw

outside of the bounding box.
This commit is contained in:
Robby Findler 2010-09-09 06:58:23 -05:00
parent 9d35548997
commit 31685bc496
8 changed files with 17 additions and 8 deletions

View File

@ -432,12 +432,15 @@
;; (useful for debugging images)
(define/chk (frame image)
(make-image (make-overlay (image-shape image)
(image-shape
(rectangle (get-right image)
(get-bottom image)
'outline
'black)))
(make-image (make-overlay (image-shape
(crop 0 0
(get-right image)
(get-bottom image)
(rectangle (get-right image)
(get-bottom image)
'outline
(pen "black" 2 'solid 'round 'round))))
(image-shape image))
(make-bb (get-right image)
(get-bottom image)
(get-baseline image))

View File

@ -135,7 +135,7 @@
(ellipse 20 10 "solid" "navy"))
'image
"54a488e1a5.png")
(list '(frame (ellipse 20 20 "outline" "black")) 'image "6a5a617f28.png")
(list '(frame (ellipse 40 40 "solid" "gray")) 'image "1a74ac09f8a.png")
(list
'(above
(beside

View File

@ -1035,7 +1035,7 @@ the parts that fit onto @racket[scene].
with a black, single pixel frame drawn around the
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
debug image constructions, i.e., to see where
@ -1434,6 +1434,12 @@ interior.
[r (beside s s s s s s)])
(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}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

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