PathIterator
-
Cmn
interface PathIterator : Iterator
A path iterator can be used to iterate over all the segments that make up a path. Those segments may in turn define multiple contours inside the path.
The handling of conic segments is defined by the conicEvaluation property. When set to AsConic, conic segments are preserved, but when set to AsConic, conic segments are approximated using 1 or more quadratic segments. The error of the approximation is controlled by tolerance.
Summary
Nested types |
|---|
enum PathIterator.ConicEvaluation : EnumUsed to define how conic segments are evaluated when iterating over a |
Public functions |
||
|---|---|---|
Int |
calculateSize(includeConvertedConics: Boolean)Returns the number of verbs present in this iterator, i.e. the number of calls to |
Cmn
|
operator Boolean |
hasNext()Returns |
Cmn
|
operator PathSegment |
next()Returns the next |
Cmn
|
PathSegment.Type |
next(outPoints: FloatArray, offset: Int)Returns the |
Cmn
|
Public properties |
||
|---|---|---|
PathIterator.ConicEvaluation |
Indicates whether conic segments, when present, are preserved as-is or converted to quadratic segments, using an approximation whose error is controlled by |
Cmn
|
Path |
The |
Cmn
|
Float |
Error of the approximation used to evaluate conic segments if they are converted to quadratics. |
Cmn
|
Public functions
calculateSize
fun calculateSize(includeConvertedConics: Boolean = true): Int
Returns the number of verbs present in this iterator, i.e. the number of calls to next required to complete the iteration.
By default, calculateSize returns the true number of operations in the iterator. Deriving this result requires converting any conics to quadratics, if conicEvaluation is set to ConicEvaluation.AsQuadratics, which takes extra processing time. Set includeConvertedConics to false if an approximate size, not including conic conversion, is sufficient.
| Parameters | |
|---|---|
includeConvertedConics: Boolean = true |
The returned size includes any required conic conversions. Default is true, so it will return the exact size, at the cost of iterating through all elements and converting any conics as appropriate. Set to false to save on processing, at the cost of a less exact result. |
next
operator fun next(): PathSegment
Returns the next path segment in the iteration, or DoneSegment if the iteration is finished. To save on allocations, use the alternative next function, which takes a FloatArray.
next
fun next(outPoints: FloatArray, offset: Int = 0): PathSegment.Type
Returns the type of the next path segment in the iteration and fills outPoints with the points specific to the segment type. Each pair of floats in the outPoints array represents a point for the given segment. The number of pairs of floats depends on the PathSegment.Type:
-
Move: 1 pair (indices 0 to 1) -
Line: 2 pairs (indices 0 to 3) -
Quadratic: 3 pairs (indices 0 to 5) -
Conic: 3 pairs (indices 0 to 5), and the conicweightat index 6. The value of the last float is undefined. SeePathSegment.Type.Conicfor more details -
Cubic: 4 pairs (indices 0 to 7) -
Close: 0 pair -
Done: 0 pair
This method does not allocate any memory.
| Parameters | |
|---|---|
outPoints: FloatArray |
A |
offset: Int = 0 |
Offset in |
Public properties
conicEvaluation
val conicEvaluation: PathIterator.ConicEvaluation
Indicates whether conic segments, when present, are preserved as-is or converted to quadratic segments, using an approximation whose error is controlled by tolerance.
tolerance
val tolerance: Float
Error of the approximation used to evaluate conic segments if they are converted to quadratics. The error is defined as the maximum distance between the original conic segment and its quadratic approximation. See conicEvaluation.