I have encountered multiple shapes while reading IDML spreads. Each Shape has it's own geometry that looks like -
-<PathGeometry>
-<GeometryPathType PathOpen="false">
-<PathPointArray>
<PathPointType RightDirection="-611.5 1548.5" LeftDirection="-611.5 1548.5" Anchor="-611.5 1548.5"/>
<PathPointType RightDirection="-611.5 2339.5" LeftDirection="-611.5 2339.5" Anchor="-611.5 2339.5"/>
<PathPointType RightDirection="-533.3 2339.5" LeftDirection="-533.3 2339.5" Anchor="-533.3 2339.5"/>
<PathPointType RightDirection="-533.3 1548.5" LeftDirection="-533.3 1548.5" Anchor="-533.3 1548.5"/>
</PathPointArray>
</GeometryPathType>
</PathGeometry>
For rectangles it is trivial (as in the example above), where each attribute in a <PathPoint>
element points to an end point in the rectangle. What happens with other shapes? In other words, what do RightDirection, LeftDirection and Anchor attributes signify? Is there a way to determine what shape it is looking at the PathPointArray?
Thanks.
Each IDML PathPointType
is a node on a cubic bezier curve. The combination of control and anchor points defines the end points and curvature of the line. All lines in IDML are defined as if they were curves but, as you have noticed, the control and anchor points for a straight line are identical. Straight line polygons (such as a triangle) are defined the same way.
IDML has only a small collection of shape types (rectangles, ellipses, graphic lines, polygons - see 10.3.1. in the specification). You can draw any shape from IDML simply by drawing it one line at a time, but it's more efficient to create separate routines for rectangles and ellipses.
Note also PathOpen="false"
on the GeometryPathType
element. For efficiency, the last line in a shape isn't defined - you will create a line from the final point back to the first if PathOpen
== false.