PathParser


class PathParser


Parses SVG path strings.

Summary

Nested types

Each PathDataNode represents one command in the "d" attribute of the svg file.

Public functions

java-static Boolean
canMorph(
    nodesFrom: Array<PathParser.PathDataNode!>?,
    nodesTo: Array<PathParser.PathDataNode!>?
)
java-static Array<PathParser.PathDataNode!>
java-static Path

Takes a string representation of an SVG path and converts it to a Path.

java-static Array<PathParser.PathDataNode!>
java-static Unit
interpolatePathDataNodes(
    target: Array<PathParser.PathDataNode!>,
    fraction: Float,
    from: Array<PathParser.PathDataNode!>,
    to: Array<PathParser.PathDataNode!>
)

Interpolate between two arrays of PathDataNodes with the given fraction, and store the results in the first parameter.

java-static Unit

Convert an array of PathDataNode to Path.

java-static Unit

Update the target's data to match the source.

Public functions

canMorph

Added in 1.13.0
java-static fun canMorph(
    nodesFrom: Array<PathParser.PathDataNode!>?,
    nodesTo: Array<PathParser.PathDataNode!>?
): Boolean
Parameters
nodesFrom: Array<PathParser.PathDataNode!>?

The source path represented in an array of PathDataNode

nodesTo: Array<PathParser.PathDataNode!>?

The target path represented in an array of PathDataNode

Returns
Boolean

whether the nodesFrom can morph into nodesTo

createNodesFromPathData

Added in 1.13.0
java-static fun createNodesFromPathData(pathData: String): Array<PathParser.PathDataNode!>
Parameters
pathData: String

The string representing a path, the same as "d" string in svg file.

Returns
Array<PathParser.PathDataNode!>

an array of the PathDataNode.

createPathFromPathData

Added in 1.13.0
java-static fun createPathFromPathData(pathData: String): Path

Takes a string representation of an SVG path and converts it to a Path.

Parameters
pathData: String

The string representing a path, the same as "d" string in svg file.

Returns
Path

the generated Path object.

deepCopyNodes

Added in 1.13.0
java-static fun deepCopyNodes(source: Array<PathParser.PathDataNode!>): Array<PathParser.PathDataNode!>
Parameters
source: Array<PathParser.PathDataNode!>

The array of PathDataNode to be duplicated.

Returns
Array<PathParser.PathDataNode!>

a deep copy of the source.

interpolatePathDataNodes

Added in 1.13.0
java-static fun interpolatePathDataNodes(
    target: Array<PathParser.PathDataNode!>,
    fraction: Float,
    from: Array<PathParser.PathDataNode!>,
    to: Array<PathParser.PathDataNode!>
): Unit

Interpolate between two arrays of PathDataNodes with the given fraction, and store the results in the first parameter.

Parameters
target: Array<PathParser.PathDataNode!>

The resulting array of PathDataNode for the interpolation

fraction: Float

A float fraction value in the range of 0 to 1

from: Array<PathParser.PathDataNode!>

The array of PathDataNode when fraction is 0

to: Array<PathParser.PathDataNode!>

The array of PathDataNode when the fraction is 1

Throws
java.lang.IllegalArgumentException

When the arrays of nodes are incompatible for interpolation.

See also
canMorph

nodesToPath

Added in 1.13.0
java-static fun nodesToPath(node: Array<PathParser.PathDataNode!>, path: Path): Unit

Convert an array of PathDataNode to Path.

Parameters
node: Array<PathParser.PathDataNode!>

The source array of PathDataNode.

path: Path

The target Path object.

updateNodes

Added in 1.13.0
java-static fun updateNodes(
    target: Array<PathParser.PathDataNode!>,
    source: Array<PathParser.PathDataNode!>
): Unit

Update the target's data to match the source. Before calling this, make sure canMorph(target, source) is true.

Parameters
target: Array<PathParser.PathDataNode!>

The target path represented in an array of PathDataNode

source: Array<PathParser.PathDataNode!>

The source path represented in an array of PathDataNode