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_types.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /** 50 * @brief Direction for adding closed contours. 51 * 52 * @since 12 53 * @version 1.0 54 */ 55 typedef enum { 56 /** clockwise direction for adding closed contours */ 57 PATH_DIRECTION_CW, 58 /** counter-clockwise direction for adding closed contours */ 59 PATH_DIRECTION_CCW, 60 } OH_Drawing_PathDirection; 61 62 /** 63 * @brief FillType of path. 64 * 65 * @since 12 66 * @version 1.0 67 */ 68 typedef enum { 69 /** Specifies that "inside" is computed by a non-zero sum of signed edge crossings */ 70 PATH_FILL_TYPE_WINDING, 71 /** Specifies that "inside" is computed by an odd number of edge crossings */ 72 PATH_FILL_TYPE_EVEN_ODD, 73 /** Same as Winding, but draws outside of the path, rather than inside */ 74 PATH_FILL_TYPE_INVERSE_WINDING, 75 /** Same as EvenOdd, but draws outside of the path, rather than inside */ 76 PATH_FILL_TYPE_INVERSE_EVEN_ODD, 77 } OH_Drawing_PathFillType; 78 79 /** 80 * @brief Add mode of path. 81 * 82 * @since 12 83 * @version 1.0 84 */ 85 typedef enum { 86 /** Appended to destination unaltered */ 87 PATH_ADD_MODE_APPEND, 88 /** Add line if prior contour is not closed */ 89 PATH_ADD_MODE_EXTEND, 90 } OH_Drawing_PathAddMode; 91 92 /** 93 * @brief Operations when two paths are combined. 94 * 95 * @since 12 96 * @version 1.0 97 */ 98 typedef enum { 99 /** 100 * Difference operation. 101 */ 102 PATH_OP_MODE_DIFFERENCE, 103 /** 104 * Intersect operation. 105 */ 106 PATH_OP_MODE_INTERSECT, 107 /** 108 * Union operation. 109 */ 110 PATH_OP_MODE_UNION, 111 /** 112 * Xor operation. 113 */ 114 PATH_OP_MODE_XOR, 115 /** 116 * Reverse difference operation. 117 */ 118 PATH_OP_MODE_REVERSE_DIFFERENCE, 119 } OH_Drawing_PathOpMode; 120 121 /** 122 * @brief Enumerates the matrix information corresponding to the path measurements. 123 * 124 * @since 12 125 * @version 1.0 126 */ 127 typedef enum { 128 /** 129 * Gets position. 130 */ 131 GET_POSITION_MATRIX, 132 /** 133 * Gets tangent. 134 */ 135 GET_TANGENT_MATRIX, 136 /** 137 * Gets both position and tangent. 138 */ 139 GET_POSITION_AND_TANGENT_MATRIX, 140 } OH_Drawing_PathMeasureMatrixFlags; 141 142 /** 143 * @brief Creates an <b>OH_Drawing_Path</b> object. 144 * 145 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 146 * @return Returns the pointer to the <b>OH_Drawing_Path</b> object created. 147 * @since 8 148 * @version 1.0 149 */ 150 OH_Drawing_Path* OH_Drawing_PathCreate(void); 151 152 /** 153 * @brief Creates an <b>OH_Drawing_Path</b> copy object. 154 * 155 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 156 * @param path Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 157 * @return Returns the pointer to the <b>OH_Drawing_Path</b> object created. 158 * @since 12 159 * @version 1.0 160 */ 161 OH_Drawing_Path* OH_Drawing_PathCopy(OH_Drawing_Path* path); 162 163 /** 164 * @brief Destroys an <b>OH_Drawing_Path</b> object and reclaims the memory occupied by the object. 165 * 166 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 167 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 168 * @since 8 169 * @version 1.0 170 */ 171 void OH_Drawing_PathDestroy(OH_Drawing_Path* path); 172 173 /** 174 * @brief Sets the start point of a path. 175 * 176 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 177 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 178 * @param x Indicates the x coordinate of the start point. 179 * @param y Indicates the y coordinate of the start point. 180 * @since 8 181 * @version 1.0 182 */ 183 void OH_Drawing_PathMoveTo(OH_Drawing_Path* path, float x, float y); 184 185 /** 186 * @brief Draws a line segment from the last point of a path to the target point. 187 * 188 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 189 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 190 * @param x Indicates the x coordinate of the target point. 191 * @param y Indicates the y coordinate of the target point. 192 * @since 8 193 * @version 1.0 194 */ 195 void OH_Drawing_PathLineTo(OH_Drawing_Path* path, float x, float y); 196 197 /** 198 * @brief Draws an arc to a path. 199 * 200 * This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, 201 * and then a start angle and a sweep angle are specified. 202 * The arc is a portion of the ellipse defined by the start angle and the sweep angle. 203 * By default, a line segment from the last point of the path to the start point of the arc is also added. 204 * 205 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 206 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 207 * @param x1 Indicates the x coordinate of the upper left corner of the rectangle. 208 * @param y1 Indicates the y coordinate of the upper left corner of the rectangle. 209 * @param x2 Indicates the x coordinate of the lower right corner of the rectangle. 210 * @param y2 Indicates the y coordinate of the lower right corner of the rectangle. 211 * @param startDeg Indicates the start angle, in degrees. 212 * @param sweepDeg Indicates the angle to sweep, in degrees. 213 * @since 8 214 * @version 1.0 215 */ 216 void OH_Drawing_PathArcTo(OH_Drawing_Path* path, 217 float x1, float y1, float x2, float y2, float startDeg, float sweepDeg); 218 219 /** 220 * @brief Draws a quadratic Bezier curve from the last point of a path to the target point. 221 * 222 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 223 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 224 * @param ctrlX Indicates the x coordinate of the control point. 225 * @param ctrlY Indicates the y coordinate of the control point. 226 * @param endX Indicates the x coordinate of the target point. 227 * @param endY Indicates the y coordinate of the target point. 228 * @since 8 229 * @version 1.0 230 */ 231 void OH_Drawing_PathQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY); 232 233 /** 234 * @brief Draws a conic from the last point of a path to the target point. 235 * 236 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 237 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 238 * @param ctrlX Indicates the x coordinate of the control point. 239 * @param ctrlY Indicates the y coordinate of the control point. 240 * @param endX Indicates the x coordinate of the target point. 241 * @param endY Indicates the y coordinate of the target point. 242 * @param weight Indicates the weight of added conic. 243 * @since 12 244 * @version 1.0 245 */ 246 void OH_Drawing_PathConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight); 247 248 /** 249 * @brief Draws a cubic Bezier curve from the last point of a path to the target point. 250 * 251 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 252 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 253 * @param ctrlX1 Indicates the x coordinate of the first control point. 254 * @param ctrlY1 Indicates the y coordinate of the first control point. 255 * @param ctrlX2 Indicates the x coordinate of the second control point. 256 * @param ctrlY2 Indicates the y coordinate of the second control point. 257 * @param endX Indicates the x coordinate of the target point. 258 * @param endY Indicates the y coordinate of the target point. 259 * @since 8 260 * @version 1.0 261 */ 262 void OH_Drawing_PathCubicTo( 263 OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY); 264 265 /** 266 * @brief Sets the relative starting point of a path. 267 * 268 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 269 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 270 * @param x Indicates the x coordinate of the relative starting point. 271 * @param y Indicates the y coordinate of the relative starting point. 272 * @since 12 273 * @version 1.0 274 */ 275 void OH_Drawing_PathRMoveTo(OH_Drawing_Path* path, float x, float y); 276 277 /** 278 * @brief Draws a line segment from the last point of a path to the relative 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 x Indicates the x coordinate of the relative target point. 283 * @param y Indicates the y coordinate of the relative target point. 284 * @since 12 285 * @version 1.0 286 */ 287 void OH_Drawing_PathRLineTo(OH_Drawing_Path* path, float x, float y); 288 289 /** 290 * @brief Draws a quadratic bezier curve from the last point of a path to the relative target point. 291 * 292 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 293 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 294 * @param ctrlX Indicates the x coordinate of the relative control point. 295 * @param ctrlY Indicates the y coordinate of the relative control point. 296 * @param endX Indicates the x coordinate of the relative target point. 297 * @param endY Indicates the y coordinate of the relative target point. 298 * @since 12 299 * @version 1.0 300 */ 301 void OH_Drawing_PathRQuadTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY); 302 303 /** 304 * @brief Draws a conic from the last point of a path to the relative target point. 305 * 306 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 307 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 308 * @param ctrlX Indicates the x coordinate of the relative control point. 309 * @param ctrlY Indicates the y coordinate of the relative control point. 310 * @param endX Indicates the x coordinate of the relative target point. 311 * @param endY Indicates the y coordinate of the relative target point. 312 * @param weight Indicates the weight of added conic. 313 * @since 12 314 * @version 1.0 315 */ 316 void OH_Drawing_PathRConicTo(OH_Drawing_Path* path, float ctrlX, float ctrlY, float endX, float endY, float weight); 317 318 /** 319 * @brief Draws a cubic bezier curve from the last point of a path to the relative target point. 320 * 321 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 322 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 323 * @param ctrlX1 Indicates the x coordinate of the first relative control point. 324 * @param ctrlY1 Indicates the y coordinate of the first relative control point. 325 * @param ctrlX2 Indicates the x coordinate of the second relative control point. 326 * @param ctrlY2 Indicates the y coordinate of the second relative control point. 327 * @param endX Indicates the x coordinate of the relative target point. 328 * @param endY Indicates the y coordinate of the relative target point. 329 * @since 12 330 * @version 1.0 331 */ 332 void OH_Drawing_PathRCubicTo(OH_Drawing_Path* path, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, 333 float endX, float endY); 334 335 /** 336 * @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction. 337 * 338 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 339 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 340 * @param left Indicates the left coordinate of the upper left corner of the rectangle. 341 * @param top Indicates the top coordinate of the upper top corner of the rectangle. 342 * @param right Indicates the right coordinate of the lower right corner of the rectangle. 343 * @param bottom Indicates the bottom coordinate of the lower bottom corner of the rectangle. 344 * @param pathDirection Indicates the path direction. 345 * @since 12 346 * @version 1.0 347 */ 348 void OH_Drawing_PathAddRect(OH_Drawing_Path* path, float left, float top, float right, float bottom, 349 OH_Drawing_PathDirection pathDirection); 350 351 /** 352 * @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction. 353 * 354 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 355 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 356 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 357 * @param pathDirection Indicates the path direction. 358 * @param start Indicates initial corner of rect to add. 359 * @since 12 360 * @version 1.0 361 */ 362 void OH_Drawing_PathAddRectWithInitialCorner(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, 363 OH_Drawing_PathDirection pathDirection, uint32_t start); 364 365 /** 366 * @brief Adds a new contour to the path, defined by the round rect, and wound in the specified direction. 367 * 368 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 369 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 370 * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object. 371 * @param pathDirection Indicates the path direction. 372 * @since 12 373 * @version 1.0 374 */ 375 void OH_Drawing_PathAddRoundRect(OH_Drawing_Path* path, 376 const OH_Drawing_RoundRect* roundRect, OH_Drawing_PathDirection pathDirection); 377 378 /** 379 * @brief Adds a oval to the path, defined by the rect, and wound in the specified direction. 380 * 381 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 382 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 383 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 384 * @param start Index of initial point of ellipse. 385 * @param pathDirection Indicates the path direction. 386 * @since 12 387 * @version 1.0 388 */ 389 void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, 390 uint32_t start, OH_Drawing_PathDirection pathDirection); 391 392 /** 393 * @brief Adds a oval to the path, defined by the rect, and wound in the specified direction. 394 * 395 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 396 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 397 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 398 * @param pathDirection Indicates the path direction. 399 * @since 12 400 * @version 1.0 401 */ 402 void OH_Drawing_PathAddOval(OH_Drawing_Path* path, 403 const OH_Drawing_Rect* rect, OH_Drawing_PathDirection pathDirection); 404 405 /** 406 * @brief Appends arc to path, as the start of new contour.Arc added is part of ellipse bounded by oval, 407 * from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees 408 * is aligned with the positive x-axis, and positive sweeps extends arc clockwise.If sweepAngle <= -360, or 409 * sweepAngle >= 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle 410 * values are treated modulo 360, and arc may or may not draw depending on numeric rounding. 411 * 412 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 413 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 414 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 415 * @param startAngle Indicates the starting angle of arc in degrees. 416 * @param sweepAngle Indicates the sweep, in degrees. Positive is clockwise. 417 * @since 12 418 * @version 1.0 419 */ 420 void OH_Drawing_PathAddArc(OH_Drawing_Path* path, const OH_Drawing_Rect* rect, float startAngle, float sweepAngle); 421 422 /** 423 * @brief Appends src path to path, transformed by matrix. Transformed curves may have different verbs, 424 * point, and conic weights. 425 * 426 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 427 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 428 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 429 * @param matrix Indicates the length of the <b>OH_Drawing_Matrix</b> object. 430 * @since 12 431 * @version 1.0 432 */ 433 void OH_Drawing_PathAddPath(OH_Drawing_Path* path, const OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix); 434 435 /** 436 * @brief Appends src path to path, transformed by matrix and mode. Transformed curves may have different verbs, 437 * point, and conic weights. 438 * 439 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 440 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 441 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 442 * @param matrix Indicates the length of the <b>OH_Drawing_Matrix</b> object. 443 * @param pathAddMode Indicates the add path's add mode. 444 * @since 12 445 * @version 1.0 446 */ 447 void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, 448 const OH_Drawing_Matrix* matrix, OH_Drawing_PathAddMode pathAddMode); 449 450 /** 451 * @brief Appends src path to path, transformed by mode. Transformed curves may have different verbs, 452 * point, and conic weights. 453 * 454 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 455 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 456 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object, which is Appends src path to path. 457 * @param pathAddMode Indicates the add path's add mode. 458 * @since 12 459 * @version 1.0 460 */ 461 void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* path, 462 const OH_Drawing_Path* src, OH_Drawing_PathAddMode pathAddMode); 463 464 /** 465 * @brief Appends src path to path, transformed by offset and mode. Transformed curves may have different verbs, 466 * point, and conic weights. 467 * 468 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 469 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 470 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 471 * @param dx Indicates offset added to src path x-axis coordinates. 472 * @param dy Indicates offset added to src path y-axis coordinates. 473 * @param pathAddMode Indicates the add path's add mode. 474 * @since 12 475 * @version 1.0 476 */ 477 void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path* path, const OH_Drawing_Path* src, float dx, float dy, 478 OH_Drawing_PathAddMode pathAddMode); 479 480 /** 481 * @brief Adds contour created from point array, adding (count - 1) line segments. 482 * 483 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 484 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 485 * @param points Indicates the point array. 486 * @param count Indicates the size of point array. 487 * @param isClosed Indicates Whether to add lines that connect the end and start. 488 * @since 12 489 * @version 1.0 490 */ 491 void OH_Drawing_PathAddPolygon(OH_Drawing_Path* path, const OH_Drawing_Point2D* points, uint32_t count, bool isClosed); 492 493 /** 494 * @brief Adds a circle to the path, and wound in the specified direction. 495 * 496 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 497 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 498 * @param x Indicates the x coordinate of the center of the circle. 499 * @param y Indicates the y coordinate of the center of the circle. 500 * @param radius Indicates the radius of the circle. 501 * @param pathDirection Indicates the path direction. 502 * @since 12 503 * @version 1.0 504 */ 505 void OH_Drawing_PathAddCircle(OH_Drawing_Path* path, 506 float x, float y, float radius, OH_Drawing_PathDirection pathDirection); 507 508 /** 509 * @brief Parses the svg path from the string. 510 * 511 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 512 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 513 * @param str Indicates the string of the SVG path. 514 * @return Returns true if build path is successful, returns false otherwise. 515 * @since 12 516 * @version 1.0 517 */ 518 bool OH_Drawing_PathBuildFromSvgString(OH_Drawing_Path* path, const char* str); 519 520 /** 521 * @brief Return the status that point (x, y) is contained by path. 522 * 523 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 524 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 525 * @param x Indicates the x-axis value of containment test. 526 * @param y Indicates the y-axis value of containment test. 527 * @return Returns true if the point (x, y) is contained by path. 528 * @since 12 529 * @version 1.0 530 */ 531 bool OH_Drawing_PathContains(OH_Drawing_Path* path, float x, float y); 532 533 /** 534 * @brief Transforms verb array, point array, and weight by matrix. transform may change verbs 535 * and increase their number. path is replaced by transformed data. 536 * 537 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 538 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 539 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 540 * @since 12 541 * @version 1.0 542 */ 543 void OH_Drawing_PathTransform(OH_Drawing_Path* path, const OH_Drawing_Matrix* matrix); 544 545 /** 546 * @brief Transforms verb array, point array, and weight by matrix. 547 * Transform may change verbs and increase their number. 548 * 549 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 550 * @param src Indicates the pointer to an <b>OH_Drawing_Path</b> object. 551 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 552 * @param dst Indicates the pointer to an <b>OH_Drawing_Path</b> object. 553 * @param applyPerspectiveClip Indicates whether to apply perspective clip. 554 * @since 12 555 * @version 1.0 556 */ 557 void OH_Drawing_PathTransformWithPerspectiveClip(OH_Drawing_Path* src, const OH_Drawing_Matrix* matrix, 558 OH_Drawing_Path* dst, bool applyPerspectiveClip); 559 560 /** 561 * @brief Sets FillType, the rule used to fill path. 562 * 563 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 564 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 565 * @param pathFillType Indicates the add path's fill type. 566 * @since 12 567 * @version 1.0 568 */ 569 void OH_Drawing_PathSetFillType(OH_Drawing_Path* path, OH_Drawing_PathFillType pathFillType); 570 571 /** 572 * @brief Gets the length of the current path object. 573 * 574 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 575 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 576 * @param forceClosed Indicates whether free to modify/delete the path after this call. 577 * @return Returns the length of the current path object. 578 * @since 12 579 * @version 1.0 580 */ 581 float OH_Drawing_PathGetLength(OH_Drawing_Path* path, bool forceClosed); 582 583 /** 584 * @brief Gets the smallest bounding box that contains the path. 585 * 586 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 587 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 588 * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 589 * @since 12 590 * @version 1.0 591 */ 592 void OH_Drawing_PathGetBounds(OH_Drawing_Path* path, OH_Drawing_Rect* rect); 593 594 /** 595 * @brief Closes a path. A line segment from the start point to the last point of the path is added. 596 * 597 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 598 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 599 * @since 8 600 * @version 1.0 601 */ 602 void OH_Drawing_PathClose(OH_Drawing_Path* path); 603 604 /** 605 * @brief Offset path replaces dst. 606 * 607 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 608 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 609 * @param dst Indicates the pointer to an <b>OH_Drawing_Path</b> object. 610 * @param dx Indicates offset added to dst path x-axis coordinates. 611 * @param dy Indicates offset added to dst path y-axis coordinates. 612 * @since 12 613 * @version 1.0 614 */ 615 void OH_Drawing_PathOffset(OH_Drawing_Path* path, OH_Drawing_Path* dst, float dx, float dy); 616 617 /** 618 * @brief Resets path data. 619 * 620 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 621 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 622 * @since 8 623 * @version 1.0 624 */ 625 void OH_Drawing_PathReset(OH_Drawing_Path* path); 626 627 /** 628 * @brief Determines whether the path current contour is closed. 629 * 630 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 631 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 632 * @param forceClosed Whether to close the Path. 633 * @return Returns <b>true</b> if the path current contour is closed; returns <b>false</b> otherwise. 634 * @since 12 635 * @version 1.0 636 */ 637 bool OH_Drawing_PathIsClosed(OH_Drawing_Path* path, bool forceClosed); 638 639 /** 640 * @brief Gets the position and tangent of the distance from the starting position of the Path. 641 * 642 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 643 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 644 * @param forceClosed Whether to close the Path. 645 * @param distance The distance from the start of the Path. 646 * @param position Sets to the position of distance from the starting position of the Path. 647 * @param tangent Sets to the tangent of distance from the starting position of the Path. 648 * @return Returns <b>true</b> if succeeded; returns <b>false</b> otherwise. 649 * @since 12 650 * @version 1.0 651 */ 652 bool OH_Drawing_PathGetPositionTangent(OH_Drawing_Path* path, bool forceClosed, 653 float distance, OH_Drawing_Point2D* position, OH_Drawing_Point2D* tangent); 654 655 /** 656 * @brief Combines two paths. 657 * 658 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 659 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 660 * @param other Indicates the pointer to an <b>OH_Drawing_Path</b> object. 661 * @param op Indicates the operation to apply to combine. 662 * @return Returns <b>true</b> if constructed path is not empty; returns <b>false</b> otherwise. 663 * @since 12 664 * @version 1.0 665 */ 666 bool OH_Drawing_PathOp(OH_Drawing_Path* path, const OH_Drawing_Path* other, OH_Drawing_PathOpMode op); 667 668 /** 669 * @brief Computes the corresponding matrix at the specified distance. 670 * 671 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 672 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 673 * @param forceClosed Whether to close the Path. 674 * @param distance The distance from the start of the Path. 675 * @param matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object. 676 * @param flag Indicates what should be returned in the matrix. 677 * @return Returns <b>false</b> if path is nullptr or zero-length; 678 returns <b>true</b> if path is not nullptr and not zero-length. 679 * @since 12 680 * @version 1.0 681 */ 682 bool OH_Drawing_PathGetMatrix(OH_Drawing_Path* path, bool forceClosed, 683 float distance, OH_Drawing_Matrix* matrix, OH_Drawing_PathMeasureMatrixFlags flag); 684 685 #ifdef __cplusplus 686 } 687 #endif 688 /** @} */ 689 #endif 690