| pathbbox |
([Number flatness]) |
typedict.Path |
| |
|
Returns a
Rectangle
that represents the bounding box of this path in the user space
described by the
CTM
associated with this path when
pathbbox
is called.
The answer can sometimes be larger than expected, because
pathbbox
calculates the bounding box of the path in device space,
transforms the four corners of that rectangle into user space points
using the inverse of
CTM,
and then determines the smallest user space rectangle that covers the
corners.
The optional
flatness
argument, which should be a number between
0.2
and
100,
tells
pathbbox
to base its calculations on a copy of the path that has been flattened using
flatness
as the parameter that controls the accuracy of the flattening process.
| |
| Example: |
The program,
import yoix.*.*;
JFrame f = {
paint(Rectangle rect) {
Rectangle bbox;
graphics {
gsave();
sethsbcolor(0.666667, 0.5, 1.0);
linewidth = 18;
linejoin = JOIN_MITER;
linecap = CAP_ROUND;
translate(144, 144);
rotate(15); // change the angle
moveto(0, 0);
rlineto(72, -50);
rlineto(-20, 72);
strokepath(); // makes outline
bbox = pathbbox();
fill();
foreground = Color.red;
linewidth = 0;
rectstroke(bbox);
grestore();
}
}
};
f.visible = TRUE;
defines a paint function in a frame that builds a short path,
turns that path into an outline, uses
pathbbox
to determine the bounding box of that outline,
and draws the outline in light blue and the bounding box in red.
This is a short example, but there is lots you can learn,
so we encourage you to experiment with it.
| | |
| Return: |
Rectangle
| | |
| See Also: |
arc,
arcn,
closepath,
currentpath,
currentpoint,
curveto,
flattenpath,
Graphics,
lineto,
moveto,
newpath,
pathforall,
quadto,
rcurveto,
rlineto,
rmoveto,
rquadto
|
|
Yoix is a registered trademark of AT&T Inc.
|