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