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