5 Bounding Box Adjusters

▼ |  | Pict: Functional Pictures

1 | Pict Datatype
2 | Basic Pict Constructors
3 | Pict Combiners
4 | Pict Drawing Adjusters
5 | Bounding Box Adjusters
6 | Pict Finders
7 | More Pict Constructors
8 | Animation Helpers
9 | Color Helpers
10 | Shadows
11 | Conditional Combinations
12 | Tree Layout
13 | Miscellaneous
14 | Rendering
15 | Conversion to Picts

On this page:

inset
clip-descent
clip-ascent
lift-above-baseline
drop-below-ascent
baseless
refocus
panorama
use-last
use-last*

top ← prev up next →

### 5`` Bounding Box Adjusters

> procedure (inset pict amt) → pict?
> pict : pict-convertible?
> amt : real?
> (inset pict h-amt v-amt) → pict?
> pict : pict-convertible?
> h-amt : real?
> v-amt : real?
> (inset pict l-amt t-amt r-amt b-amt) → pict?
> pict : pict-convertible?
> l-amt : real?
> t-amt : real?
> r-amt : real?
> b-amt : real?

Extends pict’s bounding box by adding the given amounts to the corresponding sides; ascent and descent are extended, too.

Examples:

> > (pict-width (disk 40))
> 40
> > (pict-width (inset (disk 40) -10))
> 20

> procedure (clip-descent pict) → pict?
> pict : pict-convertible?

Truncates pict’s bounding box by removing the descent part.

Examples:

> > (frame (text "gjy" null 50))
> > (frame (clip-descent (text "gjy" null 50)))

> procedure (clip-ascent pict) → pict?
> pict : pict-convertible?

Truncates pict’s bounding box by removing the ascent part.

Examples:

> > (frame (text "gjy" null 50))
> > (frame (clip-ascent (text "gjy" null 50)))

> procedure (lift-above-baseline pict amt) → pict?
> pict : pict-convertible?
> amt : real?

Lifts pict relative to its baseline, extending the bounding box height if necessary.

Examples:

> > (frame (hbl-append (text "ijijij" null 50)
> (text "abc" null 50)))
> > (frame (hbl-append (lift-above-baseline (text "ijijij" null 50) 20)
> (text "abc" null 50)))

> procedure (drop-below-ascent pict amt) → pict?
> pict : pict-convertible?
> amt : real?

Drops pict relative to its ascent line, extending the bounding box height if necessary.

Examples:

> > (define txt (text "ijgy" null 50))
> > (frame (hbl-append txt (text "abc" null 50)))
> > (frame (hbl-append (drop-below-ascent txt 20)
> (text "abc" null 50)))

> procedure (baseless pict) → pict?
> pict : pict-convertible?

Makes the descent 0 and the ascent the same as the height.

Examples:

> > (frame (hbl-append (text "gjy" null 50)
> (text "abc" null 50)))
> > (frame (hbl-append (baseless (text "gjy" null 50))
> (text "abc" null 50)))

> procedure (refocus pict sub-pict) → pict?
> pict : pict-convertible?
> sub-pict : pict-convertible?

Assuming that sub-pict can be found within pict, shifts the overall bounding box to that of sub-pict (but preserving all the drawing of pict). The last element, as reported by pict-last is also set to (or (pict-last sub-pict) sub-pict).

Examples:

> > (define p1 (filled-rectangle 50 50 #:color "darkkhaki"))
> > (define p2 (filled-rectangle 30 30 #:color "sienna"))
> > (define combined (cc-superimpose p1 p2))
> > combined
> > (refocus combined p2)

> procedure (panorama pict) → pict?
> pict : pict-convertible?

Shifts the given pict’s bounding box to enclose the bounding boxes of all sub-picts (even laundered picts).

Examples:

> > (define p1 (filled-rectangle 50 50 #:color "maroon"))
> > (define p2 (disk 30 #:color "tomato"))
> > (define combined (cc-superimpose p1 p2))
> > (refocus combined p2)
> > (panorama (refocus combined p2))

> procedure (use-last pict sub-pict) → pict?
> pict : pict-convertible?
> sub-pict : pict-path?

Returns a pict like pict, but with the last element (as reported by pict-last) set to sub-pict. The sub-pict must exist as a sub-pict (or path of sub-picts) within pict.

> procedure (use-last* pict sub-pict) → pict?
> pict : pict-convertible?
> sub-pict : pict-convertible?

Propagates the last element of sub-pict to pict.

That is, use-last* is like use-last, but the last element of sub-pict is used as the new last element for pict, instead of sub-pict itself—unless (pict-last sub-pict) is #f, in which case sub-pict is used as the last element of pict.

top ← prev up next →