32.5 Progressive Picts and Slides
32.5.1 Progressive Picts
(require unstable/gui/ppict) |
A progressive pict or “ppict” is a kind of pict that has an associated “pict placer,” which generally represents a position and alignment. New picts can be placed on the progressive pict by calling ppict-add, and the placer can be updated by calling ppict-go. The ppict-do form provides a compact notation for sequences of those two operations.
syntax
(ppict-do base-expr ppict-do-fragment ...)
syntax
(ppict-do* base-expr ppic-do-fragment ...)
ppict-do-fragment = #:go placer-expr | #:set pict-expr | #:next | #:alt (ppict-do-fragment ...) | elem-expr
base-expr : pict?
placer-expr : placer?
pict-expr : pict?
elem-expr : (or/c pict? real? #f)
A #:go fragment changes the current placer. A #:set fragment replaces the current pict state altogether with a new computed pict. A #:next fragment saves a pict including only the contents emitted so far (but whose alignment takes into account picts yet to come). A #:alt fragment saves the current pict state, executes the sub-sequence that follows, saves the result (as if the sub-sequence ended with #:next), then restores the saved pict state before continuing.
The elem-exprs are interpreted by the current placer. A numeric elem-expr usually represents a spacing change, but some placers do not support them. A spacing change only affects added picts up until the next placer is installed; when a new placer is installed, the spacing is reset, usually to 0.
The ppict-do-state form tracks the current state of the pict. It is updated before a #:go or #:set fragment or before a sequence of elem-exprs. It is not updated in the middle of a chain of elem-exprs, however.
Examples: | |||||||||||
|
(let* ([pp (colorize (rectangle 200 200) "gray")] [pp (ppict-go pp (coord 1/2 1/2 'cc))] [pp (ppict-add pp (colorize (hline 200 1) "gray"))] [pp (ppict-go pp (coord 1/2 1/2 'cc))] [pp (ppict-add pp (colorize (vline 1 200) "gray"))]) pp)
Examples: | |||||||||||||||||||||||||||||||||||||||||||||||
|
More examples of ppict-do are scattered throughout this section.
syntax
procedure
pp : ppict? elem : (or/c pict? real? #f 'next)
procedure
(ppict-add* pp elem ...) →
pict? (listof pict?) pp : ppict? elem : (or/c pict? real? #f 'next)
An elem that is a real number changes the spacing for subsequent additions. A elem that is #f is discarded; it is permitted as a convenience for conditionally including sub-picts. Note that #f is not equivalent to (blank 0), since the latter will cause spacing to be added around it.
procedure
(refpoint-placer? x) → boolean?
x : any/c
procedure
(coord rel-x rel-y [ align #:abs-x abs-x #:abs-y abs-y #:compose composer]) → refpoint-placer? rel-x : real? rel-y : real? align : (or/c 'lt 'ct 'rt 'lc 'cc 'rc 'lb 'cb 'rb) = 'cc abs-x : real? = 0 abs-y : real? = 0 composer : procedure? = computed from align
Additions are aligned according to align, a symbol whose name consists of a horizontal alignment character followed by a vertical alignment character. For example, if align is 'lt, the pict is placed so that its left-top corner is at the reference point; if align is 'rc, the pict is placed so that the center of its bounding box’s right edge coincides with the reference point.
By default, if there are multiple picts to be placed, they are vertically appended, aligned according to the horizontal component of align. For example, if align is 'cc, the default composer is vc-append; for 'lt, the default composer is vl-append. The spacing is initially 0.
Examples: | |||||||||||||||||||||||
|
procedure
(grid cols rows col row [ align #:abs-x abs-x #:abs-y abs-y #:compose composer]) → refpoint-placer? cols : exact-positive-integer? rows : exact-positive-integer? col : exact-integer? row : exact-integer? align : (or/c 'lt 'ct 'rt 'lc 'cc 'rc 'lb 'cb 'rb) = 'cc abs-x : real? = 0 abs-y : real? = 0 composer : procedure? = computed from align
Uses of grid can be translated into uses of coord, but the translation depends on the alignment. For example, (grid 2 2 1 1 'lt) is equivalent to (coord 0 0 'lt), but (grid 2 2 1 1 'rt) is equivalent to (coord 1/2 0 'rt).
Examples: | ||||||||||||||||
|
When a list picts is to be placed, their bounding boxes are normalized to the maximum width and height of all picts in the list; each pict is centered in its new bounding box. The picts are then cascaded so there is step-x space between each of the picts’ left edges; there is also step-x space between the base pict’s left edge and the first pict’s left edge. Similarly for step-y and the vertical spacing.
If step-x or step-y is 'auto, the spacing between the centers of the picts to be placed is determined automatically so that the inter-pict spacing is the same as the spacing between the last pict and the base.
Examples: | ||||||||||||
|
procedure
cols : exact-positive-integer? rows : exact-positive-integer?
Example: | ||||||||
|
procedure
(at-find-pict find-path [ finder align #:abs-x abs-x #:abs-y abs-y #:compose composer]) → refpoint-placer? find-path : (or/c tag-path? pict-path?) finder : procedure? = cc-find align : (or/c 'lt 'ct 'rt 'lc 'cc 'rc 'lb 'cb 'rb) = 'cc abs-x : real? = 0 abs-y : real? = 0 composer : procedure? = computed from align
Example: | ||||||||
|
procedure
(merge-refpoints x-placer y-placer) → refpoint-placer?
x-placer : refpoint-placer? y-placer : refpoint-placer?
Example: | |||||||||
|
32.5.2 Progressive Slides
(require unstable/gui/pslide) |
syntax
(pslide ppict-do-fragment ...)
Note that like slide but unlike ppict-do*, the number of slides produced is one greater than the number of #:next uses; that is, a slide is created for the final pict.
Remember to include gap-size after updating the current placer if you want slide-like spacing.
Example: | |||||||||
|
Note that the text is not flush against the sides of the slide, because pslide uses a base pict the size of the client area, excluding the margins.
parameter
(pslide-base-pict) → (-> pict)
(pslide-base-pict make-base-pict) → void? make-base-pict : (-> pict)
parameter
(pslide-default-placer placer) → void? placer : placer?
(coord 1/2 1/2 'cc)