UXPathElement
UXPathElement is one step of a
UXShapePath: what to do, and where.
#use <UXKit> // or #import "UXShapePath.xc"Overview
Section titled “Overview”class UXPathElement : Object { i32 type; // UXPE_MOVE / UXPE_LINE / UXPE_CLOSE / UXPE_CURVE i16 x; i16 y; // the on-curve point i16 c1x; i16 c1y; // UXPE_CURVE only i16 c2x; i16 c2y;}A path is an array of these, in order. You build them with
moveTo and related methods instead
of constructing them yourself. The class is public because reading a path back
(to serialise it, edit it, or draw handles for it) means walking the elements.
The four types
Section titled “The four types”| constant | meaning | fields used |
|---|---|---|
UXPE_MOVE | start a new subpath at x,y | x, y |
UXPE_LINE | straight line to x,y | x, y |
UXPE_CLOSE | close the current subpath | none |
UXPE_CURVE | cubic Bézier to x,y | all six |
There is no quadratic type. quadTo elevates its control point to a cubic
pair on the way in, so flattening, bounds and containment handle one curve form.
A path you read back shows UXPE_CURVE where you wrote a quad.
UXPE_CLOSE carries no coordinates: the subpath’s start is already known from
the UXPE_MOVE that opened it.
The control points are the previous point’s partners
Section titled “The control points are the previous point’s partners”A cubic needs four points, and the element stores three. The fourth, the start, is the current point: wherever the previous element left off.
p.moveTo(20, 50); // current point is 20,50p.curveTo(20, 10, 80, 10, 80, 50); // P0 = 20,50 implicitlyThis is the usual path convention. Elements cannot be reordered or removed independently, because each one’s meaning depends on the one before it.
Coordinates are i16
Section titled “Coordinates are i16”Whole pixels, with a range of ±32767. That is an authoring range, well past any window and any printed page at device resolution.
The precision rendering needs lives elsewhere: the flattener can emit 1/16-pixel units, which the stroker works in and rounds once at the end. See sub-pixel output. The element type stays small and exact, and the fractional work happens where it is needed.
Fields
Section titled “Fields”i32 typeOne of the four constants above.
i16 x; i16 yThe on-curve point this element ends at. Unused by UXPE_CLOSE.
c1x / c1y / c2x / c2y
Section titled “c1x / c1y / c2x / c2y”i16 c1x; i16 c1y; // first control pointi16 c2x; i16 c2y; // secondMeaningful only for UXPE_CURVE. For other types they are zero: init clears
them, so a move or line element reads as 0,0, not as leftover memory.
Conforms to
Section titled “Conforms to”- Inherits
Object
See also
Section titled “See also”UXShapePath: the path these buildUXEdge: what a flattened path becomes