AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
fillPolygon (Object obj, Array xpoints, Array ypoints [, int count]) yoix.graphics
fillPolygon (Object obj, Number x0, Number y0, Number x1, Number y1, ...)  
 
Fills a polygon 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 connects points whose x and y coordinates are supplied as numbers in the xpoints and ypoints arrays. The number of points in the polygon 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 fillPolygon chooses a value that is the minimum of the size of the xpoints and ypoints arrays. The Yoix implementation of fillPolygon also accepts x and y coordinates of the points in the polygon as arguments.

The polygon is closed by a line segment that connects the first and last points. Interior points are identified using a rule known as the even-odd rule and painted using 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.yellow;
            };

            paint(clip) {
                fillPolygon(this,
                    unroll(Star(size.width - 72, size.height - 72*2)));
            }
        },
    };
};

frame.visible = TRUE;
sleep(5);
exit(0);
defines a paint function in a canvas that fills a yellow five pointed star that is centered 1 inch from the right and 2 inches from the bottom of the canvas. The x and y coordinates of the star are returned in an array by the function named Star. The polygon is filled by unrolling those coordinates using the unroll built-in and handing them to fillPolygon.
 
 See Also:   clearRect, copyArea, drawArc, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, fillArc, fillOval, fillRect, fillRoundRect, pointInPolygon, pointInRect, rectContainsRect, rectIntersectionRect, rectIntersectsRect, rectUnionRect, stringBounds, stringWidth

 

Yoix is a registered trademark of AT&T Inc.