Android Studio Sign in

PathParser


public final class PathParser


Parses SVG path strings.

Summary

Nested types

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

Public methods

static boolean
canMorph(
    @Nullable PathParser.PathDataNode[] nodesFrom,
    @Nullable PathParser.PathDataNode[] nodesTo
)
static @NonNull PathParser.PathDataNode[]
static @NonNull Path

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

static @NonNull PathParser.PathDataNode[]
deepCopyNodes(@NonNull PathParser.PathDataNode[] source)
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.

static void
nodesToPath(@NonNull PathParser.PathDataNode[] node, @NonNull Path path)

Convert an array of PathDataNode to Path.

static void
updateNodes(
    @NonNull PathParser.PathDataNode[] target,
    @NonNull PathParser.PathDataNode[] source
)

Update the target's data to match the source.

Public methods

canMorph

Added in 1.13.0
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 nodesFrom can morph into nodesTo

createNodesFromPathData

Added in 1.13.0
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

Added in 1.13.0
public static @NonNull Path createPathFromPathData(@NonNull String pathData)

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

Parameters
@NonNull String pathData

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

Returns
@NonNull Path

the generated Path object.

deepCopyNodes

Added in 1.13.0
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 source.

interpolatePathDataNodes

Added in 1.13.0
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 PathDataNode for the interpolation

float fraction

A float fraction value in the range of 0 to 1

@NonNull PathParser.PathDataNode[] from

The array of PathDataNode when fraction is 0

@NonNull PathParser.PathDataNode[] to

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
public static void nodesToPath(@NonNull PathParser.PathDataNode[] node, @NonNull Path path)

Convert an array of PathDataNode to Path.

Parameters
@NonNull PathParser.PathDataNode[] node

The source array of PathDataNode.

@NonNull Path path

The target Path object.

updateNodes

Added in 1.13.0
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.

Parameters
@NonNull PathParser.PathDataNode[] target

The target path represented in an array of PathDataNode

@NonNull PathParser.PathDataNode[] source

The source path represented in an array of PathDataNode

Morty Proxy This is a proxified and sanitized view of the page, visit original site.