PtPolygon

PtPolygon — A set of points connected by lines.

Synopsis

class PtPolygon PtGraphic
{
    polygon_flags;    // flag  (Pt_ARG_POLYGON_FLAGS)    
}
		

Base Classes

PtWidget <-- PtBasic <-- PtGraphic <-- PtPolygon

Description

This widget is a polygon defined by a set of points that act as vertices, located with respect to an origin point. The origin is a PhPoint, assigned to the origin variable (inherited from PtGraphic). The set of points is defined by an array of PhPoints assigned to the points variable (also inherited from PtGraphic).

The polygon can be open or closed, empty or filled, and drawn using absolute or relative coordinates. Its lines can be stroked or unstroked.

[Note]

For detailed information, please refer to PtPolygon in the Photon documentation.

Instance Variables

polygon_flags

This instance variable determines the characteristics of the polygon, and may be a combination of zero or more of the following flags:

ConstantDescription
Pg_CLOSEDThe end point is connected to the start point.
Pg_POLY_STROKEThe polygon is outlined.
Pg_POLY_RELATIVEUse relative coordinates for drawing.
Pg_POLY_FILLThe polygon is filled.

Example

This example, ex_PtPolygon.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
 * This example puts a PtPolygon into a window,
 * and prints its array of vertex points.
 */

require_lisp("PhotonWidgets.lsp");
PtInit(nil);

win = new(PtWindow);
win.SetDim (150,150);
win.fill_color = 0xffffbb;

p1 = new(PhPoint);
p1.x = 5;
p1.y = 5;

p2 = new(PhPoint);
p2.x = 60;
p2.y = -30;

p3 = new(PhPoint);
p3.x = 80;
p3.y = 40;

o = new(PhPoint);
o.x = 20;
o.y = 65;

poly = new(PtPolygon);
poly.points = array(p1,p2,p3);
poly.origin = o;
poly.polygon_flags = Pg_POLY_FILL;
poly.fill_color = 0x00ddbb;

pretty_princ("PtPolygon points:\n",poly.points,"\n");

PtRealizeWidget(win);
PtMainLoop();