PathParser
public final class PathParser
Parses SVG path strings.
Summary
Nested types |
|---|
public class PathParser.PathDataNodeEach PathDataNode represents one command in the "d" attribute of the svg file. |
Public methods |
|
|---|---|
static boolean |
|
static @NonNull PathParser.PathDataNode[] |
createNodesFromPathData(@NonNull String pathData) |
static @NonNull Path |
createPathFromPathData(@NonNull String pathData)Takes a string representation of an SVG path and converts it to a |
static @NonNull PathParser.PathDataNode[] |
deepCopyNodes(@NonNull PathParser.PathDataNode[] source) |
static void |
interpolatePathDataNodes(Interpolate between two arrays of PathDataNodes with the given fraction, and store the results in the first parameter. |
static void |
nodesToPath(@NonNull PathParser.PathDataNode[] node, @NonNull Path path)Convert an array of PathDataNode to Path. |
static void |
updateNodes(Update the target's data to match the source. |
Public methods
canMorph
public static boolean canMorph(
@Nullable PathParser.PathDataNode[] nodesFrom,
@Nullable PathParser.PathDataNode[] nodesTo
)
| Parameters | |
|---|---|
@Nullable PathParser.PathDataNode[] nodesFrom |
The source path represented in an array of PathDataNode |
@Nullable PathParser.PathDataNode[] nodesTo |
The target path represented in an array of PathDataNode |
| Returns | |
|---|---|
boolean |
whether the |
createNodesFromPathData
public static @NonNull PathParser.PathDataNode[] createNodesFromPathData(@NonNull String pathData)
| Parameters | |
|---|---|
@NonNull String pathData |
The string representing a path, the same as "d" string in svg file. |
| Returns | |
|---|---|
@NonNull PathParser.PathDataNode[] |
an array of the PathDataNode. |
createPathFromPathData
public static @NonNull Path createPathFromPathData(@NonNull String pathData)
Takes a string representation of an SVG path and converts it to a Path.
deepCopyNodes
public static @NonNull PathParser.PathDataNode[] deepCopyNodes(@NonNull PathParser.PathDataNode[] source)
| Parameters | |
|---|---|
@NonNull PathParser.PathDataNode[] source |
The array of PathDataNode to be duplicated. |
| Returns | |
|---|---|
@NonNull PathParser.PathDataNode[] |
a deep copy of the |
interpolatePathDataNodes
public static void interpolatePathDataNodes(
@NonNull PathParser.PathDataNode[] target,
float fraction,
@NonNull PathParser.PathDataNode[] from,
@NonNull PathParser.PathDataNode[] to
)
Interpolate between two arrays of PathDataNodes with the given fraction, and store the results in the first parameter.
| Parameters | |
|---|---|
@NonNull PathParser.PathDataNode[] target |
The resulting array of |
float fraction |
A float fraction value in the range of 0 to 1 |
@NonNull PathParser.PathDataNode[] from |
The array of |
@NonNull PathParser.PathDataNode[] to |
The array of |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
When the arrays of nodes are incompatible for interpolation. |
| See also | |
|---|---|
canMorph |
nodesToPath
public static void nodesToPath(@NonNull PathParser.PathDataNode[] node, @NonNull Path path)
Convert an array of PathDataNode to Path.
updateNodes
public static void updateNodes(
@NonNull PathParser.PathDataNode[] target,
@NonNull PathParser.PathDataNode[] source
)
Update the target's data to match the source. Before calling this, make sure canMorph(target, source) is true.