1 /* 2 * Copyright (c) 2021-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup Drawing 18 * @{ 19 * 20 * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 21 * 22 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 23 * 24 * @since 8 25 * @version 1.0 26 */ 27 28 /** 29 * @file drawing_path.h 30 * 31 * @brief Declares functions related to the <b>path</b> object in the drawing module. 32 * 33 * @kit ArkGraphics2D 34 * @library libnative_drawing.so 35 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 36 * @since 8 37 * @version 1.0 38 */ 39 40 #ifndef C_INCLUDE_DRAWING_PATH_H 41 #define C_INCLUDE_DRAWING_PATH_H 42 43 #include "drawing_error_code.h" 44 #include "drawing_types.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief Direction for adding closed contours. 52 * 53 * @since 12 54 * @version 1.0 55 */ 56 typedef enum { 57 /** clockwise direction for adding closed contours */ 58 PATH_DIRECTION_CW, 59 /** counter-clockwise direction for adding closed contours */ 60 PATH_DIRECTION_CCW, 61 } OH_Drawing_PathDirection; 62 63 /** 64 * @brief FillType of path. 65 * 66 * @since 12 67 * @version 1.0 68 */ 69 typedef enum { 70 /** Specifies that "inside" is computed by a non-zero sum of signed edge crossings */ 71 PATH_FILL_TYPE_WINDING, 72 /** Specifies that "inside" is computed by an odd number of edge crossings */ 73 PATH_FILL_TYPE_EVEN_ODD, 74 /** Same as Winding, but draws outside of the path, rather than inside */ 75 PATH_FILL_TYPE_INVERSE_WINDING, 76 /** Same as EvenOdd, but draws outside of the path, rather than inside */ 77 PATH_FILL_TYPE_INVERSE_EVEN_ODD, 78 } OH_Drawing_PathFillType; 79 80 /** 81 * @brief Add mode of path. 82 * 83 * @since 12 84 * @version 1.0 85 */ 86 typedef enum { 87 /** Appended to destination unaltered */ 88 PATH_ADD_MODE_APPEND, 89 /** Add line if prior contour is not closed */ 90 PATH_ADD_MODE_EXTEND, 91 } OH_Drawing_PathAddMode; 92 93 /** 94 * @brief Operations when two paths are combined. 95 * 96 * @since 12 97 * @version 1.0 98 */ 99 typedef enum { 100 /** 101 * Difference operation. 102 */ 103 PATH_OP_MODE_DIFFERENCE, 104 /** 105 * Intersect operation. 106 */ 107 PATH_OP_MODE_INTERSECT, 108 /** 109 * Union operation. 110 */ 111 PATH_OP_MODE_UNION, 112 /** 113 * Xor operation. 114 */ 115 PATH_OP_MODE_XOR, 116 /** 117 * Reverse difference operation. 118 */ 119 PATH_OP_MODE_REVERSE_DIFFERENCE, 120 } OH_Drawing_PathOpMode; 121 122 /** 123 * @brief Enumerates the matrix information corresponding to the path measurements. 124 * 125 * @since 12 126 * @version 1.0 127 */ 128 typedef enum { 129 /** 130 * Gets position. 131 */ 132 GET_POSITION_MATRIX, 133 /** 134 * Gets tangent. 135 */ 136 GET_TANGENT_MATRIX, 137 /** 138 * Gets both position and tangent. 139 */ 140 GET_POSITION_AND_TANGENT_MATRIX, 141 } OH_Drawing_PathMeasureMatrixFlags; 142 143 /** 144 * @brief Creates an <b>OH_Drawing_Path</b> object. 145 * 146 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 147 * @return Returns the pointer to the <b>OH_Drawing_Path</b> object created. 148 * @since 8 149 * @version 1.0 150 */ 151 OH_Drawing_Path* OH_Drawing_PathCreate(void); 152 153 /** 154 * @brief Creates an <b>OH_Drawing_Path</b> copy object. 155 * 156 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 157 * @param path Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 158 * @return Returns the pointer to the <b>OH_Drawing_Path</b> object created. 159 * @since 12 160 * @version 1.0 161 */ 162 OH_Drawing_Path* OH_Drawing_PathCopy(OH_Drawing_Path* path); 163 164 /** 165 * @brief Destroys an <b>OH_Drawing_Path</b> object and reclaims the memory occupied by the object. 166 * 167 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 168 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 169 * @since 8 170 * @version 1.0 171 */ 172 void OH_Drawing_PathDestroy(OH_Drawing_Path* path); 173 174 /** 175 * @brief Sets <b>OH_Drawing_Path</b> object with the same content of another. 176 * 177 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 178 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 179 * @param other Indicates the pointer to an <b>OH_Drawing_Path</b> object to copy content from. 180 * @return Returns the error code. 181 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 182 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if path or other is nullptr. 183 * @since 20 184 * @version 1.0 185 */ 186 OH_Drawing_ErrorCode OH_Drawing_PathSetPath(OH_Drawing_Path* path, OH_Drawing_Path* other); 187 188 /** 189 * @brief Checks if <b>OH_Drawing_Path</b> object is empty. 190 * 191 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 192 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 193 * @param isEmpty Indicates the return value. 194 * @return Returns the error code. 195 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 196 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if path or isEmpty is nullptr. 197 * @since 20 198 * @version 1.0 199 */ 200 OH_Drawing_ErrorCode OH_Drawing_PathIsEmpty(OH_Drawing_Path* path, bool* isEmpty); 201 202 /** 203 * @brief Checks if <b>OH_Drawing_Path</b> represents a rectangle. 204 * 205 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 206 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 207 * @param rect Indicates the Pointer to an <b>OH_Drawing_Rect</b> object. 208 * @param isRect Indicates the return value. 209 * @return Returns the error code. 210 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 211 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if path or isRect is nullptr. 212 * @since 20 213 * @version 1.0 214 */ 215 OH_Drawing_ErrorCode OH_Drawing_PathIsRect(OH_Drawing_Path* path, OH_Drawing_Rect* rect, bool* isRect); 216 217 /** 218 * @brief Sets the start point of a path. 219 * 220 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 221 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 222 * @param x Indicates the x coordinate of the start point. 223 * @param y Indicates the y coordinate of the start point. 224 * @since 8 225 * @version 1.0 226 */ 227 void OH_Drawing_PathMoveTo(OH_Drawing_Path* path, float x, float y); 228 229 /** 230 * @brief Draws a line segment from the last point of a path to the target point. 231 * 232 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 233 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 234 * @param x Indicates the x coordinate of the target point. 235 * @param y Indicates the y coordinate of the target point. 236 * @since 8 237 * @version 1.0 238 */ 239 void OH_Drawing_PathLineTo(OH_Drawing_Path* path, float x, float y); 240 241 /** 242 * @brief Draws an arc to a path. 243 * 244 * This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, 245 * and then a start angle and a sweep angle are specified. 246 * The arc is a portion of the ellipse defined by the start angle and the sweep angle. 247 * By default, a line segment from the last point of the path to the start point of the arc is also added. 248 * 249 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 250 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 251 * @param x1 Indicates the x coordinate of the upper left corner of the rectangle. 252 * @param y1 Indicates the y coordinate of the upper left corner of the rectangle. 253 * @param x2 Indicates the x coordinate of the lower right corner of the rectangle. 254 * @param y2 Indicates the y coordinate of the lower right corner of the rectangle. 255 * @param startDeg Indicates the start angle, in degrees. 256 * @param sweepDeg Indicates the angle to sweep, in degrees. 257 * @since 8 258 * @version 1.0 259 */ 260 void OH_Drawing_PathArcTo(OH_Drawing_Path* path, 261 float x1, float y1, float x2, float y2, float startDeg, float sweepDeg); 262 263 /** 264 * @brief Draws a quadratic Bezier curve from the last point of a path to the target point. 265 * 266 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 267 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 268 * @param ctrlX Indicates the x coordinate of the control point. 269 * @param ctrlY Indicates the y coordinate of the control point. 270 * @param endX Indicates the x coordinate of the target point. 271 * @param endY Indicates the y coordinate of the target point. 272 * @since 8 273 * @version 1.0 274 */ 275 void OH_Drawing_PathQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY); 276 277 /** 278 * @brief Draws a conic from the last point of a path to the target point. 279 * 280 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 281 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 282 * @param ctrlX Indicates the x coordinate of the control point. 283 * @param ctrlY Indicates the y coordinate of the control point. 284 * @param endX Indicates the x coordinate of the target point. 285 * @param endY Indicates the y coordinate of the target point. 286 * @param weight Indicates the weight of added conic. 287 * @since 12 288 * @version 1.0 289 */ 290 void OH_Drawing_PathConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight); 291 292 /** 293 * @brief Draws a cubic Bezier curve from the last point of a path to the target point. 294 * 295 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 296 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 297 * @param ctrlX1 Indicates the x coordinate of the first control point. 298 * @param ctrlY1 Indicates the y coordinate of the first control point. 299 * @param ctrlX2 Indicates the x coordinate of the second control point. 300 * @param ctrlY2 Indicates the y coordinate of the second control point. 301 * @param endX Indicates the x coordinate of the target point. 302 * @param endY Indicates the y coordinate of the target point. 303 * @since 8 304 * @version 1.0 305 */ 306 void OH_Drawing_PathCubicTo( 307 OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY); 308 309 /** 310 * @brief Sets the relative starting point of a path. 311 * 312 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 313 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 314 * @param x Indicates the x coordinate of the relative starting point. 315 * @param y Indicates the y coordinate of the relative starting point. 316 * @since 12 317 * @version 1.0 318 */ 319 void OH_Drawing_PathRMoveTo(OH_Drawing_Path* path, float x, float y); 320 321 /** 322 * @brief Draws a line segment from the last point of a path to the relative target point. 323 * 324 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 325 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 326 * @param x Indicates the x coordinate of the relative target point. 327 * @param y Indicates the y coordinate of the relative target point. 328 * @since 12 329 * @version 1.0 330 */ 331 void OH_Drawing_PathRLineTo(OH_Drawing_Path* path, float x, float y); 332 333 /** 334 * @brief Draws a quadratic bezier curve from the last point of a path to the relative target point. 335 * 336 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 337 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 338 * @param ctrlX Indicates the x coordinate of the relative control point. 339 * @param ctrlY Indicates the y coordinate of the relative control point. 340 * @param endX Indicates the x coordinate of the relative target point. 341 * @param endY Indicates the y coordinate of the relative target point. 342 * @since 12 343 * @version 1.0 344 */ 345 void OH_Drawing_PathRQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY); 346 347 /** 348 * @brief Draws a conic from the last point of a path to the relative target point. 349 * 350 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 351 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 352 * @param ctrlX Indicates the x coordinate of the relative control point. 353 * @param ctrlY Indicates the y coordinate of the relative control point. 354 * @param endX Indicates the x coordinate of the relative target point. 355 * @param endY Indicates the y coordinate of the relative target point. 356 * @param weight Indicates the weight of added conic. 357 * @since 12 358 * @version 1.0 359 */ 360 void OH_Drawing_PathRConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight); 361 362 /** 363 * @brief Draws a cubic bezier curve from the last point of a path to the relative target point. 364 * 365 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 366 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 367 * @param ctrlX1 Indicates the x coordinate of the first relative control point. 368 * @param ctrlY1 Indicates the y coordinate of the first relative control point. 369 * @param ctrlX2 Indicates the x coordinate of the second relative control point. 370 * @param ctrlY2 Indicates the y coordinate of the second relative control point. 371 * @param endX Indicates the x coordinate of the relative target point. 372 * @param endY Indicates the y coordinate of the relative target point. 373 * @since 12 374 * @version 1.0 375 */ 376 void OH_Drawing_PathRCubicTo(OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, 377 float endX, float endY); 378 379 /** 380 * @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction. 381 * 382 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 383 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 384 * @param left Indicates the left coordinate of the upper left corner of the rectangle. 385 * @param top Indicates the top coordinate of the upper top corner of the rectangle. 386 * @param right Indicates the right coordinate of the lower right corner of the rectangle. 387 * @param bottom Indicates the bottom coordinate of the lower bottom corner of the rectangle. 388 * @param pathDirection Indicates the path direction. 389 * @since 12 390 * @version 1.0 391 */ 392 void OH_Drawing_PathAddRect(OH_Drawing_Path* path, float left, float top, float right, float bottom, 393 OH_Drawing_PathDirection pathDirection); 394 395 /** 396 * @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction. 397 * 398 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 399 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 400 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 401 * @param pathDirection Indicates the path direction. 402 * @param start Indicates initial corner of rect to add. 403 * @since 12 404 * @version 1.0 405 */ 406 void OH_Drawing_PathAddRectWithInitialCorner(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, 407 OH_Drawing_PathDirection pathDirection, uint32_t start); 408 409 /** 410 * @brief Adds a new contour to the path, defined by the round rect, and wound in the specified direction. 411 * 412 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 413 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 414 * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object. 415 * @param pathDirection Indicates the path direction. 416 * @since 12 417 * @version 1.0 418 */ 419 void OH_Drawing_PathAddRoundRect(OH_Drawing_Path* path, 420 const OH_Drawing_RoundRect* roundRect, OH_Drawing_PathDirection pathDirection); 421 422 /** 423 * @brief Adds a oval to the path, defined by the rect, and wound in the specified direction. 424 * 425 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 426 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 427 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 428 * @param start Index of initial point of ellipse. 429 * @param pathDirection Indicates the path direction. 430 * @since 12 431 * @version 1.0 432 */ 433 void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, 434 uint32_t start, OH_Drawing_PathDirection pathDirection); 435 436 /** 437 * @brief Adds a oval to the path, defined by the rect, and wound in the specified direction. 438 * 439 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 440 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 441 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 442 * @param pathDirection Indicates the path direction. 443 * @since 12 444 * @version 1.0 445 */ 446 void OH_Drawing_PathAddOval(OH_Drawing_Path* path, 447 const OH_Drawing_Rect* rect, OH_Drawing_PathDirection pathDirection); 448 449 /** 450 * @brief Appends arc to path, as the start of new contour.Arc added is part of ellipse bounded by oval, 451 * from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees 452 * is aligned with the positive x-axis, and positive sweeps extends arc clockwise.If sweepAngle <= -360, or 453 * sweepAngle >= 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle 454 * values are treated modulo 360, and arc may or may not draw depending on numeric rounding. 455 * 456 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 457 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 458 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 459 * @param startAngle Indicates the starting angle of arc in degrees. 460 * @param sweepAngle Indicates the sweep, in degrees. Positive is clockwise. 461 * @since 12 462 * @version 1.0 463 */ 464 void OH_Drawing_PathAddArc(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, float startAngle, float sweepAngle); 465 466 /** 467 * @brief Appends src path to path, transformed by matrix. Transformed curves may have different verbs, 468 * point, and conic weights. 469 * 470 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 471 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 472 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 473 * @param matrix Indicates the length of the <b>OH_Drawing_Matrix</b> object. 474 * @since 12 475 * @version 1.0 476 */ 477 void OH_Drawing_PathAddPath(OH_Drawing_Path* path, const OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix); 478 479 /** 480 * @brief Appends src path to path, transformed by matrix and mode. Transformed curves may have different verbs, 481 * point, and conic weights. 482 * 483 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 484 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 485 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 486 * @param matrix Indicates the length of the <b>OH_Drawing_Matrix</b> object. 487 * @param pathAddMode Indicates the add path's add mode. 488 * @since 12 489 * @version 1.0 490 */ 491 void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, 492 const OH_Drawing_Matrix* matrix, OH_Drawing_PathAddMode pathAddMode); 493 494 /** 495 * @brief Appends src path to path, transformed by mode. Transformed curves may have different verbs, 496 * point, and conic weights. 497 * 498 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 499 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 500 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object, which is Appends src path to path. 501 * @param pathAddMode Indicates the add path's add mode. 502 * @since 12 503 * @version 1.0 504 */ 505 void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* path, 506 const OH_Drawing_Path* src, OH_Drawing_PathAddMode pathAddMode); 507 508 /** 509 * @brief Appends src path to path, transformed by offset and mode. Transformed curves may have different verbs, 510 * point, and conic weights. 511 * 512 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 513 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 514 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 515 * @param dx Indicates offset added to src path x-axis coordinates. 516 * @param dy Indicates offset added to src path y-axis coordinates. 517 * @param pathAddMode Indicates the add path's add mode. 518 * @since 12 519 * @version 1.0 520 */ 521 void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, float dx, float dy, 522 OH_Drawing_PathAddMode pathAddMode); 523 524 /** 525 * @brief Adds contour created from point array, adding (count - 1) line segments. 526 * 527 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 528 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 529 * @param points Indicates the point array. 530 * @param count Indicates the size of point array. 531 * @param isClosed Indicates Whether to add lines that connect the end and start. 532 * @since 12 533 * @version 1.0 534 */ 535 void OH_Drawing_PathAddPolygon(OH_Drawing_Path* path, const OH_Drawing_Point2D* points, uint32_t count, bool isClosed); 536 537 /** 538 * @brief Adds a circle to the path, and wound in the specified direction. 539 * 540 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 541 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 542 * @param x Indicates the x coordinate of the center of the circle. 543 * @param y Indicates the y coordinate of the center of the circle. 544 * @param radius Indicates the radius of the circle. 545 * @param pathDirection Indicates the path direction. 546 * @since 12 547 * @version 1.0 548 */ 549 void OH_Drawing_PathAddCircle(OH_Drawing_Path* path, 550 float x, float y, float radius, OH_Drawing_PathDirection pathDirection); 551 552 /** 553 * @brief Parses the svg path from the string. 554 * 555 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 556 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 557 * @param str Indicates the string of the SVG path. 558 * @return Returns true if build path is successful, returns false otherwise. 559 * @since 12 560 * @version 1.0 561 */ 562 bool OH_Drawing_PathBuildFromSvgString(OH_Drawing_Path* path, const char* str); 563 564 /** 565 * @brief Return the status that point (x, y) is contained by path. 566 * 567 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 568 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 569 * @param x Indicates the x-axis value of containment test. 570 * @param y Indicates the y-axis value of containment test. 571 * @return Returns true if the point (x, y) is contained by path. 572 * @since 12 573 * @version 1.0 574 */ 575 bool OH_Drawing_PathContains(OH_Drawing_Path* path, float x, float y); 576 577 /** 578 * @brief Transforms verb array, point array, and weight by matrix. transform may change verbs 579 * and increase their number. path is replaced by transformed data. 580 * 581 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 582 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 583 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 584 * @since 12 585 * @version 1.0 586 */ 587 void OH_Drawing_PathTransform(OH_Drawing_Path* path, const OH_Drawing_Matrix* matrix); 588 589 /** 590 * @brief Transforms verb array, point array, and weight by matrix. 591 * Transform may change verbs and increase their number. 592 * 593 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 594 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 595 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 596 * @param dst Indicates the pointer to an <b>OH_Drawing_Path</b> object. 597 * @param applyPerspectiveClip Indicates whether to apply perspective clip. 598 * @since 12 599 * @version 1.0 600 */ 601 void OH_Drawing_PathTransformWithPerspectiveClip(OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix, 602 OH_Drawing_Path* dst, bool applyPerspectiveClip); 603 604 /** 605 * @brief Sets FillType, the rule used to fill path. 606 * 607 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 608 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 609 * @param pathFillType Indicates the add path's fill type. 610 * @since 12 611 * @version 1.0 612 */ 613 void OH_Drawing_PathSetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType pathFillType); 614 615 /** 616 * @brief Gets FillType, the rule used to fill path. 617 * 618 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 619 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 620 * @param pathFillType Indicates the FillType apply to path. 621 * @return Returns the error code. 622 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 623 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if path or pathFillType is nullptr. 624 * @since 20 625 * @version 1.0 626 */ 627 OH_Drawing_ErrorCode OH_Drawing_PathGetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType* pathFillType); 628 629 /** 630 * @brief Gets the length of the current path object. 631 * 632 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 633 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 634 * @param forceClosed Indicates whether free to modify/delete the path after this call. 635 * @return Returns the length of the current path object. 636 * @since 12 637 * @version 1.0 638 */ 639 float OH_Drawing_PathGetLength(OH_Drawing_Path* path, bool forceClosed); 640 641 /** 642 * @brief Gets the smallest bounding box that contains the path. 643 * 644 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 645 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 646 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 647 * @since 12 648 * @version 1.0 649 */ 650 void OH_Drawing_PathGetBounds(OH_Drawing_Path* path, OH_Drawing_Rect* rect); 651 652 /** 653 * @brief Closes a path. A line segment from the start point to the last point of the path is added. 654 * 655 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 656 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 657 * @since 8 658 * @version 1.0 659 */ 660 void OH_Drawing_PathClose(OH_Drawing_Path* path); 661 662 /** 663 * @brief Offset path replaces dst. 664 * 665 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 666 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 667 * @param dst Indicates the pointer to an <b>OH_Drawing_Path</b> object. 668 * @param dx Indicates offset added to dst path x-axis coordinates. 669 * @param dy Indicates offset added to dst path y-axis coordinates. 670 * @since 12 671 * @version 1.0 672 */ 673 void OH_Drawing_PathOffset(OH_Drawing_Path* path, OH_Drawing_Path* dst, float dx, float dy); 674 675 /** 676 * @brief Resets path data. 677 * 678 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 679 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 680 * @since 8 681 * @version 1.0 682 */ 683 void OH_Drawing_PathReset(OH_Drawing_Path* path); 684 685 /** 686 * @brief Determines whether the path current contour is closed. 687 * 688 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 689 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 690 * @param forceClosed Whether to close the Path. 691 * @return Returns <b>true</b> if the path current contour is closed; returns <b>false</b> otherwise. 692 * @since 12 693 * @version 1.0 694 */ 695 bool OH_Drawing_PathIsClosed(OH_Drawing_Path* path, bool forceClosed); 696 697 /** 698 * @brief Gets the position and tangent of the distance from the starting position of the Path. 699 * 700 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 701 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 702 * @param forceClosed Whether to close the Path. 703 * @param distance The distance from the start of the Path. 704 * @param position Sets to the position of distance from the starting position of the Path. 705 * @param tangent Sets to the tangent of distance from the starting position of the Path. 706 * @return Returns <b>true</b> if succeeded; returns <b>false</b> otherwise. 707 * @since 12 708 * @version 1.0 709 */ 710 bool OH_Drawing_PathGetPositionTangent(OH_Drawing_Path* path, bool forceClosed, 711 float distance, OH_Drawing_Point2D* position, OH_Drawing_Point2D* tangent); 712 713 /** 714 * @brief Gets the path between the start and end points. 715 * 716 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 717 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 718 * @param forceClosed Whether to close the path. 719 * @param start The distance from the starting point of the segment to the starting point of the path. 720 * @param stop The distance from the end point of the segment to the starting point of the path. 721 * @param startWithMoveTo Whether the path obtained moveTo to the starting segment. 722 * @param dst The path obtained. 723 * @param result Indicates the result of getting the path segment. 724 * The value is false if the segment is zero-length or start >= stop, and true otherwise. 725 * @return Returns the error code. 726 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 727 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of path, dst and result is nullptr. 728 * @since 18 729 * @version 1.0 730 */ 731 OH_Drawing_ErrorCode OH_Drawing_PathGetSegment(OH_Drawing_Path* path, bool forceClosed, 732 float start, float stop, bool startWithMoveTo, OH_Drawing_Path* dst, bool* result); 733 734 /** 735 * @brief Combines two paths. 736 * 737 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 738 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 739 * @param other Indicates the pointer to an <b>OH_Drawing_Path</b> object. 740 * @param op Indicates the operation to apply to combine. 741 * @return Returns <b>true</b> if constructed path is not empty; returns <b>false</b> otherwise. 742 * @since 12 743 * @version 1.0 744 */ 745 bool OH_Drawing_PathOp(OH_Drawing_Path* path, const OH_Drawing_Path* other, OH_Drawing_PathOpMode op); 746 747 /** 748 * @brief Computes the corresponding matrix at the specified distance. 749 * 750 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 751 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 752 * @param forceClosed Whether to close the Path. 753 * @param distance The distance from the start of the Path. 754 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 755 * @param flag Indicates what should be returned in the matrix. 756 * @return Returns <b>false</b> if path is nullptr or zero-length; 757 returns <b>true</b> if path is not nullptr and not zero-length. 758 * @since 12 759 * @version 1.0 760 */ 761 bool OH_Drawing_PathGetMatrix(OH_Drawing_Path* path, bool forceClosed, 762 float distance, OH_Drawing_Matrix* matrix, OH_Drawing_PathMeasureMatrixFlags flag); 763 764 /** 765 * @brief Approximates the path with a series of line segments. 766 * 767 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 768 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 769 * @param acceptableError Indicates the acceptable error for a line on the path. Should be no less than 0. 770 * @param vals Indicates the storage for the computed array containing point components. 771 * There are three components for each point: 772 * 1.Fraction along the length of the path that the point resides. 773 * 2.The x coordinate of the point. 774 * 3.The y coordinate of the point. 775 * @param count Returns with the size of array. 776 * @return Returns the error code. 777 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 778 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if path or count is nullptr. 779 * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if acceptableError is less than 0. 780 * @since 20 781 * @version 1.0 782 */ 783 OH_Drawing_ErrorCode OH_Drawing_PathApproximate(OH_Drawing_Path* path, float acceptableError, float* vals, 784 uint32_t* count); 785 786 /** 787 * @brief Performs interpolation between the current path and another path based on a given weight, and stores the 788 * result in the target path object. 789 * 790 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 791 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 792 * @param other Indicates the pointer to an <b>OH_Drawing_Path</b> object to be interpolated with path. 793 * @param weight Indicates the interpolation weight, which must be in the range [0, 1]. 794 * @param success Indicates the interpolation is success or not. 795 * @param interpolatedPath Indicates the pointer to an <b>OH_Drawing_Path</b> object to store the result. 796 * @return Returns the error code. 797 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 798 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if either path, other, success or interpolatedPath is 799 * nullptr. 800 * Returns {@link OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE} if weight is outside the range [0, 1]. 801 * @since 20 802 * @version 1.0 803 */ 804 OH_Drawing_ErrorCode OH_Drawing_PathInterpolate(OH_Drawing_Path* path, OH_Drawing_Path* other, 805 float weight, bool* success, OH_Drawing_Path* interpolatedPath); 806 807 /** 808 * @brief Checks whether the current path is compatible with another path (other) for interpolation, which means 809 * they have exactly the same structure, both paths must have the same operations, in the same order. 810 * If any of the operations are of type CONIC, then the weights of those conics must also match. 811 * 812 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 813 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 814 * @param other Indicates the pointer to an <b>OH_Drawing_Path</b> object to be interpolated with path. 815 * @param result Indicates whether the current path and the other path are compatible for interpolation. 816 * The value is true if the paths are compatible, and false otherwise. 817 * @return Returns the error code. 818 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 819 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if either path, other or result is nullptr. 820 * @since 20 821 * @version 1.0 822 */ 823 OH_Drawing_ErrorCode OH_Drawing_PathIsInterpolate(OH_Drawing_Path* path, OH_Drawing_Path* other, bool* result); 824 825 #ifdef __cplusplus 826 } 827 #endif 828 /** @} */ 829 #endif 830