6.0
3 Pict Utilities
The functions and macros exported by this module are also exported by
unstable/gui/slideshow.
3.1 Pict Colors
Applies color
c to picture
p. Equivalent to
(colorize p c).
These functions apply appropriate colors to picture p.
These functions produce ligher or darker versions of a color.
This contract recognizes color strings,
color% instances, and RGB color
lists.
3.2 Pict Manipulation
Extends pict’s bounding box to a minimum width and/or
height, placing the original picture in the middle of the space.
Scales pict so that its width and height are at most
width and height, respectively. If mode is
'preserve, the width and height are scaled by the same factor
so pict’s aspect ratio is preserved; the result’s bounding
box may be smaller than width by height. If
mode is 'inset, the aspect ratio is preserved as
with 'preserve, but the resulting pict is centered in a
bounding box of exactly width by height. If
mode is 'distort, the width and height are scaled
separately.
3.2.1 Conditional Manipulations
These pict transformers all take boolean arguments that determine whether to
transform the pict or leave it unchanged. These transformations can be useful
for staged slides, as the resulting pict always has the same size and shape, and
its contents always appear at the same position, but changing the boolean
argument between slides can control when the transformation occurs.
These functions conditionally show or hide an image, essentially choosing
between
pict and
(ghost pict). The only difference between
the two is the default behavior and the opposite meaning of the
show?
and
hide? booleans. Both functions are provided for mnemonic purposes.
Displays a strikethrough image by putting a line through the middle of
pict if strike? is true; produces pict unchanged
otherwise.
Shades pict to show with ratio of its normal opacity; if
ratio is 1 or shade? is #f, shows
pict unchanged.
3.2.2 Conditional Combinations
These pict control flow operators decide which pict of several to use. All
branches are evaluated; the resulting pict is a combination of the pict chosen
by normal conditional flow with ghost applied to all the other picts.
The result is a picture large enough to accommodate each alternative, but showing
only the chosen one. This is useful for staged slides, as the pict chosen may
change with each slide but its size and position will not.
(pict-if maybe-combine test-expr then-expr else-expr)
|
|
maybe-combine | | = | | | | | | | | #:combine combine-expr |
|
Chooses either
then-expr or
else-expr based on
test-expr, similarly to
if. Combines the chosen, visible
image with the other, invisible image using
combine-expr, defaulting to
pict-combine.
(pict-cond maybe-combine [test-expr pict-expr] ...)
|
|
maybe-combine | | = | | | | | | | | #:combine combine-expr |
|
Chooses a
pict-expr based on the first successful
test-expr,
similarly to
cond. Combines the chosen, visible image with the other,
invisible images using
combine-expr, defaulting to
pict-combine.
(pict-case test-expr maybe-combine [literals pict-expr] ...)
|
|
maybe-combine | | = | | | | | | | | #:combine combine-expr |
|
Chooses a
pict-expr based on
test-expr and each list of
literals, similarly to
case. Combines the chosen, visible
image with the other, invisible images using
combine-expr, defaulting
to
pict-combine.
(pict-match test-expr maybe-combine [pattern pict-expr] ...)
|
|
maybe-combine | | = | | | | | | | | #:combine combine-expr |
|
Chooses a
pict-expr based on
test-expr and each
pattern, similarly to
match. Combines the chosen, visible
image with the other, invisible images using
combine-expr, defaulting
to
pict-combine.
This syntax parameter determines the default pict combining form used by the
above macros. It defaults to
lbl-superimpose.
Sets
pict-combine to refer to
combine-id within each of the
body terms, which are spliced into the containing context.
3.3 Shapes with Borders
The subsequent bindings were added by Vincent St-Amour.
These functions create shapes with border of the given color and width.
3.4 Lines with Labels
The subsequent bindings were added by Scott Owens.
3.5 Blur
The subsequent bindings were added by Ryan Culpepper.
Blurs p using an iterated box blur that approximates a
gaussian blur. The h-radius and v-radius arguments
control the strength of the horizontal and vertical components of the
blur, respectively. They are given in terms of pict units, which may
not directly correspond to screen pixels.
The
blur function takes work proportional to
The resulting pict has the same bounding box as
p, so when
picts are automatically
clipped (as in Scribble documents),
the pict should be
inset by the blur radius.
Creates a shadow effect by superimposing p over a
blurred version of p. The shadow is offset from p by
(dx, dy) units.
If color is not #f, the foreground part is
(colorize p color); otherwise it is just p. If
shadow-color is not #f, the shadow part is produced
by blurring (colorize p shadow-color); otherwise it is
produced by blurring p.
The resulting pict has the same bounding box as p.
Blurs bitmap using blur radii h-radius and
v-radius.
3.5.1 Tagged Picts
Returns a pict like
p that carries a symbolic tag. The tag
can be used with
find-tag to locate the pict.
Locates a sub-pict of
p. Returns a pict-path that can be used
with functions like
lt-find, etc.
Like
find-tag, but returns all pict-paths corresponding to
the given tag-path.
Returns #t if x is a symbol or a non-empty list of
symbols, #f otherwise.
3.6 Shadow Frames
(shadow-frame | | pict | | | | ... | | | [ | #:sep separation | | | | #:margin margin | | | | #:background-color bg-color | | | | #:frame-color frame-color | | | | #:frame-line-width frame-line-width | | | | #:shadow-side-length shadow-side-length | | | | #:shadow-top-y-offset shadow-top-y-offset | | | | #:shadow-bottom-y-offset shadow-bottom-y-offset | | | | #:shadow-descent shadow-descent | | | | #:shadow-alpha-factor shadow-alpha-factor | | | | #:blur blur-radius]) | |
|
→ pict? |
pict : pict? |
separation : real? = 5 |
margin : real? = 20 |
bg-color : (or/c string? (is-a?/c color%)) = "white" |
frame-color : (or/c string? (is-a?/c color%)) = "gray" |
frame-line-width : (or/c real? #f) = 0 |
shadow-side-length : real? = 4 |
shadow-top-y-offset : real? = 10 |
shadow-bottom-y-offset : real? = 4 |
shadow-descent : (and/c real? (not/c negative?)) = 40 |
shadow-alpha-factor : real? = 3/4 |
blur-radius : (and/c real? (not/c negative?)) = 20 |
Surrounds the picts with a rectangular frame that casts a
symmetric “curled paper” shadow.
The picts are vertically appended with separation
space between them. They are placed on a rectangular background of
solid bg-color with margin space on all sides. A
frame of frame-color and frame-line-width is added
around the rectangle. The rectangle casts a shadow that extends
shadow-side-length to the left and right, starts
shadow-top-y-offset below the top of the rectangle and
extends to shadow-bottom-y-offset below the bottom of the
rectangle in the center and an additional shadow-descent
below that on the sides. The shadow is painted using a linear
gradient; shadow-alpha-factor determines its density at the
center. Finally, the shadow is blurred by blur-radius; all
previous measurements are pre-blur measurements.
Creates an arch.
3.7 Additional combinators
The subsequent bindings were added by Asumu Takikawa.
Adds a background highlighted with color to
pict.
|
pict : pict? |
width : real? = 1 |
| style | | : | | (or/c 'transparent 'solid 'xor | 'hilite 'dot 'long-dash 'short-dash | 'dot-dash 'xor-dot 'xor-long-dash | 'xor-short-dash 'xor-dot-dash) |
| | = | | 'solid |
|
color : color/c = "black" |
Crosses out pict with two diagonal lines drawn with
the given line width and with the line style.
The lines are colored with color.