Name
PathItems -- traverse individual path items (V7.0)
Synopsis
f = PathItems(id)
Function
This function can be used together with the generic For statement to traverse all items in a path. It returns an iterator function which will return a table that contains information about the next item in the path. Once all path items have been returned, the iterator function will return Nil to break the generic For statement.

See Generic For statement for details.

The table returned by PathItems() will contain a Type field which contains a string that describes the item type. All further table fields depend on the item type as returned in Type. The following types are currently supported:

NewSubPath:
This item starts a new sub-path. The current point will be undefined at this time. There are no additional arguments.

ClosePath:
Closes the current path by drawing a line from the current point to the first point in the sub-path. There are no additional arguments.

MoveTo:
This command begins a new sub-path. The sub-path's current point will be set to the specified position. The MoveTo table contains the following three additional arguments:

Rel:
This is a boolean value that indicates whether the coordinates are relative or absolute values. If this is True, the coordinates have to be interpreted as relative to the current point.

X:
The x coordinate of the new position.

Y:
The y coordinate of the new position.

LineTo:
This draws a line from the current point to the specified position. Additionally, it will change the current point to the line's end point when it is done. The LineTo table contains the following three additional arguments:

Rel:
This is a boolean value that indicates whether the coordinates are relative or absolute values. If this is True, the coordinates have to be interpreted as relative to the current point.

X:
The x coordinate of the new position.

Y:
The y coordinate of the new position.

If there is no current point, LineTo will behave as if it was MoveTo, i.e. it will simply set the current point to the specified vertex.

CurveTo:
This command draws a Bézier curve that runs from the current point to the position passed in the final two coordinates. The other four coordinates are the control points for the curve. Additionally, it will change the current point to the curve's end point when it is done. The CurveTo table contains the following seven additional arguments:

Rel:
This is a boolean value that indicates whether the coordinates are relative or absolute values. If this is True, the coordinates have to be interpreted as relative to the current point.

X1:
The x coordinate of the first control point.

Y1:
The y coordinate of the first control point.

X2:
The x coordinate of the second control point.

Y2:
The y coordinate of the second control point.

X3:
The x coordinate of the end point.

Y3:
The y coordinate of the end point.

If there is no current point, CurveTo will use the point passed in (x1,y1) as the current point.

Arc:
This command will draw an elliptical arc. Arc will open a new subpath for the new arc only in case there is no currently active subpath. If there is already a subpath, Arc will connect its starting vertex with the current vertex of the subpath. Arc will not close the subpath when it has finished adding its vertices. Arc will not connect the start and end angles of the arc with its center point automatically. This has to be requested explicitly by issuing separate MoveTo and LineTo commands before and after Arc. The Arc table contains the following additional arguments:

XC:
The x center point of the arc.
YC:
The y center point of the arc.
RA:
Arc's radius on the x axis.
RB:
Arc's radius on the y axis.
Start:
Start angle in degrees.
End:
End angle in degrees.
Clockwise:
Whether or not the angles should be connected in clockwise direction.

When Arc is done, it will set the current point to the position of the end angle.

Box:
This command will draw a rectangle. Box will first open a new subpath, then add the rectangle's vertices to it and close the subpath when it is finished. Optionally, the rectangle can have rounded corners. The Box table contains the following additional arguments:

X:
X position of the rectangle.
Y:
Y position of the rectangle.
Width:
Rectangle width.
Height:
Rectangle height.
Round:
This is a table which contains four integer values in the range from 0 to 100 specifying the degree of rounding for the four corners of the rectangle. A value of 0 means no rounding, 100 means full rounding.

Text:
This command will draw vector text relative to the current point. The individual characters are added as closed subpaths. The Text table contains the following additional arguments:

Size:
Desired font size.

Text:
The string to draw.

When Text is done, it will set the current point to where the next character would be displayed.

Inputs
id
identifier of path to traverse
Results
f
iterator function for generic for loop
Example
For t In PathItems(1) Do DebugPrint(t.type)
The code above iterates over all items in path 1 and prints the type of each item to the debug device.

Show TOC