Next / Previous / Contents / TCC Help System / NM Tech homepage

6.8. The canvas polygon object

As displayed, a polygon has two parts: its outline and its interior. Its geometry is specified as a series of vertices [(x0, y0), (x1, y1), … (xn, yn)], but the actual perimeter includes one more segment from (xn, yn) back to (x0, y0). In this example, there are five vertices:

To create a new polygon object on a canvas C:

    id = C.create_polygon ( x0, y0, x1, y1, ..., option, ... )

The constructor returns the object ID for that object. Options:

fillYou can color the interior by setting this option to a color. The default appearance for the interior of a polygon is transparent, and you can set fill="" to get this behavior. See Section 4.3, “Colors”.
outlineColor of the outline; defaults to outline="black". Use outline="" to make the outline transparent.
smoothThe default outline uses straight lines to connect the vertices; use smooth=0 to get that behavior. If you use smooth=1, you get a continuous spline curve. Moreover, if you set smooth=1, you can make any segment straight by duplicating the coordinates at each end of that segment.
splinestepsIf the smooth option is true, each spline is rendered as a number of straight line segments. The splinesteps option specifies the number of segments used to approximate each section of the line; the default is splinesteps=12.
stippleA bitmap indicating how the interior of the polygon will be stippled. Default is stipple="", which means a solid color. A typical value would be stipple="gray25". Has no effect unless the fill has been set to some color. See Section 4.7, “Bitmaps”.
tagsThe tags to be associated with the object, as a sequence of strings. See Section 6.1.4, “Canvas tags”.
widthWidth of the outline; defaults to 1. See Section 4.1, “Dimensions”.