Draw Polyline/Polygon

Purpose

The Draw Polyline/Polygon function draws a connected chain of line segments and can be used to approximate a curve. When the "Fill Mode" attribute is enabled, this function draws a closed and filled polygon.

Syntax

 Opcode format Opcode [ASCII] (Hex) Operand Format Comments Single-byte, readable operand [P] (50) [][,]+ Draws either a dot, a line, a polyline, or a polygon. Absolute coordinates. Single-byte, binary operand [p] (70) [][]+ Polyline/polygon, relative coordinates [Ctrl-p] (10) [][]+ Polyline/polygon, relative coordinates

Count The number of points in the polyline/polygon. When using the binary operand form, a value of zero for count indicates that an extended count will follow. In the ASCII operand case, count may be any value larger than zero.

Ecount When count is zero, a 2-byte extended count follows allowing for polylines/polygons with vertices from 256 through 65,791 which are encoded as an integer (0 to 65,535).

Xi,Yi The ith point (in logical coordinates) of the polyline/polygon.

Details

This is the basic opcode for drawing a connected sequence of line segments. When the "Fill Mode" attribute is inactive (the default) a polyline is rendered using the current "Line Weight", "Line Cap", "Line Pattern", "Color", and "Visibility" attributes.

There are two visual differences between a Polyline and the equivalent series of simple Draw Line calls:

• The "Line Pattern", if any, flows smoothly and without interruption around the corners.
• A Line Join style can be defined to either bevel, round, or miter the corners of thick lines.

The value of count is one more than the number of line segments to be drawn. For example, a count of 3 would specify three logical points that define two connected line segments.

When the "Fill Mode" attribute is active, a closed and colored-in polygon is drawn rather than a polyline. The polygon is rendered using the current "Color" and "Visibility" attributes. The value of count is equal to the number of sides of the polygon to be drawn. For example, a count of "3" would specify three logical points that define a filled-in triangular polygon.

Notes

A polyline is generally more efficient, with respect to file size, than an equivalent series of Draw Line calls.

To draw filled polygons with interior holes use the Draw Contour Set opcode.

If a polyline or a polygon with more than 65,791 points is desired, it must be drawn by multiple Draw Polyline/Polygon opcodes (unless the readable ASCII form of the command is used).

Polygons are drawn by filling the specified region with the currently active color attribute.

Note: A visually apparent edge of the polygon is not rendered; however the Draw Polygon function can be followed by additional draw calls that render the desired edge. For example, to draw a red triangle with a black edge we could use the following:

(Color 255,0,0,255) Set the color to red.

F Turn on Fill Mode.

P 3 0,0 10,0 5,5 Draw a triangle.

(Color 0,0,0,255) Set the color to black.

f Turn off Fill Mode.

P 4 0,0 10,0 5,5 0,0 Four points specifies three line segments.

In this example, notice that four points must be used to draw the outlining edge of the triangle, where the first and last points of the polyline are equal.

The "Fill Mode" attribute is ignored when count is given a value less than three. In this case the Draw Line function would normally be used instead of Draw Polyline.

Implementation in WHIP! Versions

 Toolkit Function TBD Partial Full Revised in Draw Polyline - 0.2x, 0.5x, 1.x 1.03 - Draw Polygon - - 1.03 -

See Also