Polygon Items

Items of type polygon appear as polygonal or curved filled regions on the display. Polygon items support coordinate indexing operations using the canvas widget commands: dchars, index, insert. Polygons are created with widget commands of the following form:

(#<widget> 'create 'polygon x1 y1 ... xn yn ?option value option value ...?)
(#<widget> 'create 'polygon coordList ?option value option value ...?)

The arguments x1 through yn or coordList specify the coordinates for three or more points that define a polygon. The first point should not be repeated as the last to close the shape; Tk will automatically close the periphery between the first and last points. After the coordinates there may be any number of option-value pairs, each of which sets one of the configuration options for the item. These same option-value pairs may be used in itemconfigure widget commands to change the item's configuration.

The following standard options are supported by polygons:

#:dash
#:activedash
#:disableddash
#:dashoffset
#:fill
#:activefill
#:disabledfill
#:offset
#:outline
#:activeoutline
#:disabledoutline
#:outlinestipple
#:activeoutlinestipple
#:disabledoutlinestipple
#:stipple
#:activestipple
#:disabledstipple
#:state
#:tags
#:width
#:activewidth
#:disabledwidth

The following extra options are supported for polygons:

#:joinstyle style
Specifies the ways in which joints are to be drawn at the vertices of the outline. Style may have any of the forms accepted by Tk_GetCapStyle (bevel, miter, or round). If this option isn't specified then it defaults to miter.
#:smooth boolean
Boolean must have one of the forms accepted by Tk_GetBoolean It indicates whether or not the polygon should be drawn with a curved perimeter. If so, the outline of the polygon becomes a set of parabolic splines, one spline for the first and second line segments, one for the second and third, and so on. Straight-line segments can be generated in a smoothed polygon by duplicating the end-points of the desired line segment.
#:splinesteps number
Specifies the degree of smoothness desired for curves: each spline will be approximated with number line segments. This option is ignored unless the #:smooth option is true.

Polygon items are different from other items such as rectangles, ovals and arcs in that interior points are considered to be ``inside'' a polygon (e.g. for purposes of the find closest and find overlapping widget commands) even if it is not filled. For most other item types, an interior point is considered to be inside the item only if the item is filled or if it has neither a fill nor an outline. If you would like an unfilled polygon whose interior points are not considered to be inside the polygon, use a line item instead.


© Author | Home | Sitemap