diff --git a/graphic/graphic_2d/native_drawing/drawing_path.h b/graphic/graphic_2d/native_drawing/drawing_path.h index d82a70df860cc5b61f39d9495791b9af6ba2ac5d..fac5a2066fc50609af53a214789c520d034796e7 100644 --- a/graphic/graphic_2d/native_drawing/drawing_path.h +++ b/graphic/graphic_2d/native_drawing/drawing_path.h @@ -86,6 +86,56 @@ typedef enum { PATH_ADD_MODE_EXTEND, } OH_Drawing_PathAddMode; +/** + * @brief Operations when two paths are combined. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** + * Difference operation. + */ + PATH_OP_MODE_DIFFERENCE, + /** + * Intersect operation. + */ + PATH_OP_MODE_INTERSECT, + /** + * Union operation. + */ + PATH_OP_MODE_UNION, + /** + * Xor operation. + */ + PATH_OP_MODE_XOR, + /** + * Reverse difference operation. + */ + PATH_OP_MODE_REVERSE_DIFFERENCE, +} OH_Drawing_PathOpMode; + +/** + * @brief What should be returned in the matrix. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** + * Gets position. + */ + GET_POSITION_MATRIX, + /** + * Gets tangent. + */ + GET_TANGENT_MATRIX, + /** + * Gets both position and tangent. + */ + GET_POS_AND_TAN_MATRIX, +} OH_Drawing_PathMeasureMatrixFlags; + /** * @brief Creates an OH_Drawing_Path object. * @@ -516,6 +566,63 @@ void OH_Drawing_PathOffset(OH_Drawing_Path* path, OH_Drawing_Path* dst, float dx */ void OH_Drawing_PathReset(OH_Drawing_Path*); +/** + * @brief Determines whether the path current contour is closed. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path Indicates the pointer to an OH_Drawing_Path object. + * @param forceClosed Whether to close the Path. + * @return Returns true if the path current contour is closed. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_PathIsClosed(OH_Drawing_Path* path, bool forceClosed); + +/** + * @brief Gets the position and tangent of the distance from the starting position of the Path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path Indicates the pointer to an OH_Drawing_Path object. + * @param distance The distance from the start of the Path. + * @param position Sets to the position of distance from the starting position of the Path. + * @param tangent Sets to the tangent of distance from the starting position of the Path. + * @param forceClosed Whether to close the Path. + * @return Returns true if succeeded, otherwise false. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_PathGetPosTan(OH_Drawing_Path* path, bool forceClosed, + float distance, OH_Drawing_Point2D* position, OH_Drawing_Point2D* tangent); + +/** + * @brief Combines two paths. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path Indicates the pointer to an OH_Drawing_Path object. + * @param srcPath Indicates the pointer to an OH_Drawing_Path object. + * @param op Indicates the operation to apply to combine. + * @return Returns true if constructed path is not empty. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_PathOp(OH_Drawing_Path* path, const OH_Drawing_Path* srcPath, OH_Drawing_PathOpMode op); + +/** + * @brief Computes the corresponding matrix at the specified distance. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path Indicates the pointer to an OH_Drawing_Path object. + * @param forceClosed Whether to close the Path. + * @param distance The distance from the start of the Path. + * @param matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param flag Indicates what should be returned in the matrix. + * @return Returns false if path is nullptr or zero-length, otherwise true. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_PathGetMatrix(OH_Drawing_Path* path, bool forceClosed, + float distance, OH_Drawing_Matrix* matrix, OH_Drawing_PathMeasureMatrixFlags flag); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h index b145f999e085bd16ea5919ab203ea43e17c8de15..f40cc94710d48339d1fd2d066d311d2555917c8b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_region.h +++ b/graphic/graphic_2d/native_drawing/drawing_region.h @@ -43,6 +43,39 @@ extern "C" { #endif +/** + * @brief Operations when two regions are combined. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** + * Difference operation. + */ + REGION_OP_MODE_DIFFERENCE, + /** + * Intersect operation. + */ + REGION_OP_MODE_INTERSECT, + /** + * Union operation. + */ + REGION_OP_MODE_UNION, + /** + * Xor operation. + */ + REGION_OP_MODE_XOR, + /** + * Reverse difference operation. + */ + REGION_OP_MODE_REVERSE_DIFFERENCE, + /** + * Replace operation. + */ + REGION_OP_MODE_REPLACE, +} OH_Drawing_RegionOpMode; + /** * @brief Creates an OH_Drawing_Region object. * @@ -53,6 +86,32 @@ extern "C" { */ OH_Drawing_Region* OH_Drawing_RegionCreate(void); +/** + * @brief Determines whether the region contains the specified coordinates. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param region Indicates the pointer to an OH_Drawing_Region object. + * @param int32_t x-coordinate. + * @param int32_t y-coordinate. + * @return Return true if (x, y) is inside region. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_RegionContains(OH_Drawing_Region* region, int32_t x, int32_t y); + +/** + * @brief Combines two regions. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param region Indicates the pointer to an OH_Drawing_Region object. + * @param dst Indicates the pointer to an OH_Drawing_Region object. + * @param op Indicates the operation to apply to combine. + * @return Return true if constructed Region is not empty. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_RegionOp(OH_Drawing_Region* region, const OH_Drawing_Region* dst, OH_Drawing_RegionOpMode op); + /** * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object. * @@ -65,6 +124,19 @@ OH_Drawing_Region* OH_Drawing_RegionCreate(void); */ bool OH_Drawing_RegionSetRect(OH_Drawing_Region* region, const OH_Drawing_Rect* rect); +/** + * @brief Constructs region that matchs outline of path within clip. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param region Indicates the pointer to an OH_Drawing_Region object. + * @param path Indicates the pointer to an OH_Drawing_Path object. + * @param clip Indicates the pointer to an OH_Drawing_Region object. + * @return Return true if constructed Region is not empty. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_RegionSetPath(OH_Drawing_Region* region, const OH_Drawing_Path* path, const OH_Drawing_Region* clip); + /** * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index e41daf79704162c2bff6fbd9146f76e5dbfc9cd9..80a44c280bc6d1ff6f251dddeb5251de2437c861 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -363,6 +363,22 @@ "name": "OH_Drawing_PathOffset" }, { "name": "OH_Drawing_PathReset" }, + { + "first_introduced": "12", + "name": "OH_Drawing_PathIsClosed" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PathGetPosTan" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PathOp" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PathGetMatrix" + }, { "name": "OH_Drawing_PenCreate" }, { "name": "OH_Drawing_PenDestroy" }, { "name": "OH_Drawing_PenGetAlpha" }, @@ -926,6 +942,18 @@ "first_introduced": "12", "name": "OH_Drawing_RegionCreate" }, + { + "first_introduced": "12", + "name": "OH_Drawing_RegionContains" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_RegionOp" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_RegionSetPath" + }, { "first_introduced": "12", "name": "OH_Drawing_RegionDestroy"