public class PathMeasure extends Object
Path object.| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
GET_POSITION_AND_TANGENT_MATRIX_FLAG |
Indicates the flag of getting position and tangent.
|
static int |
GET_POSITION_MATRIX_FLAG |
Indicates the flag of getting position.
|
static int |
GET_TANGENT_MATRIX_FLAG |
Indicates the flag of getting tangent.
|
| 构造器 | 说明 |
|---|---|
PathMeasure(Path path,
boolean forceClosed) |
A constructor used to create a
PathMeasure object based on the specified path. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
float |
getLength() |
Obtains the length of the associated path in this
PathMeasure object. |
boolean |
getMatrix(float distance,
Matrix matrix,
int flags) |
Obtains the matrix that saves the position or tangent value of the specified
distance on the path. |
boolean |
getPosTan(float distance,
float[] position,
float[] tangent) |
Obtains the coordinates that specify the position of the specified length on the associated path and its tangent
value.
|
boolean |
getSegment(float startDistance,
float stopDistance,
Path path,
boolean startWithMoveTo) |
Obtains the specified segment of the path associated with this
PathMeasure object. |
boolean |
isClosed() |
Checks whether the contour of the path associated with this
PathMeasure object is closed. |
void |
setPath(Path path,
boolean forceClosed) |
Associates the specified path with this
PathMeasure object. |
public static final int GET_POSITION_AND_TANGENT_MATRIX_FLAG
public static final int GET_POSITION_MATRIX_FLAG
public static final int GET_TANGENT_MATRIX_FLAG
public PathMeasure(Path path, boolean forceClosed)
PathMeasure object based on the specified path.
Once a PathMeasure object is associated with a specified path, you must call setPath(ohos.agp.render.Path, boolean) to
re-associate the path if the path is modified.
path - Indicates the Path object to associate. This parameter can be null.forceClosed - Specifies whether to forcibly close the path. If the value is true, the path is
forcibly closed. If the value is false, the path keeps unchanged.public float getLength()
PathMeasure object.public boolean getPosTan(float distance,
float[] position,
float[] tangent)
distance - Indicates the distance away from the starting point of the associated path.position - Indicates the coordinate array of the position which is distance away from the starting
point of the associated path. The coordinate array contains two values, the x-axis coordinate value and y-axis
coordinate value.tangent - Indicates the tangent value of the position on the associated path, that is, the direction
of the path at the point.true if the position and tangent value are obtained; returns false otherwise.
When false is returned, the position and tangent value of the path keep unchanged.public void setPath(Path path, boolean forceClosed)
PathMeasure object.path - Indicates the Path object to associate.forceClosed - Specifies whether to forcibly close the path. If the value is true, the path is
forcibly closed. If the value is false, the path keeps unchanged.public boolean getSegment(float startDistance,
float stopDistance,
Path path,
boolean startWithMoveTo)
PathMeasure object.startDistance - Indicates the distance from the start of the segment to the start of the path.stopDistance - Indicates the distance from the end of the segment to the start of the path.path - Indicates the Path object used to save the segment of the associated path. The existing
structure in the Path object keeps unchanged, and only the segment of the associated path is added.startWithMoveTo - Specifies whether to use a moveTo feature for the segment. If this parameter is
set to true, the segment is left unchanged. If this parameter is set to false and the last point
of the path does not overlap the first point of the segment, the two points will be connected.true if the segment is obtained; returns false otherwise.public boolean isClosed()
PathMeasure object is closed.true if the contour of the path is closed; returns false otherwise.public boolean getMatrix(float distance,
Matrix matrix,
int flags)
distance on the path.distance - Indicates the distance from the start of the path to the specified position.matrix - Indicates the matrix used to save the position or/and tangent value of the specified distance.flags - Indicates the flags used to specify the data to be stored in the matrix. The value 1 means
to save the position, 2 means to save the tangent value, and 3 means to save both the position
and tangent value.true if information is successfully saved in the matrix; returns false otherwise.