1 /* 2 * Copyright (c) 2021-2024 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 the start point of a path. 176 * 177 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 178 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 179 * @param x Indicates the x coordinate of the start point. 180 * @param y Indicates the y coordinate of the start point. 181 * @since 8 182 * @version 1.0 183 */ 184 void OH_Drawing_PathMoveTo(OH_Drawing_Path* path, float x, float y); 185 186 /** 187 * @brief Draws a line segment from the last point of a path to the target point. 188 * 189 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 190 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 191 * @param x Indicates the x coordinate of the target point. 192 * @param y Indicates the y coordinate of the target point. 193 * @since 8 194 * @version 1.0 195 */ 196 void OH_Drawing_PathLineTo(OH_Drawing_Path* path, float x, float y); 197 198 /** 199 * @brief Draws an arc to a path. 200 * 201 * This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, 202 * and then a start angle and a sweep angle are specified. 203 * The arc is a portion of the ellipse defined by the start angle and the sweep angle. 204 * By default, a line segment from the last point of the path to the start point of the arc is also added. 205 * 206 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 207 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 208 * @param x1 Indicates the x coordinate of the upper left corner of the rectangle. 209 * @param y1 Indicates the y coordinate of the upper left corner of the rectangle. 210 * @param x2 Indicates the x coordinate of the lower right corner of the rectangle. 211 * @param y2 Indicates the y coordinate of the lower right corner of the rectangle. 212 * @param startDeg Indicates the start angle, in degrees. 213 * @param sweepDeg Indicates the angle to sweep, in degrees. 214 * @since 8 215 * @version 1.0 216 */ 217 void OH_Drawing_PathArcTo(OH_Drawing_Path* path, 218 float x1, float y1, float x2, float y2, float startDeg, float sweepDeg); 219 220 /** 221 * @brief Draws a quadratic Bezier curve from the last point of a path to the target point. 222 * 223 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 224 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 225 * @param ctrlX Indicates the x coordinate of the control point. 226 * @param ctrlY Indicates the y coordinate of the control point. 227 * @param endX Indicates the x coordinate of the target point. 228 * @param endY Indicates the y coordinate of the target point. 229 * @since 8 230 * @version 1.0 231 */ 232 void OH_Drawing_PathQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY); 233 234 /** 235 * @brief Draws a conic from the last point of a path to the target point. 236 * 237 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 238 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 239 * @param ctrlX Indicates the x coordinate of the control point. 240 * @param ctrlY Indicates the y coordinate of the control point. 241 * @param endX Indicates the x coordinate of the target point. 242 * @param endY Indicates the y coordinate of the target point. 243 * @param weight Indicates the weight of added conic. 244 * @since 12 245 * @version 1.0 246 */ 247 void OH_Drawing_PathConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight); 248 249 /** 250 * @brief Draws a cubic Bezier curve from the last point of a path to the target point. 251 * 252 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 253 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 254 * @param ctrlX1 Indicates the x coordinate of the first control point. 255 * @param ctrlY1 Indicates the y coordinate of the first control point. 256 * @param ctrlX2 Indicates the x coordinate of the second control point. 257 * @param ctrlY2 Indicates the y coordinate of the second control point. 258 * @param endX Indicates the x coordinate of the target point. 259 * @param endY Indicates the y coordinate of the target point. 260 * @since 8 261 * @version 1.0 262 */ 263 void OH_Drawing_PathCubicTo( 264 OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY); 265 266 /** 267 * @brief Sets the relative starting point of a path. 268 * 269 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 270 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 271 * @param x Indicates the x coordinate of the relative starting point. 272 * @param y Indicates the y coordinate of the relative starting point. 273 * @since 12 274 * @version 1.0 275 */ 276 void OH_Drawing_PathRMoveTo(OH_Drawing_Path* path, float x, float y); 277 278 /** 279 * @brief Draws a line segment from the last point of a path to the relative target point. 280 * 281 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 282 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 283 * @param x Indicates the x coordinate of the relative target point. 284 * @param y Indicates the y coordinate of the relative target point. 285 * @since 12 286 * @version 1.0 287 */ 288 void OH_Drawing_PathRLineTo(OH_Drawing_Path* path, float x, float y); 289 290 /** 291 * @brief Draws a quadratic bezier curve from the last point of a path to the relative target point. 292 * 293 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 294 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 295 * @param ctrlX Indicates the x coordinate of the relative control point. 296 * @param ctrlY Indicates the y coordinate of the relative control point. 297 * @param endX Indicates the x coordinate of the relative target point. 298 * @param endY Indicates the y coordinate of the relative target point. 299 * @since 12 300 * @version 1.0 301 */ 302 void OH_Drawing_PathRQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY); 303 304 /** 305 * @brief Draws a conic from the last point of a path to the relative target point. 306 * 307 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 308 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 309 * @param ctrlX Indicates the x coordinate of the relative control point. 310 * @param ctrlY Indicates the y coordinate of the relative control point. 311 * @param endX Indicates the x coordinate of the relative target point. 312 * @param endY Indicates the y coordinate of the relative target point. 313 * @param weight Indicates the weight of added conic. 314 * @since 12 315 * @version 1.0 316 */ 317 void OH_Drawing_PathRConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight); 318 319 /** 320 * @brief Draws a cubic bezier curve from the last point of a path to the relative target point. 321 * 322 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 323 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 324 * @param ctrlX1 Indicates the x coordinate of the first relative control point. 325 * @param ctrlY1 Indicates the y coordinate of the first relative control point. 326 * @param ctrlX2 Indicates the x coordinate of the second relative control point. 327 * @param ctrlY2 Indicates the y coordinate of the second relative control point. 328 * @param endX Indicates the x coordinate of the relative target point. 329 * @param endY Indicates the y coordinate of the relative target point. 330 * @since 12 331 * @version 1.0 332 */ 333 void OH_Drawing_PathRCubicTo(OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, 334 float endX, float endY); 335 336 /** 337 * @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction. 338 * 339 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 340 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 341 * @param left Indicates the left coordinate of the upper left corner of the rectangle. 342 * @param top Indicates the top coordinate of the upper top corner of the rectangle. 343 * @param right Indicates the right coordinate of the lower right corner of the rectangle. 344 * @param bottom Indicates the bottom coordinate of the lower bottom corner of the rectangle. 345 * @param pathDirection Indicates the path direction. 346 * @since 12 347 * @version 1.0 348 */ 349 void OH_Drawing_PathAddRect(OH_Drawing_Path* path, float left, float top, float right, float bottom, 350 OH_Drawing_PathDirection pathDirection); 351 352 /** 353 * @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction. 354 * 355 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 356 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 357 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 358 * @param pathDirection Indicates the path direction. 359 * @param start Indicates initial corner of rect to add. 360 * @since 12 361 * @version 1.0 362 */ 363 void OH_Drawing_PathAddRectWithInitialCorner(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, 364 OH_Drawing_PathDirection pathDirection, uint32_t start); 365 366 /** 367 * @brief Adds a new contour to the path, defined by the round rect, and wound in the specified direction. 368 * 369 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 370 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 371 * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object. 372 * @param pathDirection Indicates the path direction. 373 * @since 12 374 * @version 1.0 375 */ 376 void OH_Drawing_PathAddRoundRect(OH_Drawing_Path* path, 377 const OH_Drawing_RoundRect* roundRect, OH_Drawing_PathDirection pathDirection); 378 379 /** 380 * @brief Adds a oval 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 rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 385 * @param start Index of initial point of ellipse. 386 * @param pathDirection Indicates the path direction. 387 * @since 12 388 * @version 1.0 389 */ 390 void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, 391 uint32_t start, OH_Drawing_PathDirection pathDirection); 392 393 /** 394 * @brief Adds a oval to the path, defined by the rect, and wound in the specified direction. 395 * 396 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 397 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 398 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 399 * @param pathDirection Indicates the path direction. 400 * @since 12 401 * @version 1.0 402 */ 403 void OH_Drawing_PathAddOval(OH_Drawing_Path* path, 404 const OH_Drawing_Rect* rect, OH_Drawing_PathDirection pathDirection); 405 406 /** 407 * @brief Appends arc to path, as the start of new contour.Arc added is part of ellipse bounded by oval, 408 * from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees 409 * is aligned with the positive x-axis, and positive sweeps extends arc clockwise.If sweepAngle <= -360, or 410 * sweepAngle >= 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle 411 * values are treated modulo 360, and arc may or may not draw depending on numeric rounding. 412 * 413 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 414 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 415 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 416 * @param startAngle Indicates the starting angle of arc in degrees. 417 * @param sweepAngle Indicates the sweep, in degrees. Positive is clockwise. 418 * @since 12 419 * @version 1.0 420 */ 421 void OH_Drawing_PathAddArc(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, float startAngle, float sweepAngle); 422 423 /** 424 * @brief Appends src path to path, transformed by matrix. Transformed curves may have different verbs, 425 * point, and conic weights. 426 * 427 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 428 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 429 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 430 * @param matrix Indicates the length of the <b>OH_Drawing_Matrix</b> object. 431 * @since 12 432 * @version 1.0 433 */ 434 void OH_Drawing_PathAddPath(OH_Drawing_Path* path, const OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix); 435 436 /** 437 * @brief Appends src path to path, transformed by matrix and mode. Transformed curves may have different verbs, 438 * point, and conic weights. 439 * 440 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 441 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 442 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 443 * @param matrix Indicates the length of the <b>OH_Drawing_Matrix</b> object. 444 * @param pathAddMode Indicates the add path's add mode. 445 * @since 12 446 * @version 1.0 447 */ 448 void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, 449 const OH_Drawing_Matrix* matrix, OH_Drawing_PathAddMode pathAddMode); 450 451 /** 452 * @brief Appends src path to path, transformed by mode. Transformed curves may have different verbs, 453 * point, and conic weights. 454 * 455 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 456 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 457 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object, which is Appends src path to path. 458 * @param pathAddMode Indicates the add path's add mode. 459 * @since 12 460 * @version 1.0 461 */ 462 void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* path, 463 const OH_Drawing_Path* src, OH_Drawing_PathAddMode pathAddMode); 464 465 /** 466 * @brief Appends src path to path, transformed by offset and mode. Transformed curves may have different verbs, 467 * point, and conic weights. 468 * 469 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 470 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 471 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 472 * @param dx Indicates offset added to src path x-axis coordinates. 473 * @param dy Indicates offset added to src path y-axis coordinates. 474 * @param pathAddMode Indicates the add path's add mode. 475 * @since 12 476 * @version 1.0 477 */ 478 void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, float dx, float dy, 479 OH_Drawing_PathAddMode pathAddMode); 480 481 /** 482 * @brief Adds contour created from point array, adding (count - 1) line segments. 483 * 484 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 485 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 486 * @param points Indicates the point array. 487 * @param count Indicates the size of point array. 488 * @param isClosed Indicates Whether to add lines that connect the end and start. 489 * @since 12 490 * @version 1.0 491 */ 492 void OH_Drawing_PathAddPolygon(OH_Drawing_Path* path, const OH_Drawing_Point2D* points, uint32_t count, bool isClosed); 493 494 /** 495 * @brief Adds a circle to the path, and wound in the specified direction. 496 * 497 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 498 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 499 * @param x Indicates the x coordinate of the center of the circle. 500 * @param y Indicates the y coordinate of the center of the circle. 501 * @param radius Indicates the radius of the circle. 502 * @param pathDirection Indicates the path direction. 503 * @since 12 504 * @version 1.0 505 */ 506 void OH_Drawing_PathAddCircle(OH_Drawing_Path* path, 507 float x, float y, float radius, OH_Drawing_PathDirection pathDirection); 508 509 /** 510 * @brief Parses the svg path from the string. 511 * 512 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 513 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 514 * @param str Indicates the string of the SVG path. 515 * @return Returns true if build path is successful, returns false otherwise. 516 * @since 12 517 * @version 1.0 518 */ 519 bool OH_Drawing_PathBuildFromSvgString(OH_Drawing_Path* path, const char* str); 520 521 /** 522 * @brief Return the status that point (x, y) is contained by path. 523 * 524 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 525 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 526 * @param x Indicates the x-axis value of containment test. 527 * @param y Indicates the y-axis value of containment test. 528 * @return Returns true if the point (x, y) is contained by path. 529 * @since 12 530 * @version 1.0 531 */ 532 bool OH_Drawing_PathContains(OH_Drawing_Path* path, float x, float y); 533 534 /** 535 * @brief Transforms verb array, point array, and weight by matrix. transform may change verbs 536 * and increase their number. path is replaced by transformed data. 537 * 538 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 539 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 540 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 541 * @since 12 542 * @version 1.0 543 */ 544 void OH_Drawing_PathTransform(OH_Drawing_Path* path, const OH_Drawing_Matrix* matrix); 545 546 /** 547 * @brief Transforms verb array, point array, and weight by matrix. 548 * Transform may change verbs and increase their number. 549 * 550 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 551 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 552 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 553 * @param dst Indicates the pointer to an <b>OH_Drawing_Path</b> object. 554 * @param applyPerspectiveClip Indicates whether to apply perspective clip. 555 * @since 12 556 * @version 1.0 557 */ 558 void OH_Drawing_PathTransformWithPerspectiveClip(OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix, 559 OH_Drawing_Path* dst, bool applyPerspectiveClip); 560 561 /** 562 * @brief Sets FillType, the rule used to fill path. 563 * 564 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 565 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 566 * @param pathFillType Indicates the add path's fill type. 567 * @since 12 568 * @version 1.0 569 */ 570 void OH_Drawing_PathSetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType pathFillType); 571 572 /** 573 * @brief Gets the length of the current path object. 574 * 575 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 576 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 577 * @param forceClosed Indicates whether free to modify/delete the path after this call. 578 * @return Returns the length of the current path object. 579 * @since 12 580 * @version 1.0 581 */ 582 float OH_Drawing_PathGetLength(OH_Drawing_Path* path, bool forceClosed); 583 584 /** 585 * @brief Gets the smallest bounding box that contains the path. 586 * 587 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 588 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 589 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 590 * @since 12 591 * @version 1.0 592 */ 593 void OH_Drawing_PathGetBounds(OH_Drawing_Path* path, OH_Drawing_Rect* rect); 594 595 /** 596 * @brief Closes a path. A line segment from the start point to the last point of the path is added. 597 * 598 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 599 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 600 * @since 8 601 * @version 1.0 602 */ 603 void OH_Drawing_PathClose(OH_Drawing_Path* path); 604 605 /** 606 * @brief Offset path replaces dst. 607 * 608 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 609 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 610 * @param dst Indicates the pointer to an <b>OH_Drawing_Path</b> object. 611 * @param dx Indicates offset added to dst path x-axis coordinates. 612 * @param dy Indicates offset added to dst path y-axis coordinates. 613 * @since 12 614 * @version 1.0 615 */ 616 void OH_Drawing_PathOffset(OH_Drawing_Path* path, OH_Drawing_Path* dst, float dx, float dy); 617 618 /** 619 * @brief Resets path data. 620 * 621 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 622 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 623 * @since 8 624 * @version 1.0 625 */ 626 void OH_Drawing_PathReset(OH_Drawing_Path* path); 627 628 /** 629 * @brief Determines whether the path current contour is closed. 630 * 631 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 632 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 633 * @param forceClosed Whether to close the Path. 634 * @return Returns <b>true</b> if the path current contour is closed; returns <b>false</b> otherwise. 635 * @since 12 636 * @version 1.0 637 */ 638 bool OH_Drawing_PathIsClosed(OH_Drawing_Path* path, bool forceClosed); 639 640 /** 641 * @brief Gets the position and tangent of the distance from the starting position of the Path. 642 * 643 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 644 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 645 * @param forceClosed Whether to close the Path. 646 * @param distance The distance from the start of the Path. 647 * @param position Sets to the position of distance from the starting position of the Path. 648 * @param tangent Sets to the tangent of distance from the starting position of the Path. 649 * @return Returns <b>true</b> if succeeded; returns <b>false</b> otherwise. 650 * @since 12 651 * @version 1.0 652 */ 653 bool OH_Drawing_PathGetPositionTangent(OH_Drawing_Path* path, bool forceClosed, 654 float distance, OH_Drawing_Point2D* position, OH_Drawing_Point2D* tangent); 655 656 /** 657 * @brief Gets the path between the start and end points. 658 * 659 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 660 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 661 * @param forceClosed Whether to close the path. 662 * @param start The distance from the starting point of the segment to the starting point of the path. 663 * @param stop The distance from the end point of the segment to the starting point of the path. 664 * @param startWithMoveTo Whether the path obtained moveTo to the starting segment. 665 * @param dst The path obtained. 666 * @param result Indicates the result of getting the path segment. 667 * The value is false if the segment is zero-length or start >= stop, and true otherwise. 668 * @return Returns the error code. 669 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 670 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of path, dst and result is nullptr. 671 * @since 18 672 * @version 1.0 673 */ 674 OH_Drawing_ErrorCode OH_Drawing_PathGetSegment(OH_Drawing_Path* path, bool forceClosed, 675 float start, float stop, bool startWithMoveTo, OH_Drawing_Path* dst, bool* result); 676 677 /** 678 * @brief Combines two paths. 679 * 680 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 681 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 682 * @param other Indicates the pointer to an <b>OH_Drawing_Path</b> object. 683 * @param op Indicates the operation to apply to combine. 684 * @return Returns <b>true</b> if constructed path is not empty; returns <b>false</b> otherwise. 685 * @since 12 686 * @version 1.0 687 */ 688 bool OH_Drawing_PathOp(OH_Drawing_Path* path, const OH_Drawing_Path* other, OH_Drawing_PathOpMode op); 689 690 /** 691 * @brief Computes the corresponding matrix at the specified distance. 692 * 693 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 694 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 695 * @param forceClosed Whether to close the Path. 696 * @param distance The distance from the start of the Path. 697 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 698 * @param flag Indicates what should be returned in the matrix. 699 * @return Returns <b>false</b> if path is nullptr or zero-length; 700 returns <b>true</b> if path is not nullptr and not zero-length. 701 * @since 12 702 * @version 1.0 703 */ 704 bool OH_Drawing_PathGetMatrix(OH_Drawing_Path* path, bool forceClosed, 705 float distance, OH_Drawing_Matrix* matrix, OH_Drawing_PathMeasureMatrixFlags flag); 706 707 #ifdef __cplusplus 708 } 709 #endif 710 /** @} */ 711 #endif 712