openharmony 鸿蒙 capi-drawing-path-h

2026-08-25 浏览 (1)

drawing_path.h

Overview

This file declares the functions related to the path in the drawing module.

Sample: NDKAPIDrawing (API Version 20)

File to include: <native_drawing/drawing_path.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Related module: Drawing

Summary

Enums

Nametypedef KeywordDescription
OH_Drawing_PathDirectionOH_Drawing_PathDirectionDefines an enum for the directions of a closed contour.
OH_Drawing_PathFillTypeOH_Drawing_PathFillTypeDefines an enum for the fill types of a path.
OH_Drawing_PathAddModeOH_Drawing_PathAddModeDefines an enum for the path adding modes.
OH_Drawing_PathOpModeOH_Drawing_PathOpModeDefines an enum for the operation modes available for a path.
OH_Drawing_PathMeasureMatrixFlagsOH_Drawing_PathMeasureMatrixFlagsDefines an enum for the types of matrix information obtained during path measurement.

Functions

NameDescription
OH_Drawing_Path* OH_Drawing_PathCreate(void)Creates an OH_Drawing_Path object.
OH_Drawing_Path* OH_Drawing_PathCopy(OH_Drawing_Path* path)Creates a copy of the OH_Drawing_Path object.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathDestroy(OH_Drawing_Path* path)Destroys an OH_Drawing_Path object and reclaims the memory occupied by the object.
OH_Drawing_ErrorCode OH_Drawing_PathSetPath(OH_Drawing_Path* path, OH_Drawing_Path* other)Sets a path object as the current path object.
OH_Drawing_ErrorCode OH_Drawing_PathIsEmpty(OH_Drawing_Path* path, bool* isEmpty)Checks whether a path object is empty.
OH_Drawing_ErrorCode OH_Drawing_PathIsRect(OH_Drawing_Path* path, OH_Drawing_Rect* rect, bool* isRect)Checks whether a path object forms a rectangle.
void OH_Drawing_PathMoveTo(OH_Drawing_Path* path, float x, float y)Sets the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathLineTo(OH_Drawing_Path* path, float x, float y)Draws a line segment from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathArcTo(OH_Drawing_Path* path,float x1, float y1, float x2, float y2, float startDeg, float sweepDeg)Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle is specified first,
and then a start angle and scanning degree are specified. The inscribed ellipse of the rectangle will be used to intercept the arc.
The arc is a portion of the ellipse defined by the start angle and the sweep angle. If the path is empty, a line segment from the last point of the path to the start point of the arc is also added.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY)Draws a quadratic Bezier curve from the last point of a path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight)Draws a conic curve from the last point of a path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathCubicTo(OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY)Draws a cubic Bezier curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathRMoveTo(OH_Drawing_Path* path, float x, float y)Sets the start position relative to the last point of a path. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathRLineTo(OH_Drawing_Path* path, float x, float y)Draws a line segment from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathRQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY)Draws a quadratic Bezier curve from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathRConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight)Draws a conic curve from the last point of a path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathRCubicTo(OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2,float endX, float endY)Draws a cubic Bezier curve from the last point of a path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathAddRect(OH_Drawing_Path* path, float left, float top, float right, float bottom,OH_Drawing_PathDirection pathDirection)Adds a rectangle to a path in the specified direction. The start point is the upper left corner of the rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddRectWithInitialCorner(OH_Drawing_Path* path, const OH_Drawing_Rect* rect,OH_Drawing_PathDirection pathDirection, uint32_t start)Adds a rectangle contour to a path in the specified direction.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddRoundRect(OH_Drawing_Path* path,const OH_Drawing_RoundRect* roundRect, OH_Drawing_PathDirection pathDirection)Adds a rounded rectangle to a path in the specified direction. When the path direction is clockwise, the start point is at the intersection of the rounded rectangle's left boundary and its lower left corner. When the path direction is counterclockwise, the start point is at the intersection point between the left boundary and the upper left corner.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or roundRect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path* path, const OH_Drawing_Rect* rect,uint32_t start, OH_Drawing_PathDirection pathDirection)Adds an oval to a path. OH_Drawing_Rect specifies the outer tangent rectangle of the oval, and OH_Drawing_PathDirection specifies whether the drawing is clockwise or counterclockwise.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddOval(OH_Drawing_Path* path,const OH_Drawing_Rect* rect, OH_Drawing_PathDirection pathDirection)Adds an oval to a path in the specified direction.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddArc(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, float startAngle, float sweepAngle)Adds an arc to a path as the start of a new contour. The arc added is part of the inscribed ellipse of the rectangle, from the start angle through the sweep angle. If the sweep angle is less than or equal to -360°, or if the sweep angle is greater than or equal to 360°, and start angle modulo 90 is nearly zero, an oval instead of an ellipse is added.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathAddPath(OH_Drawing_Path* path, const OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix)Transforms the points in a src path by a matrix and adds the new one to the current path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src,const OH_Drawing_Matrix* matrix, OH_Drawing_PathAddMode pathAddMode)Transforms the points in a src path by a matrix and adds the new one to the current path with the specified adding mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathAddMode is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* path,const OH_Drawing_Path* src, OH_Drawing_PathAddMode pathAddMode)Adds a src path to the current path with the specified adding mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathAddMode is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, float dx, float dy,OH_Drawing_PathAddMode pathAddMode)Translates a src path by an offset and adds the new one to the current path with the specified adding mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathAddMode is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
void OH_Drawing_PathAddPolygon(OH_Drawing_Path* path, const OH_Drawing_Point2D* points, uint32_t count, bool isClosed)Adds a polygon to a path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or points is NULL or count is 0, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathAddCircle(OH_Drawing_Path* path,float x, float y, float radius, OH_Drawing_PathDirection pathDirection)Adds a circle to a path in the specified direction.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If radius is less than or equal to 0, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
bool OH_Drawing_PathBuildFromSvgString(OH_Drawing_Path* path, const char* str)Parses the path represented by an SVG string.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or str is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
bool OH_Drawing_PathContains(OH_Drawing_Path* path, float x, float y)Checks whether a coordinate point is included in this path. For details, see OH_Drawing_PathFillType.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathTransform(OH_Drawing_Path* path, const OH_Drawing_Matrix* matrix)Transforms the points in a path by matrix.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or matrix is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathTransformWithPerspectiveClip(OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix,OH_Drawing_Path* dst, bool applyPerspectiveClip)Transforms the points in a path by matrix, and uses the new one to replace the dst path. If dst is NULL, the src path is replaced.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either src or matrix is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathSetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType pathFillType)Sets the fill type of a path. The fill type determines how "inside" of the path is drawn.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathFillType is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
OH_Drawing_ErrorCode OH_Drawing_PathGetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType* pathFillType)Obtains the fill type of a path.
float OH_Drawing_PathGetLength(OH_Drawing_Path* path, bool forceClosed)Obtains the length of a path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathGetBounds(OH_Drawing_Path* path, OH_Drawing_Rect* rect)Obtains the minimum bounds that enclose a path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathClose(OH_Drawing_Path* path)Draws a line segment from the current point to the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathOffset(OH_Drawing_Path* path, OH_Drawing_Path* dst, float dx, float dy)Translates a path by an offset along the X axis and Y axis and adds the new one to the dst path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_PathReset(OH_Drawing_Path* path)Resets the path data.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
bool OH_Drawing_PathIsClosed(OH_Drawing_Path* path, bool forceClosed)Checks whether a path is closed.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
bool OH_Drawing_PathGetPositionTangent(OH_Drawing_Path* path, bool forceClosed,float distance, OH_Drawing_Point2D* position, OH_Drawing_Point2D* tangent)Obtains the coordinates and tangent at a distance from the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If any of path, position, or tangent is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
OH_Drawing_ErrorCode OH_Drawing_PathGetSegment(OH_Drawing_Path* path, bool forceClosed,float start, float stop, bool startWithMoveTo, OH_Drawing_Path* dst, bool* result)Extracts a segment of a path and appends it to a destination path.
bool OH_Drawing_PathOp(OH_Drawing_Path* path, const OH_Drawing_Path* other, OH_Drawing_PathOpMode op)Combines two paths based on the specified operation mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or srcPath is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If op is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
bool OH_Drawing_PathGetMatrix(OH_Drawing_Path* path, bool forceClosed,float distance, OH_Drawing_Matrix* matrix, OH_Drawing_PathMeasureMatrixFlags flag)Obtains a transformation matrix at a distance from the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or matrix is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If flag is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
OH_Drawing_ErrorCode OH_Drawing_PathApproximate(OH_Drawing_Path* path, float acceptableError, float* vals,uint32_t* count)Converts the existing path into an approximate path consisting of consecutive line segments.
OH_Drawing_ErrorCode OH_Drawing_PathInterpolate(OH_Drawing_Path* path, OH_Drawing_Path* other,float weight, bool* success, OH_Drawing_Path* interpolatedPath)Interpolates between the existing path and another path based on the given weight and stores the result in the target path object.
Interpolation is achievable if the two paths have the same number of points. The target path is created based on the structure of the existing path.
OH_Drawing_ErrorCode OH_Drawing_PathIsInterpolate(OH_Drawing_Path* path, OH_Drawing_Path* other, bool* result)Checks whether the existing path and another path (other) are compatible for interpolation in terms of structure and operation sequence.
If the paths contain conic operations, the weight values of the operations must be the same.
OH_Drawing_ErrorCode OH_Drawing_PathIsInverseFillType(const OH_Drawing_Path* path, bool* isInverse)Checks whether the fill type of the path is the inverse type.
The inverse type is PATH_FILL_TYPE_INVERSE_WINDING and PATH_FILL_TYPE_INVERSE_EVEN_ODD in OH_Drawing_PathFillType.
OH_Drawing_ErrorCode OH_Drawing_PathToggleInverseFillType(OH_Drawing_Path* path)Toggles the fill type of the path to the inverse type.
The inverse type is PATH_FILL_TYPE_INVERSE_WINDING and PATH_FILL_TYPE_INVERSE_EVEN_ODD in OH_Drawing_PathFillType.

Enum Description

OH_Drawing_PathDirection

enum OH_Drawing_PathDirection

Description

Enumerates the directions of a closed contour.

Since: 12

ValueDescription
PATH_DIRECTION_CWAdds a closed contour clockwise.
PATH_DIRECTION_CCWAdds a closed contour counterclockwise.

OH_Drawing_PathFillType

enum OH_Drawing_PathFillType

Description

Enumerates the fill types of a path.

Since: 12

ValueDescription
PATH_FILL_TYPE_WINDINGFor any point within the drawing area, a ray is cast in an arbitrary direction. The count starts at 0 for all intersections between this ray and the path.
Each clockwise intersection—where the path crosses the ray from left to right—results in the count being incremented by 1, while each counterclockwise intersection—where the path crosses the ray from right to left—causes the count to be decremented by 1. A point is deemed inside the path and needs to be colored if the final count is non-zero; if the count is 0, the point remains uncolored.
PATH_FILL_TYPE_EVEN_ODDFor any point in the drawing area, a ray is cast in an arbitrary direction. If the number of intersections between this ray and the path is odd, the point is deemed inside the path and needs to be colored; if the number is even, it remains uncolored.
PATH_FILL_TYPE_INVERSE_WINDINGSame as PATH_FILL_TYPE_WINDING, but draws outside of the path, rather than inside.
PATH_FILL_TYPE_INVERSE_EVEN_ODDSame as PATH_FILL_TYPE_EVEN_ODD, but draws outside of the path, rather than inside.

OH_Drawing_PathAddMode

enum OH_Drawing_PathAddMode

Description

Enumerates the path adding modes.

Since: 12

ValueDescription
PATH_ADD_MODE_APPENDAdds a path in append mode.
PATH_ADD_MODE_EXTENDAdds a line segment to close the path if the previous path is not closed.

OH_Drawing_PathOpMode

enum OH_Drawing_PathOpMode

Description

Enumerates the operation modes available for a path.

Since: 12

ValueDescription
PATH_OP_MODE_DIFFERENCEDifference operation.
PATH_OP_MODE_INTERSECTIntersection operation.
PATH_OP_MODE_UNIONUnion operation.
PATH_OP_MODE_XORXOR operation.
PATH_OP_MODE_REVERSE_DIFFERENCEReverse difference operation.

OH_Drawing_PathMeasureMatrixFlags

enum OH_Drawing_PathMeasureMatrixFlags

Description

Enumerates the types of matrix information obtained during path measurement.

Since: 12

ValueDescription
GET_POSITION_MATRIXMatrix corresponding to the position information.
GET_TANGENT_MATRIXMatrix corresponding to the tangent information.
GET_POSITION_AND_TANGENT_MATRIXMatrix corresponding to the position and tangent information.

Function Description

OH_Drawing_PathCreate()

OH_Drawing_Path* OH_Drawing_PathCreate(void)

Description

Creates an OH_Drawing_Path object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Returns

TypeDescription
OH_Drawing_Path*Returns the pointer to the OH_Drawing_Path object created.

OH_Drawing_PathCopy()

OH_Drawing_Path* OH_Drawing_PathCopy(OH_Drawing_Path* path)

Description

Creates a copy of the OH_Drawing_Path object.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.

Returns

TypeDescription
OH_Drawing_Path*Pointer to the copy of the OH_Drawing_Path object.

OH_Drawing_PathDestroy()

void OH_Drawing_PathDestroy(OH_Drawing_Path* path)

Description

Destroys an OH_Drawing_Path object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.

OH_Drawing_PathSetPath()

OH_Drawing_ErrorCode OH_Drawing_PathSetPath(OH_Drawing_Path* path, OH_Drawing_Path* other)

Description

Sets a path object as the current path object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
OH_Drawing_Path* otherPointer to the OH_Drawing_Path object to be set.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if path or other is NULL.

OH_Drawing_PathIsEmpty()

OH_Drawing_ErrorCode OH_Drawing_PathIsEmpty(OH_Drawing_Path* path, bool* isEmpty)

Description

Checks whether a path object is empty.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
bool* isEmptyWhether the path object is empty. true means empty; false otherwise. It as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if path or isEmpty is NULL.

OH_Drawing_PathIsRect()

OH_Drawing_ErrorCode OH_Drawing_PathIsRect(OH_Drawing_Path* path, OH_Drawing_Rect* rect, bool* isRect)

Description

Checks whether a path object forms a rectangle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object, which is used as an output parameter and can be null.
bool* isRectWhether a path forms a rectangle. true means yes; false otherwise. It as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if path or isRect is NULL.

OH_Drawing_PathMoveTo()

void OH_Drawing_PathMoveTo(OH_Drawing_Path* path, float x, float y)

Description

Sets the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.
float xX coordinate of the start point.
float yY coordinate of the start point.

OH_Drawing_PathLineTo()

void OH_Drawing_PathLineTo(OH_Drawing_Path* path, float x, float y)

Description

Draws a line segment from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.
float xX coordinate of the target point.
float yY coordinate of the target point.

OH_Drawing_PathArcTo()

void OH_Drawing_PathArcTo(OH_Drawing_Path* path,float x1, float y1, float x2, float y2, float startDeg, float sweepDeg)

Description

Draws an arc to a path. This is done by using angle arc mode. In this mode, a rectangle is specified first,
and then a start angle and scanning degree are specified. The inscribed ellipse of the rectangle will be used to intercept the arc.
The arc is a portion of the ellipse defined by the start angle and the sweep angle. If the path is empty, a line segment from the last point of the path to the start point of the arc is also added.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.
float x1X coordinate of the upper left corner of the rectangle.
float y1Y coordinate of the upper left corner of the rectangle.
float x2X coordinate of the lower right corner of the rectangle.
float y2Y coordinate of the lower right corner of the rectangle.
float startDegStart angle. The start direction (0°) of the angle is the positive direction of the X axis.
float sweepDegAngle to sweep, in degrees. A positive number indicates a clockwise sweep, and a negative value indicates a counterclockwise swipe. The actual swipe degree is the modulo operation result of the input parameter by 360.

OH_Drawing_PathQuadTo()

void OH_Drawing_PathQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY)

Description

Draws a quadratic Bezier curve from the last point of a path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.
float ctrlXX coordinate of the control point.
float ctrlYY coordinate of the control point.
float endXX coordinate of the target point.
float endYY coordinate of the target point.

OH_Drawing_PathConicTo()

void OH_Drawing_PathConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight)

Description

Draws a conic curve from the last point of a path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float ctrlXX coordinate of the control point.
float ctrlYY coordinate of the control point.
float endXX coordinate of the target point.
float endYY coordinate of the target point.
float weightWeight of the curve, which determines its shape. The larger the value, the closer of the curve to the control point.
If the value is less than or equal to 0, the result is equivalent to a line segment from the start point to the end point, which is added by calling OH_Drawing_PathLineTo.
If the value is 1, the result is equivalent to OH_Drawing_PathQuadTo.

OH_Drawing_PathCubicTo()

void OH_Drawing_PathCubicTo(OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY)

Description

Draws a cubic Bezier curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.
float ctrlX1X coordinate of the first control point.
float ctrlY1Y coordinate of the first control point.
float ctrlX2X coordinate of the second control point.
float ctrlY2Y coordinate of the second control point.
float endXX coordinate of the target point.
float endYY coordinate of the target point.

OH_Drawing_PathRMoveTo()

void OH_Drawing_PathRMoveTo(OH_Drawing_Path* path, float x, float y)

Description

Sets the start position relative to the last point of a path. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float xX-axis offset relative to the end point of a path. A positive number indicates an offset in the positive direction of the X axis, and a negative number indicates an offset in the negative direction of the X axis.
float yY-axis offset relative to the end point of a path. A positive number indicates an offset in the positive direction of the Y axis, and a negative number indicates an offset in the negative direction of the Y axis.

OH_Drawing_PathRLineTo()

void OH_Drawing_PathRLineTo(OH_Drawing_Path* path, float x, float y)

Description

Draws a line segment from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float xX offset relative to the last point, which is used to specify the X coordinate of the target point.
float yY offset relative to the last point, which is used to specify the X coordinate of the target point.

OH_Drawing_PathRQuadTo()

void OH_Drawing_PathRQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY)

Description

Draws a quadratic Bezier curve from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float ctrlXX offset relative to the last point, which is used to specify the X coordinate of the control point.
float ctrlYY offset relative to the last point, which is used to specify the Y coordinate of the control point.
float endXX offset relative to the last point, which is used to specify the X coordinate of the target point.
float endYY offset relative to the last point, which is used to specify the Y coordinate of the target point.

OH_Drawing_PathRConicTo()

void OH_Drawing_PathRConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight)

Description

Draws a conic curve from the last point of a path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float ctrlXX offset relative to the last point, which is used to specify the X coordinate of the control point.
float ctrlYY offset relative to the last point, which is used to specify the Y coordinate of the control point.
float endXX offset relative to the last point, which is used to specify the X coordinate of the target point.
float endYY offset relative to the last point, which is used to specify the Y coordinate of the target point.
float weightWeight of the curve, which determines its shape. The larger the value, the closer of the curve to the control point.
If the value is less than or equal to 0, the result is equivalent to a line segment from the start point to the end point, which is added by calling OH_Drawing_PathRLineTo.
If the value is 1, the result is equivalent to OH_Drawing_PathRQuadTo.

OH_Drawing_PathRCubicTo()

void OH_Drawing_PathRCubicTo(OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2,float endX, float endY)

Description

Draws a cubic Bezier curve from the last point of a path to a point relative to the last point. If the path is empty, the start point (0, 0) is used.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float ctrlX1X offset relative to the last point, which is used to specify the X coordinate of the first control point.
float ctrlY1Y offset relative to the last point, which is used to specify the Y coordinate of the first control point.
float ctrlX2X offset relative to the last point, which is used to specify the X coordinate of the second control point.
float ctrlY2Y offset relative to the last point, which is used to specify the Y coordinate of the second control point.
float endXX offset relative to the last point, which is used to specify the X coordinate of the target point.
float endYY offset relative to the last point, which is used to specify the Y coordinate of the target point.

OH_Drawing_PathAddRect()

void OH_Drawing_PathAddRect(OH_Drawing_Path* path, float left, float top, float right, float bottom,OH_Drawing_PathDirection pathDirection)

Description

Adds a rectangle to a path in the specified direction. The start point is the upper left corner of the rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float leftX coordinate of the upper left corner of the rectangle.
float topY coordinate of the upper left corner of the rectangle.
float rightX coordinate of the lower right corner of the rectangle.
float bottomY coordinate of the lower right corner of the rectangle.
OH_Drawing_PathDirection pathDirectionOH_Drawing_PathDirection object.

OH_Drawing_PathAddRectWithInitialCorner()

void OH_Drawing_PathAddRectWithInitialCorner(OH_Drawing_Path* path, const OH_Drawing_Rect* rect,OH_Drawing_PathDirection pathDirection, uint32_t start)

Description

Adds a rectangle contour to a path in the specified direction.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
const OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
OH_Drawing_PathDirectionOH_Drawing_PathDirection object.
uint32_t startStart point, indicating the corner of the rectangle from which the path is drawn. The value 0 means the upper left corner, 1 means the upper right corner, 2 means the lower right corner, and 3 means the lower left corner.

OH_Drawing_PathAddRoundRect()

void OH_Drawing_PathAddRoundRect(OH_Drawing_Path* path,const OH_Drawing_RoundRect* roundRect, OH_Drawing_PathDirection pathDirection)

Description

Adds a rounded rectangle to a path in the specified direction. When the path direction is clockwise, the start point is at the intersection of the rounded rectangle's left boundary and its lower left corner. When the path direction is counterclockwise, the start point is at the intersection point between the left boundary and the upper left corner.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or roundRect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
const OH_Drawing_RoundRect* roundRectPointer to the OH_Drawing_RoundRect object.
OH_Drawing_PathDirection pathDirectionOH_Drawing_PathDirection object.

OH_Drawing_PathAddOvalWithInitialPoint()

void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path* path, const OH_Drawing_Rect* rect,uint32_t start, OH_Drawing_PathDirection pathDirection)

Description

Adds an oval to a path. OH_Drawing_Rect specifies the outer tangent rectangle of the oval, and OH_Drawing_PathDirection specifies whether the drawing is clockwise or counterclockwise.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
const OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
uint32_t startStart point of the oval.
OH_Drawing_PathDirection pathDirectionOH_Drawing_PathDirection object.

OH_Drawing_PathAddOval()

void OH_Drawing_PathAddOval(OH_Drawing_Path* path,const OH_Drawing_Rect* rect, OH_Drawing_PathDirection pathDirection)

Description

Adds an oval to a path in the specified direction.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
const OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
OH_Drawing_PathDirection pathDirectionOH_Drawing_PathDirection object.

OH_Drawing_PathAddArc()

void OH_Drawing_PathAddArc(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, float startAngle, float sweepAngle)

Description

Adds an arc to a path as the start of a new contour. The arc added is part of the inscribed ellipse of the rectangle, from the start angle through the sweep angle. If the sweep angle is less than or equal to -360°, or if the sweep angle is greater than or equal to 360°, and start angle modulo 90 is nearly zero, an oval instead of an ellipse is added.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
const OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
float startAngleStart angle of the arc, in degrees.
float sweepAngleAngle to sweep, in degrees. A positive number indicates a clockwise sweep, and a negative value indicates a counterclockwise swipe. The actual swipe degree is the modulo operation result of the input parameter by 360.

OH_Drawing_PathAddPath()

void OH_Drawing_PathAddPath(OH_Drawing_Path* path, const OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix)

Description

Transforms the points in a src path by a matrix and adds the new one to the current path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the existing OH_Drawing_Path object.
const OH_Drawing_Path* srcPointer to the source OH_Drawing_Path object.
const OH_Drawing_Matrix* matrixPointer to the OH_Drawing_Matrix object. A null pointer means an identity matrix.

OH_Drawing_PathAddPathWithMatrixAndMode()

void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src,const OH_Drawing_Matrix* matrix, OH_Drawing_PathAddMode pathAddMode)

Description

Transforms the points in a src path by a matrix and adds the new one to the current path with the specified adding mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathAddMode is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the existing OH_Drawing_Path object.
const OH_Drawing_Path* srcPointer to the source OH_Drawing_Path object.
const OH_Drawing_Matrix* matrixPointer to the OH_Drawing_Matrix object. A null pointer means an identity matrix.
OH_Drawing_PathAddMode pathAddModeOH_Drawing_PathAddMode object.

OH_Drawing_PathAddPathWithMode()

void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* path,const OH_Drawing_Path* src, OH_Drawing_PathAddMode pathAddMode)

Description

Adds a src path to the current path with the specified adding mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathAddMode is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the existing OH_Drawing_Path object.
const OH_Drawing_Path* srcPointer to the source OH_Drawing_Path object.
OH_Drawing_PathAddMode pathAddModeOH_Drawing_PathAddMode object.

OH_Drawing_PathAddPathWithOffsetAndMode()

void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, float dx, float dy,OH_Drawing_PathAddMode pathAddMode)

Description

Translates a src path by an offset and adds the new one to the current path with the specified adding mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or src is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathAddMode is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the existing OH_Drawing_Path object.
const OH_Drawing_Path* srcPointer to the source OH_Drawing_Path object.
float dxX offset.
float dyY offset.
OH_Drawing_PathAddMode pathAddModeOH_Drawing_PathAddMode object.

OH_Drawing_PathAddPolygon()

void OH_Drawing_PathAddPolygon(OH_Drawing_Path* path, const OH_Drawing_Point2D* points, uint32_t count, bool isClosed)

Description

Adds a polygon to a path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or points is NULL or count is 0, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the existing OH_Drawing_Path object.
const OH_Drawing_Point2D* pointsPointer to an array that holds the vertex coordinates of the polygon.
uint32_t countSize of the array.
bool isClosedWhether the path is closed. The value true means that the path is closed, and false means the opposite.

OH_Drawing_PathAddCircle()

void OH_Drawing_PathAddCircle(OH_Drawing_Path* path,float x, float y, float radius, OH_Drawing_PathDirection pathDirection)

Description

Adds a circle to a path in the specified direction.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If radius is less than or equal to 0, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.
If pathDirection is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float xX coordinate of the circle center.
float yY coordinate of the circle center.
float radiusRadius of the circle.
OH_Drawing_PathDirection pathDirectionOH_Drawing_PathDirection object.

OH_Drawing_PathBuildFromSvgString()

bool OH_Drawing_PathBuildFromSvgString(OH_Drawing_Path* path, const char* str)

Description

Parses the path represented by an SVG string.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or str is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
const char* strPointer to the SVG string.

Returns

TypeDescription
boolReturns whether the SVG string is successfully parsed. true means successful; false otherwise.

OH_Drawing_PathContains()

bool OH_Drawing_PathContains(OH_Drawing_Path* path, float x, float y)

Description

Checks whether a coordinate point is included in this path. For details, see OH_Drawing_PathFillType.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float xCoordinate point on the X axis.
float yCoordinate point on the Y axis.

Returns

TypeDescription
boolReturns true if the coordinate point is included in the path; returns false otherwise.

OH_Drawing_PathTransform()

void OH_Drawing_PathTransform(OH_Drawing_Path* path, const OH_Drawing_Matrix* matrix)

Description

Transforms the points in a path by matrix.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or matrix is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
const OH_Drawing_Matrix* matrixPointer to the OH_Drawing_Matrix object.

OH_Drawing_PathTransformWithPerspectiveClip()

void OH_Drawing_PathTransformWithPerspectiveClip(OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix,OH_Drawing_Path* dst, bool applyPerspectiveClip)

Description

Transforms the points in a path by matrix, and uses the new one to replace the dst path. If dst is NULL, the src path is replaced.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either src or matrix is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* srcPointer to the OH_Drawing_Path object.
const OH_Drawing_Matrix* matrixPointer to the OH_Drawing_Matrix object.
OH_Drawing_Path* dstPointer to the target OH_Drawing_Path object.
bool applyPerspectiveClipWhether to apply perspective cropping to the new path. The value true means to apply perspective cropping, and false means the opposite.

OH_Drawing_PathSetFillType()

void OH_Drawing_PathSetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType pathFillType)

Description

Sets the fill type of a path. The fill type determines how "inside" of the path is drawn.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If pathFillType is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
OH_Drawing_PathFillType pathFillTypeOH_Drawing_PathFillType object.

OH_Drawing_PathGetFillType()

OH_Drawing_ErrorCode OH_Drawing_PathGetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType* pathFillType)

Description

Obtains the fill type of a path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
OH_Drawing_PathFillType* pathFillTypePointer to the OH_Drawing_PathFillType object.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if path or pathFillType is NULL.

OH_Drawing_PathGetLength()

float OH_Drawing_PathGetLength(OH_Drawing_Path* path, bool forceClosed)

Description

Obtains the length of a path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
bool forceClosedWhether the path is measured as a closed path. true means that the path is forcibly considered as a closed path; false means that the path is measured depending on whether it is a closed path.

Returns

TypeDescription
floatReturns the length of the path.

OH_Drawing_PathGetBounds()

void OH_Drawing_PathGetBounds(OH_Drawing_Path* path, OH_Drawing_Rect* rect)

Description

Obtains the minimum bounds that enclose a path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.

OH_Drawing_PathClose()

void OH_Drawing_PathClose(OH_Drawing_Path* path)

Description

Draws a line segment from the current point to the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.

OH_Drawing_PathOffset()

void OH_Drawing_PathOffset(OH_Drawing_Path* path, OH_Drawing_Path* dst, float dx, float dy)

Description

Translates a path by an offset along the X axis and Y axis and adds the new one to the dst path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the existing OH_Drawing_Path object.
OH_Drawing_Path* dstPointer to a destination path, which is an OH_Drawing_Path object. If NULL is passed in, the result is stored in the current path.
float dxX offset.
float dyY offset.

OH_Drawing_PathReset()

void OH_Drawing_PathReset(OH_Drawing_Path* path)

Description

Resets the path data.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object.

OH_Drawing_PathIsClosed()

bool OH_Drawing_PathIsClosed(OH_Drawing_Path* path, bool forceClosed)

Description

Checks whether a path is closed.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If path is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
bool forceClosedWhether the path is measured as a closed path. The value true means that the path is considered closed during measurement, and false means that the path is measured based on the actual closed status.

Returns

TypeDescription
boolReturns true if the path is closed; returns false otherwise.

OH_Drawing_PathGetPositionTangent()

bool OH_Drawing_PathGetPositionTangent(OH_Drawing_Path* path, bool forceClosed,float distance, OH_Drawing_Point2D* position, OH_Drawing_Point2D* tangent)

Description

Obtains the coordinates and tangent at a distance from the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If any of path, position, or tangent is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
bool forceClosedWhether the path is measured as a closed path. The value true means that the path is considered closed during measurement, and false means that the path is measured based on the actual closed status.
float distanceDistance from the start point. If the distance is less than 0, it is considered as 0. If the distance is greater than the path length, it is considered as the path length.
OH_Drawing_Point2D* positionPointer to the coordinates.
OH_Drawing_Point2D* tangentPointer to the tangent, where tangent.x and tangent.y represent the cosine and sine of the tangent of the point, respectively.

Returns

TypeDescription
boolReturns whether the measurement is successful. true means successful; false otherwise.

OH_Drawing_PathGetSegment()

OH_Drawing_ErrorCode OH_Drawing_PathGetSegment(OH_Drawing_Path* path, bool forceClosed,float start, float stop, bool startWithMoveTo, OH_Drawing_Path* dst, bool* result)

Description

Extracts a segment of a path and appends it to a destination path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
bool forceClosedWhether the path is measured as a closed path. The value true means that the path is considered closed during measurement, and false means that the path is measured based on the actual closed status.
float startDistance from the start point of the path to the start point of the segment. If it is less than 0, it defaults to 0. If it is greater than or equal to stop, the extraction fails.
float stopDistance from the start point of the path to the end point of the segment. If it is less than or equal to start, the extraction fails. If it is greater than the path length, it defaults to the path length.
bool startWithMoveToWhether to execute OH_Drawing_PathMoveTo in the destination path to move to its start point. The value true means to move to the start point, and false means the opposite.
OH_Drawing_Path* dstPointer to a destination path, which is an OH_Drawing_Path object. If the extraction succeeds, the segment is appended to the path. If the extraction fails, nothing changes.
bool* resultPointer to the extraction result. The value true means that the extraction is successful, and false means the opposite. It as an output parameter.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns one of the following result codes:
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if at least one of the path, dst, and result parameters is a null pointer.

OH_Drawing_PathOp()

bool OH_Drawing_PathOp(OH_Drawing_Path* path, const OH_Drawing_Path* other, OH_Drawing_PathOpMode op)

Description

Combines two paths based on the specified operation mode.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or srcPath is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If op is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to an OH_Drawing_Path object, in which the resulting path is saved.
const OH_Drawing_Path* otherPointer to the OH_Drawing_Path object.
OH_Drawing_PathOpMode opOperation mode of the path. For details about the available options, see OH_Drawing_PathOpMode.

Returns

TypeDescription
boolReturns true if the resulting path is not empty; returns false otherwise.

OH_Drawing_PathGetMatrix()

bool OH_Drawing_PathGetMatrix(OH_Drawing_Path* path, bool forceClosed,float distance, OH_Drawing_Matrix* matrix, OH_Drawing_PathMeasureMatrixFlags flag)

Description

Obtains a transformation matrix at a distance from the start point of this path.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either path or matrix is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
If flag is not set to one of the enumerated values, OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
bool forceClosedWhether the path is measured as a closed path. The value true means that the path is considered closed during measurement, and false means that the path is measured based on the actual closed status.
float distanceDistance from the start point. If the distance is less than 0, it is considered as 0. If the distance is greater than the path length, it is considered as the path length.
OH_Drawing_Matrix* matrixPointer to the transformation matrix.
OH_Drawing_PathMeasureMatrixFlags flagType of the matrix information. For details about the available options, see OH_Drawing_PathMeasureMatrixFlags.

Returns

TypeDescription
boolReturns true if the transformation matrix is obtained successfully; returns false otherwise. The possible failure cause is that path is NULL or the path length is 0.

OH_Drawing_PathApproximate()

OH_Drawing_ErrorCode OH_Drawing_PathApproximate(OH_Drawing_Path* path, float acceptableError, float* vals,uint32_t* count)

Description

Converts the existing path into an approximate path consisting of consecutive line segments.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
float acceptableErrorAcceptable error of each line segment on the path. The value cannot be less than 0.
1. Avoid setting acceptableError to 0 as it heavily divides the curve path, significantly impacting performance and memory usage.
2. Setting a high acceptableError simplifies the path greatly by keeping only essential points, potentially distorting the original shape.
3. When you set a high acceptableError for curves such as ellipses, the fitting process often simplifies them to polygons by keeping just the start and end points of their Bezier curve segments.
float* valsAn array of approximate points of the path.
Each point consists of three values, indicating:
1. Length ratio of the point to the start point of the path.
2. X coordinate of the point.
3. Y coordinate of the point.
uint32_t* countSize of the returned array, which is at least 6. The size of the point array after fitting is returned if vals is a null pointer.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if path or count is a null pointer.
OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE if acceptableError is less than 0.

OH_Drawing_PathInterpolate()

OH_Drawing_ErrorCode OH_Drawing_PathInterpolate(OH_Drawing_Path* path, OH_Drawing_Path* other,float weight, bool* success, OH_Drawing_Path* interpolatedPath)

Description

Interpolates between the existing path and another path based on the given weight and stores the result in the target path object.
Interpolation is achievable if the two paths have the same number of points. The target path is created based on the structure of the existing path.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
OH_Drawing_Path* otherPointer to the OH_Drawing_Path object of the other path used for interpolation.
float weightInterpolation weight. The value range is [0, 1].
bool* successWhether the interpolation is successful. true means yes; false otherwise. It as an output parameter.
OH_Drawing_Path* interpolatedPathPointer to the OH_Drawing_Path object used to store the interpolation result.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if path, other, success, or interpolatedPath is a null pointer.
OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE if weight is not in the range of [0, 1].

OH_Drawing_PathIsInterpolate()

OH_Drawing_ErrorCode OH_Drawing_PathIsInterpolate(OH_Drawing_Path* path, OH_Drawing_Path* other, bool* result)

Description

Checks whether the existing path and another path (other) are compatible for interpolation in terms of structure and operation sequence.
If the paths contain conic operations, the weight values of the operations must be the same.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
OH_Drawing_Path* otherPointer to the OH_Drawing_Path object.
bool* resultChecks whether a path is compatible with another path. It is used as an output parameter.
true if the paths are compatible, false otherwise.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if path, other, or result is a null pointer.

OH_Drawing_PathIsInverseFillType()

OH_Drawing_ErrorCode OH_Drawing_PathIsInverseFillType(const OH_Drawing_Path* path, bool* isInverse)

Description

Checks whether the fill type of the path is the inverse type.

The inverse type is PATH_FILL_TYPE_INVERSE_WINDING and PATH_FILL_TYPE_INVERSE_EVEN_ODD in OH_Drawing_PathFillType.

Since: 23

Parameters

NameDescription
const OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.
bool* isInverseWhether the fill type is the inverse type. It is used as an output parameter. true if the fill type is the inverse type; false otherwise.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if path or isInverse is a null pointer.

OH_Drawing_PathToggleInverseFillType()

OH_Drawing_ErrorCode OH_Drawing_PathToggleInverseFillType(OH_Drawing_Path* path)

Description

Toggles the fill type of the path to the inverse type.

The inverse type is PATH_FILL_TYPE_INVERSE_WINDING and PATH_FILL_TYPE_INVERSE_EVEN_ODD in OH_Drawing_PathFillType.

Since: 23

Parameters

NameDescription
OH_Drawing_Path* pathPointer to the OH_Drawing_Path object.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if path is a null pointer.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drawing-gpu-context-h

openharmony 鸿蒙 capi-drawing-nativepixelmap-

openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange

openharmony 鸿蒙 capi-drawing-oh-drawing-brush

openharmony 鸿蒙 capi-drawing-oh-drawing-image-info

openharmony 鸿蒙 capi-drawing-text-linetypography-h

openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage

openharmony 鸿蒙 capi-drawing-typeface-h

openharmony 鸿蒙 capi-drawing-brush-h

openharmony 鸿蒙 capi-nativewindow

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/3EeI0fxa