| drawPolyline |
(Object obj, Array xpoints, Array ypoints [, int count]) |
yoix.graphics |
| drawPolyline |
(Object obj, Number x0, Number y0, Number x1, Number y1, ...) |
|
| |
|
Draws a series of lines in
obj,
which must be an
Image
or a drawable component (i.e., a Swing or AWT component, like a
JCanvas,
JFrame,
or
Canvas,
that supports a
paint
function),
that connect points whose x and y coordinates are supplied as numbers in the
xpoints
and
ypoints
arrays.
The number of points can be specified by the optional
count
argument, which must be less than or equal to the number of elements in both
xpoints
and
ypoints.
When
count
is omitted
drawPolyline
chooses a value that is the minimum of the size of the
xpoints
and
ypoints
arrays.
The Yoix implementation of
drawPolyline
also accepts x and y coordinates of the points as arguments.
The connected lines are drawn in the
foreground
color selected by the
Graphics
object associated with
obj.
| |
| Example: |
The program,
import yoix.*.*;
Star(double xcenter, double ycenter) {
return(
new Array {
xcenter + 0, ycenter + -50,
xcenter + 29, ycenter + 40,
xcenter + -47, ycenter + -15,
xcenter + 47, ycenter + -15,
xcenter + -29, ycenter + 40,
}
);
}
JFrame frame = {
Array layout = {
new JCanvas {
Color background = Color.black;
Graphics graphics = {
Color foreground = Color.red;
};
paint(clip) {
drawPolyline(this, unroll(Star(72, 72*2)));
}
},
};
};
frame.visible = TRUE;
sleep(5);
exit(0);
defines a paint function in a canvas that draws most of a five pointed star
in red that is centered 1 inch from the left and 2 inches from the top of the
canvas.
The missing line segment is the one that connects the first and last points
and it was omitted so the difference between
drawPolygon
and
drawPolyline
would be obvious.
The x and y coordinates of the star are returned in an array
by the function named
Star.
The polyline is drawn by unrolling those coordinates using the
unroll
built-in and handing them to
drawPolyline.
| | |
| See Also: |
clearRect,
copyArea,
drawArc,
drawImage,
drawLine,
drawOval,
drawPolygon,
drawRect,
drawRoundRect,
drawString,
fillArc,
fillOval,
fillPolygon,
fillRect,
fillRoundRect,
pointInPolygon,
pointInRect,
rectContainsRect,
rectIntersectionRect,
rectIntersectsRect,
rectUnionRect,
stringBounds,
stringWidth
|
|
Yoix is a registered trademark of AT&T Inc.
|
|