1/* 2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkGraphics2D 19 */ 20 21import type image from './@ohos.multimedia.image'; 22import type common2D from './@ohos.graphics.common2D'; 23import type colorSpaceManager from './@ohos.graphics.colorSpaceManager'; 24import { Resource } from './global/resource'; 25 26/** 27 * The common2D module defines some common data types in the 2D graphics field. 28 * 29 * @namespace drawing 30 * @syscap SystemCapability.Graphics.Drawing 31 * @since 11 32 */ 33/** 34 * The common2D module defines some common data types in the 2D graphics field. 35 * 36 * @namespace drawing 37 * @syscap SystemCapability.Graphics.Drawing 38 * @crossplatform 39 * @since 20 40 * @arkts 1.1&1.2 41 */ 42declare namespace drawing { 43 /** 44 * Enumerates the blend modes. A blend mode combines two colors (source color and destination color) in a specific way to create a new color. 45 * This is commonly used in graphics operations like overlaying, filtering, and masking. 46 * The blending process applies the same logic to the red, green, and blue color channels separately. 47 * The alpha channel, however, is handled according to the specific definitions of each blend mode. 48 * 49 * For brevity, the following abbreviations are used: 50 * 51 * s: source. 52 * d: destination. 53 * sa: source alpha. 54 * da: destination alpha. 55 * The following abbreviations are used in the calculation result: 56 * 57 * r: used when the calculation method is the same for the four channels (alpha, red, green, and blue channels). 58 * ra: used when only the alpha channel is manipulated. 59 * rc: used when the other three color channels are manipulated. 60 * The table below shows the effect of each blend mode, where the yellow rectangle is the source and the blue circle is the destination. 61 * 62 * @enum { number } 63 * @syscap SystemCapability.Graphics.Drawing 64 * @since 11 65 */ 66 /** 67 * Enumerates the blend modes. A blend mode combines two colors (source color and destination color) in a specific way to create a new color. 68 * This is commonly used in graphics operations like overlaying, filtering, and masking. 69 * The blending process applies the same logic to the red, green, and blue color channels separately. 70 * The alpha channel, however, is handled according to the specific definitions of each blend mode. 71 * 72 * For brevity, the following abbreviations are used: 73 * 74 * s: source. 75 * d: destination. 76 * sa: source alpha. 77 * da: destination alpha. 78 * The following abbreviations are used in the calculation result: 79 * 80 * r: used when the calculation method is the same for the four channels (alpha, red, green, and blue channels). 81 * ra: used when only the alpha channel is manipulated. 82 * rc: used when the other three color channels are manipulated. 83 * The table below shows the effect of each blend mode, where the yellow rectangle is the source and the blue circle is the destination. 84 * @enum { number } 85 * @syscap SystemCapability.Graphics.Drawing 86 * @crossplatform 87 * @since 20 88 * @arkts 1.1&1.2 89 */ 90 enum BlendMode { 91 /** 92 * r = 0, sets the the destination pixels to fully transparent. 93 * @syscap SystemCapability.Graphics.Drawing 94 * @since 11 95 */ 96 /** 97 * r = 0, sets the the destination pixels to fully transparent. 98 * @syscap SystemCapability.Graphics.Drawing 99 * @crossplatform 100 * @since 20 101 * @arkts 1.1&1.2 102 */ 103 CLEAR = 0, 104 /** 105 * r = s (all channels of the result equal those of the source), replaces the destination pixels with the source pixels. 106 * @syscap SystemCapability.Graphics.Drawing 107 * @since 11 108 */ 109 /** 110 * r = s (all channels of the result equal those of the source), replaces the destination pixels with the source pixels. 111 * @syscap SystemCapability.Graphics.Drawing 112 * @crossplatform 113 * @since 20 114 * @arkts 1.1&1.2 115 */ 116 SRC = 1, 117 /** 118 * r = d (all channels of the result equal those of the destination), keeps the destination pixels unchanged. 119 * @syscap SystemCapability.Graphics.Drawing 120 * @since 11 121 */ 122 /** 123 * r = d (all channels of the result equal those of the destination), keeps the destination pixels unchanged. 124 * @syscap SystemCapability.Graphics.Drawing 125 * @crossplatform 126 * @since 20 127 * @arkts 1.1&1.2 128 */ 129 DST = 2, 130 /** 131 * r = s + (1 - sa) * d, draws the source pixels over the destination pixels, considering the source's transparency. 132 * @syscap SystemCapability.Graphics.Drawing 133 * @since 11 134 */ 135 /** 136 * r = s + (1 - sa) * d, draws the source pixels over the destination pixels, considering the source's transparency. 137 * @syscap SystemCapability.Graphics.Drawing 138 * @crossplatform 139 * @since 20 140 * @arkts 1.1&1.2 141 */ 142 SRC_OVER = 3, 143 /** 144 * r = d + (1 - da) * s, draws the destination pixels over the source pixels, considering the destination's transparency. 145 * @syscap SystemCapability.Graphics.Drawing 146 * @since 11 147 */ 148 /** 149 * r = d + (1 - da) * s, draws the destination pixels over the source pixels, considering the destination's transparency. 150 * @syscap SystemCapability.Graphics.Drawing 151 * @crossplatform 152 * @since 20 153 * @arkts 1.1&1.2 154 */ 155 DST_OVER = 4, 156 /** 157 * r = s * da, retains only the intersection of the source pixels with the opaque parts of the destination. 158 * @syscap SystemCapability.Graphics.Drawing 159 * @since 11 160 */ 161 /** 162 * r = s * da, retains only the intersection of the source pixels with the opaque parts of the destination. 163 * @syscap SystemCapability.Graphics.Drawing 164 * @crossplatform 165 * @since 20 166 * @arkts 1.1&1.2 167 */ 168 SRC_IN = 5, 169 /** 170 * r = d * sa, retains only the intersection of the destination pixels with the opaque parts of the source. 171 * @syscap SystemCapability.Graphics.Drawing 172 * @since 11 173 */ 174 /** 175 * r = d * sa, retains only the intersection of the destination pixels with the opaque parts of the source. 176 * @syscap SystemCapability.Graphics.Drawing 177 * @crossplatform 178 * @since 20 179 * @arkts 1.1&1.2 180 */ 181 DST_IN = 6, 182 /** 183 * r = s * (1 - da), retains the parts of the source pixels that do not overlap with the destination. 184 * @syscap SystemCapability.Graphics.Drawing 185 * @since 11 186 */ 187 /** 188 * r = s * (1 - da), retains the parts of the source pixels that do not overlap with the destination. 189 * @syscap SystemCapability.Graphics.Drawing 190 * @crossplatform 191 * @since 20 192 * @arkts 1.1&1.2 193 */ 194 SRC_OUT = 7, 195 /** 196 * r = d * (1 - sa), retains the parts of the destination pixels that do not overlap with the source. 197 * @syscap SystemCapability.Graphics.Drawing 198 * @since 11 199 */ 200 /** 201 * r = d * (1 - sa), retains the parts of the destination pixels that do not overlap with the source. 202 * @syscap SystemCapability.Graphics.Drawing 203 * @crossplatform 204 * @since 20 205 * @arkts 1.1&1.2 206 */ 207 DST_OUT = 8, 208 /** 209 * r = s * da + d * (1 - sa), covers the destination pixels with the source pixels, showing the source only in the opaque parts of the destination. 210 * @syscap SystemCapability.Graphics.Drawing 211 * @since 11 212 */ 213 /** 214 * r = s * da + d * (1 - sa), covers the destination pixels with the source pixels, showing the source only in the opaque parts of the destination. 215 * @syscap SystemCapability.Graphics.Drawing 216 * @crossplatform 217 * @since 20 218 * @arkts 1.1&1.2 219 */ 220 SRC_ATOP = 9, 221 /** 222 * r = d * sa + s * (1 - da), covers the source pixels with the destination pixels, showing the destination only in the opaque parts of the source. 223 * @syscap SystemCapability.Graphics.Drawing 224 * @since 11 225 */ 226 /** 227 * r = d * sa + s * (1 - da), covers the source pixels with the destination pixels, showing the destination only in the opaque parts of the source. 228 * @syscap SystemCapability.Graphics.Drawing 229 * @crossplatform 230 * @since 20 231 * @arkts 1.1&1.2 232 */ 233 DST_ATOP = 10, 234 /** 235 * r = s * (1 - da) + d * (1 - sa), shows only the non-overlapping parts of the source and destination pixels. 236 * @syscap SystemCapability.Graphics.Drawing 237 * @since 11 238 */ 239 /** 240 * r = s * (1 - da) + d * (1 - sa), shows only the non-overlapping parts of the source and destination pixels. 241 * @syscap SystemCapability.Graphics.Drawing 242 * @crossplatform 243 * @since 20 244 * @arkts 1.1&1.2 245 */ 246 XOR = 11, 247 /** 248 * r = min(s + d, 1), adds the color values of the source and destination pixels. 249 * @syscap SystemCapability.Graphics.Drawing 250 * @since 11 251 */ 252 /** 253 * r = min(s + d, 1), adds the color values of the source and destination pixels. 254 * @syscap SystemCapability.Graphics.Drawing 255 * @crossplatform 256 * @since 20 257 * @arkts 1.1&1.2 258 */ 259 PLUS = 12, 260 /** 261 * r = s * d, multiplies the color values of the source and destination pixels. 262 * @syscap SystemCapability.Graphics.Drawing 263 * @since 11 264 */ 265 /** 266 * r = s * d, multiplies the color values of the source and destination pixels. 267 * @syscap SystemCapability.Graphics.Drawing 268 * @crossplatform 269 * @since 20 270 * @arkts 1.1&1.2 271 */ 272 MODULATE = 13, 273 /** 274 * r = s + d - s * d, inverts the color values of the source and destination pixels, multiplies them, 275 * and then inverts the result, typically producing a brighter outcome. 276 * @syscap SystemCapability.Graphics.Drawing 277 * @since 11 278 */ 279 /** 280 * r = s + d - s * d, inverts the color values of the source and destination pixels, multiplies them, 281 * and then inverts the result, typically producing a brighter outcome. 282 * @syscap SystemCapability.Graphics.Drawing 283 * @crossplatform 284 * @since 20 285 * @arkts 1.1&1.2 286 */ 287 SCREEN = 14, 288 /** 289 * Selectively applies MULTIPLY or SCREEN based on the brightness of the destination pixels, enhancing contrast. 290 * @syscap SystemCapability.Graphics.Drawing 291 * @since 11 292 */ 293 /** 294 * Selectively applies MULTIPLY or SCREEN based on the brightness of the destination pixels, enhancing contrast. 295 * @syscap SystemCapability.Graphics.Drawing 296 * @crossplatform 297 * @since 20 298 * @arkts 1.1&1.2 299 */ 300 OVERLAY = 15, 301 /** 302 * rc = s + d - max(s * da, d * sa), ra = s + (1 - sa) * d, takes the darker color values between the source and destination pixels. 303 * @syscap SystemCapability.Graphics.Drawing 304 * @since 11 305 */ 306 /** 307 * rc = s + d - max(s * da, d * sa), ra = s + (1 - sa) * d, takes the darker color values between the source and destination pixels. 308 * @syscap SystemCapability.Graphics.Drawing 309 * @crossplatform 310 * @since 20 311 * @arkts 1.1&1.2 312 */ 313 DARKEN = 16, 314 /** 315 * rc = s + d - min(s * da, d * sa), ra = s + (1 - sa) * d, takes the lighter color values between the source and destination pixels. 316 * @syscap SystemCapability.Graphics.Drawing 317 * @since 11 318 */ 319 /** 320 * rc = s + d - min(s * da, d * sa), ra = s + (1 - sa) * d, takes the lighter color values between the source and destination pixels. 321 * @syscap SystemCapability.Graphics.Drawing 322 * @crossplatform 323 * @since 20 324 * @arkts 1.1&1.2 325 */ 326 LIGHTEN = 17, 327 /** 328 * Brightens the destination pixels by reducing contrast to reflect the source pixels. 329 * @syscap SystemCapability.Graphics.Drawing 330 * @since 11 331 */ 332 /** 333 * Brightens the destination pixels by reducing contrast to reflect the source pixels. 334 * @syscap SystemCapability.Graphics.Drawing 335 * @crossplatform 336 * @since 20 337 * @arkts 1.1&1.2 338 */ 339 COLOR_DODGE = 18, 340 /** 341 * Darkens the destination pixels by increasing contrast to reflect the source pixels. 342 * @syscap SystemCapability.Graphics.Drawing 343 * @since 11 344 */ 345 /** 346 * Darkens the destination pixels by increasing contrast to reflect the source pixels. 347 * @syscap SystemCapability.Graphics.Drawing 348 * @crossplatform 349 * @since 20 350 * @arkts 1.1&1.2 351 */ 352 COLOR_BURN = 19, 353 /** 354 * Selectively applies MULTIPLY or SCREEN based on the brightness of the source pixels. 355 * @syscap SystemCapability.Graphics.Drawing 356 * @since 11 357 */ 358 /** 359 * Selectively applies MULTIPLY or SCREEN based on the brightness of the source pixels. 360 * @syscap SystemCapability.Graphics.Drawing 361 * @crossplatform 362 * @since 20 363 * @arkts 1.1&1.2 364 */ 365 HARD_LIGHT = 20, 366 /** 367 * Softly brightens or darkens the destination pixels based on the brightness of the source pixels. 368 * @syscap SystemCapability.Graphics.Drawing 369 * @since 11 370 */ 371 /** 372 * Softly brightens or darkens the destination pixels based on the brightness of the source pixels. 373 * @syscap SystemCapability.Graphics.Drawing 374 * @crossplatform 375 * @since 20 376 * @arkts 1.1&1.2 377 */ 378 SOFT_LIGHT = 21, 379 /** 380 * rc = s + d - 2 * (min(s * da, d * sa)), ra = s + (1 - sa) * d, calculates the difference between the color values of the source and destination pixels. 381 * @syscap SystemCapability.Graphics.Drawing 382 * @since 11 383 */ 384 /** 385 * rc = s + d - 2 * (min(s * da, d * sa)), ra = s + (1 - sa) * d, calculates the difference between the color values of the source and destination pixels. 386 * @syscap SystemCapability.Graphics.Drawing 387 * @crossplatform 388 * @since 20 389 * @arkts 1.1&1.2 390 */ 391 DIFFERENCE = 22, 392 /** 393 * rc = s + d - two(s * d), ra = s + (1 - sa) * d, similar to DIFFERENCE but with lower contrast. 394 * @syscap SystemCapability.Graphics.Drawing 395 * @since 11 396 */ 397 /** 398 * rc = s + d - two(s * d), ra = s + (1 - sa) * d, similar to DIFFERENCE but with lower contrast. 399 * @syscap SystemCapability.Graphics.Drawing 400 * @crossplatform 401 * @since 20 402 * @arkts 1.1&1.2 403 */ 404 EXCLUSION = 23, 405 /** 406 * r = s * (1 - da) + d * (1 - sa) + s * d, multiplies the color values of the source and destination pixels, typically resulting in a darker outcome. 407 * @syscap SystemCapability.Graphics.Drawing 408 * @since 11 409 */ 410 /** 411 * r = s * (1 - da) + d * (1 - sa) + s * d, multiplies the color values of the source and destination pixels, typically resulting in a darker outcome. 412 * @syscap SystemCapability.Graphics.Drawing 413 * @crossplatform 414 * @since 20 415 * @arkts 1.1&1.2 416 */ 417 MULTIPLY = 24, 418 /** 419 * Uses the hue of the source pixels and the saturation and brightness of the destination pixels. 420 * @syscap SystemCapability.Graphics.Drawing 421 * @since 11 422 */ 423 /** 424 * Uses the hue of the source pixels and the saturation and brightness of the destination pixels. 425 * @syscap SystemCapability.Graphics.Drawing 426 * @crossplatform 427 * @since 20 428 * @arkts 1.1&1.2 429 */ 430 HUE = 25, 431 /** 432 * Uses the saturation of the source pixels and the hue and brightness of the destination pixels. 433 * @syscap SystemCapability.Graphics.Drawing 434 * @since 11 435 */ 436 /** 437 * Uses the saturation of the source pixels and the hue and brightness of the destination pixels. 438 * @syscap SystemCapability.Graphics.Drawing 439 * @crossplatform 440 * @since 20 441 * @arkts 1.1&1.2 442 */ 443 SATURATION = 26, 444 /** 445 * Uses the hue and saturation of the source pixels and the brightness of the destination pixels. 446 * @syscap SystemCapability.Graphics.Drawing 447 * @since 11 448 */ 449 /** 450 * Uses the hue and saturation of the source pixels and the brightness of the destination pixels. 451 * @syscap SystemCapability.Graphics.Drawing 452 * @crossplatform 453 * @since 20 454 * @arkts 1.1&1.2 455 */ 456 COLOR = 27, 457 /** 458 * Uses the brightness of the source pixels and the hue and saturation of the destination pixels. 459 * @syscap SystemCapability.Graphics.Drawing 460 * @since 11 461 */ 462 /** 463 * Uses the brightness of the source pixels and the hue and saturation of the destination pixels. 464 * @syscap SystemCapability.Graphics.Drawing 465 * @crossplatform 466 * @since 20 467 * @arkts 1.1&1.2 468 */ 469 LUMINOSITY = 28, 470 } 471 472 /** 473 * Enumerates the directions of a closed contour. 474 * @enum { number } 475 * @syscap SystemCapability.Graphics.Drawing 476 * @since 12 477 */ 478 /** 479 * Enumerates the directions of a closed contour. 480 * @enum { number } 481 * @syscap SystemCapability.Graphics.Drawing 482 * @crossplatform 483 * @since 20 484 */ 485 enum PathDirection { 486 /** 487 * Adds a closed contour clockwise. 488 * @syscap SystemCapability.Graphics.Drawing 489 * @since 12 490 */ 491 /** 492 * Adds a closed contour clockwise. 493 * @syscap SystemCapability.Graphics.Drawing 494 * @crossplatform 495 * @since 20 496 */ 497 CLOCKWISE = 0, 498 499 /** 500 * Adds a closed contour counterclockwise. 501 * @syscap SystemCapability.Graphics.Drawing 502 * @since 12 503 */ 504 /** 505 * Adds a closed contour counterclockwise. 506 * @syscap SystemCapability.Graphics.Drawing 507 * @crossplatform 508 * @since 20 509 */ 510 COUNTER_CLOCKWISE = 1, 511 } 512 513 /** 514 * Enumerates the fill types of a path. 515 * @enum { number } 516 * @syscap SystemCapability.Graphics.Drawing 517 * @since 12 518 */ 519 /** 520 * Enumerates the fill types of a path. 521 * @enum { number } 522 * @syscap SystemCapability.Graphics.Drawing 523 * @crossplatform 524 * @since 20 525 */ 526 enum PathFillType { 527 /** 528 * Specifies that "inside" is computed by a non-zero sum of signed edge crossings. Specifically, draws a point and emits a ray in any direction. 529 * A count is used to record the number of intersection points of the ray and path, and the initial count is 0. 530 * When encountering a clockwise intersection point (the path passes from the left to the right of the ray), the count increases by 1. 531 * When encountering a counterclockwise intersection point (the path passes from the right to the left of the ray), the count decreases by 1. 532 * If the final count is not 0, the point is inside the path and needs to be colored. If the final count is 0, the point is not colored. 533 * @syscap SystemCapability.Graphics.Drawing 534 * @since 12 535 */ 536 /** 537 * Specifies that "inside" is computed by a non-zero sum of signed edge crossings. Specifically, draws a point and emits a ray in any direction. 538 * A count is used to record the number of intersection points of the ray and path, and the initial count is 0. 539 * When encountering a clockwise intersection point (the path passes from the left to the right of the ray), the count increases by 1. 540 * When encountering a counterclockwise intersection point (the path passes from the right to the left of the ray), the count decreases by 1. 541 * If the final count is not 0, the point is inside the path and needs to be colored. If the final count is 0, the point is not colored. 542 * @syscap SystemCapability.Graphics.Drawing 543 * @crossplatform 544 * @since 20 545 */ 546 WINDING = 0, 547 548 /** 549 * Specifies that "inside" is computed by an odd number of edge crossings. Specifically, draws a point and emits a ray in any direction. 550 * If the number of intersection points of the ray and path is an odd number, the point is considered to be inside the path and needs to be colored. 551 * If the number is an even number, the point is not colored. 552 * @syscap SystemCapability.Graphics.Drawing 553 * @since 12 554 */ 555 /** 556 * Specifies that "inside" is computed by an odd number of edge crossings. Specifically, draws a point and emits a ray in any direction. 557 * If the number of intersection points of the ray and path is an odd number, the point is considered to be inside the path and needs to be colored. 558 * If the number is an even number, the point is not colored. 559 * @syscap SystemCapability.Graphics.Drawing 560 * @crossplatform 561 * @since 20 562 */ 563 EVEN_ODD = 1, 564 565 /** 566 * Same as WINDING, but draws outside of the path, rather than inside. 567 * @syscap SystemCapability.Graphics.Drawing 568 * @since 12 569 */ 570 /** 571 * Same as WINDING, but draws outside of the path, rather than inside. 572 * @syscap SystemCapability.Graphics.Drawing 573 * @crossplatform 574 * @since 20 575 */ 576 INVERSE_WINDING = 2, 577 578 /** 579 * Same as EVEN_ODD, but draws outside of the path, rather than inside. 580 * @syscap SystemCapability.Graphics.Drawing 581 * @since 12 582 */ 583 /** 584 * Same as EVEN_ODD, but draws outside of the path, rather than inside. 585 * @syscap SystemCapability.Graphics.Drawing 586 * @crossplatform 587 * @since 20 588 */ 589 INVERSE_EVEN_ODD = 3, 590 } 591 592 /** 593 * Enumerates the dimensions of matrix information in path measurement. 594 * It is often used in animation scenarios where objects move along a path. 595 * @enum { number } 596 * @syscap SystemCapability.Graphics.Drawing 597 * @since 12 598 */ 599 /** 600 * Enumerates the dimensions of matrix information in path measurement. 601 * It is often used in animation scenarios where objects move along a path. 602 * @enum { number } 603 * @syscap SystemCapability.Graphics.Drawing 604 * @crossplatform 605 * @since 20 606 */ 607 enum PathMeasureMatrixFlags { 608 /** 609 * Matrix corresponding to the position information. 610 * @syscap SystemCapability.Graphics.Drawing 611 * @since 12 612 */ 613 /** 614 * Matrix corresponding to the position information. 615 * @syscap SystemCapability.Graphics.Drawing 616 * @crossplatform 617 * @since 20 618 */ 619 GET_POSITION_MATRIX = 0, 620 /** 621 * Matrix corresponding to the tangent information. 622 * @syscap SystemCapability.Graphics.Drawing 623 * @since 12 624 */ 625 /** 626 * Matrix corresponding to the tangent information. 627 * @syscap SystemCapability.Graphics.Drawing 628 * @crossplatform 629 * @since 20 630 */ 631 GET_TANGENT_MATRIX = 1, 632 /** 633 * Matrix corresponding to the position and tangent information. 634 * @syscap SystemCapability.Graphics.Drawing 635 * @since 12 636 */ 637 /** 638 * Matrix corresponding to the position and tangent information. 639 * @syscap SystemCapability.Graphics.Drawing 640 * @crossplatform 641 * @since 20 642 */ 643 GET_POSITION_AND_TANGENT_MATRIX = 2, 644 } 645 646 /** 647 * Implements a rounded rectangle. 648 * 649 * @syscap SystemCapability.Graphics.Drawing 650 * @since 12 651 */ 652 /** 653 * Implements a rounded rectangle. 654 * 655 * @syscap SystemCapability.Graphics.Drawing 656 * @crossplatform 657 * @since 20 658 * @arkts 1.1&1.2 659 */ 660 class RoundRect { 661 662 /** 663 * Creates a deep copy of the specified round rect object. 664 * @param { RoundRect } roundRect - The round rect object to copy. 665 * @syscap SystemCapability.Graphics.Drawing 666 * @crossplatform 667 * @since 20 668 * @arkts 1.1&1.2 669 */ 670 constructor(roundRect: RoundRect); 671 672 /** 673 * A constructor used to create a RoundRect object. A rounded rectangle is created when both xRadii and yRadii are greater than 0. 674 * Otherwise, only a rectangle is created. 675 * @param { common2D.Rect } rect - Rectangle that encloses the rounded rectangle to create. 676 * @param { number } xRadii - Radius of the rounded corner on the X axis. The value is a floating point number. A negative number is invalid. 677 * @param { number } yRadii - Radius of the rounded corner on the Y axis. The value is a floating point number. A negative number is invalid. 678 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 679 * <br>2. Incorrect parameter types. 680 * @syscap SystemCapability.Graphics.Drawing 681 * @since 12 682 */ 683 /** 684 * A constructor used to create a RoundRect object. A rounded rectangle is created when both xRadii and yRadii are greater than 0. 685 * Otherwise, only a rectangle is created. 686 * @param { common2D.Rect } rect - Rectangle that encloses the rounded rectangle to create. 687 * @param { number } xRadii - Radius of the rounded corner on the X axis. The value is a floating point number. A negative number is invalid. 688 * @param { number } yRadii - Radius of the rounded corner on the Y axis. The value is a floating point number. A negative number is invalid. 689 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 690 * <br>2. Incorrect parameter types. 691 * @syscap SystemCapability.Graphics.Drawing 692 * @crossplatform 693 * @since 20 694 * @arkts 1.1&1.2 695 */ 696 constructor(rect: common2D.Rect, xRadii: number, yRadii: number); 697 698 /** 699 * Sets the radii of the specified rounded corner in this rounded rectangle. 700 * @param { CornerPos } pos - Position of the rounded corner. 701 * @param { number } x - Radius of the rounded corner on the X axis. The value is a floating point number. A negative number is invalid. 702 * @param { number } y - Radius of the rounded corner on the Y axis. The value is a floating point number. A negative number is invalid. 703 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 704 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 705 * @syscap SystemCapability.Graphics.Drawing 706 * @since 12 707 */ 708 /** 709 * Sets the radii of the specified rounded corner in this rounded rectangle. 710 * @param { CornerPos } pos - Position of the rounded corner. 711 * @param { number } x - Radius of the rounded corner on the X axis. The value is a floating point number. A negative number is invalid. 712 * @param { number } y - Radius of the rounded corner on the Y axis. The value is a floating point number. A negative number is invalid. 713 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 714 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 715 * @syscap SystemCapability.Graphics.Drawing 716 * @crossplatform 717 * @since 20 718 */ 719 setCorner(pos: CornerPos, x: number, y: number): void; 720 721 /** 722 * Obtains the radii of the specified rounded corner in this rounded rectangle. 723 * @param { CornerPos } pos - Position of the rounded corner. 724 * @returns { common2D.Point } Point. The horizontal coordinate indicates the radius of the rounded corner on the X axis, 725 * and the vertical coordinate indicates the radius on the Y axis. 726 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 727 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 728 * @syscap SystemCapability.Graphics.Drawing 729 * @since 12 730 */ 731 /** 732 * Obtains the radii of the specified rounded corner in this rounded rectangle. 733 * @param { CornerPos } pos - Position of the rounded corner. 734 * @returns { common2D.Point } Point. The horizontal coordinate indicates the radius of the rounded corner on the X axis, 735 * and the vertical coordinate indicates the radius on the Y axis. 736 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 737 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 738 * @syscap SystemCapability.Graphics.Drawing 739 * @crossplatform 740 * @since 20 741 */ 742 getCorner(pos: CornerPos): common2D.Point; 743 744 /** 745 * Translates this rounded rectangle by an offset along the X axis and Y axis. 746 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 747 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 748 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 749 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 750 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 751 * <br>2. Incorrect parameter types. 752 * @syscap SystemCapability.Graphics.Drawing 753 * @since 12 754 */ 755 /** 756 * Translates this rounded rectangle by an offset along the X axis and Y axis. 757 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 758 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 759 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 760 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 761 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 762 * <br>2. Incorrect parameter types. 763 * @syscap SystemCapability.Graphics.Drawing 764 * @crossplatform 765 * @since 20 766 */ 767 offset(dx: number, dy: number): void; 768 } 769 770 /** 771 * Enumerates the path operation types. It is often used in path combination and clipping scenarios. 772 * @enum { number } 773 * @syscap SystemCapability.Graphics.Drawing 774 * @since 12 775 */ 776 /** 777 * Enumerates the path operation types. It is often used in path combination and clipping scenarios. 778 * @enum { number } 779 * @syscap SystemCapability.Graphics.Drawing 780 * @crossplatform 781 * @since 20 782 * @arkts 1.1&1.2 783 */ 784 enum PathOp { 785 /** 786 * Difference operation. 787 * @syscap SystemCapability.Graphics.Drawing 788 * @since 12 789 */ 790 /** 791 * Difference operation. 792 * @syscap SystemCapability.Graphics.Drawing 793 * @crossplatform 794 * @since 20 795 * @arkts 1.1&1.2 796 */ 797 DIFFERENCE = 0, 798 799 /** 800 * Intersection operation. 801 * @syscap SystemCapability.Graphics.Drawing 802 * @since 12 803 */ 804 /** 805 * Intersection operation. 806 * @syscap SystemCapability.Graphics.Drawing 807 * @crossplatform 808 * @since 20 809 * @arkts 1.1&1.2 810 */ 811 INTERSECT = 1, 812 813 /** 814 * Union operation. 815 * @syscap SystemCapability.Graphics.Drawing 816 * @since 12 817 */ 818 /** 819 * Union operation. 820 * @syscap SystemCapability.Graphics.Drawing 821 * @crossplatform 822 * @since 20 823 * @arkts 1.1&1.2 824 */ 825 UNION = 2, 826 827 /** 828 * XOR operation. 829 * @syscap SystemCapability.Graphics.Drawing 830 * @since 12 831 */ 832 /** 833 * XOR operation. 834 * @syscap SystemCapability.Graphics.Drawing 835 * @crossplatform 836 * @since 20 837 * @arkts 1.1&1.2 838 */ 839 XOR = 3, 840 841 /** 842 * Reverse difference operation. 843 * @syscap SystemCapability.Graphics.Drawing 844 * @since 12 845 */ 846 /** 847 * Reverse difference operation. 848 * @syscap SystemCapability.Graphics.Drawing 849 * @crossplatform 850 * @since 20 851 * @arkts 1.1&1.2 852 */ 853 REVERSE_DIFFERENCE = 4, 854 } 855 856 /** 857 * Enumerates the path operation types contained in an iterator. It is used to read path operation instructions. 858 * @enum { number } 859 * @syscap SystemCapability.Graphics.Drawing 860 * @since 18 861 */ 862 /** 863 * Enumerates the path operation types contained in an iterator. It is used to read path operation instructions. 864 * @enum { number } 865 * @syscap SystemCapability.Graphics.Drawing 866 * @crossplatform 867 * @since 20 868 */ 869 enum PathIteratorVerb { 870 /** 871 * Sets the start point. 872 * @syscap SystemCapability.Graphics.Drawing 873 * @since 18 874 */ 875 /** 876 * Sets the start point. 877 * @syscap SystemCapability.Graphics.Drawing 878 * @crossplatform 879 * @since 20 880 */ 881 MOVE = 0, 882 883 /** 884 * Adds a line segment. 885 * @syscap SystemCapability.Graphics.Drawing 886 * @since 18 887 */ 888 /** 889 * Adds a line segment. 890 * @syscap SystemCapability.Graphics.Drawing 891 * @crossplatform 892 * @since 20 893 */ 894 LINE = 1, 895 896 /** 897 * Adds a quadratic Bezier curve for smooth transitions. 898 * @syscap SystemCapability.Graphics.Drawing 899 * @since 18 900 */ 901 /** 902 * Adds a quadratic Bezier curve for smooth transitions. 903 * @syscap SystemCapability.Graphics.Drawing 904 * @crossplatform 905 * @since 20 906 */ 907 QUAD = 2, 908 909 /** 910 * Adds a conic curve. 911 * @syscap SystemCapability.Graphics.Drawing 912 * @since 18 913 */ 914 /** 915 * Adds a conic curve. 916 * @syscap SystemCapability.Graphics.Drawing 917 * @crossplatform 918 * @since 20 919 */ 920 CONIC = 3, 921 922 /** 923 * Adds a cubic Bezier curve for smooth transitions. 924 * @syscap SystemCapability.Graphics.Drawing 925 * @since 18 926 */ 927 /** 928 * Adds a cubic Bezier curve for smooth transitions. 929 * @syscap SystemCapability.Graphics.Drawing 930 * @crossplatform 931 * @since 20 932 */ 933 CUBIC = 4, 934 935 /** 936 * Closes a path. 937 * @syscap SystemCapability.Graphics.Drawing 938 * @since 18 939 */ 940 /** 941 * Closes a path. 942 * @syscap SystemCapability.Graphics.Drawing 943 * @crossplatform 944 * @since 20 945 */ 946 CLOSE = 5, 947 948 /** 949 * The path setting is complete. 950 * @syscap SystemCapability.Graphics.Drawing 951 * @since 18 952 */ 953 /** 954 * The path setting is complete. 955 * @syscap SystemCapability.Graphics.Drawing 956 * @crossplatform 957 * @since 20 958 */ 959 DONE = CLOSE + 1, 960 } 961 962 /** 963 * Implements a path operation iterator. You can read path operation instructions by traversing the iterator. 964 * 965 * @syscap SystemCapability.Graphics.Drawing 966 * @since 18 967 */ 968 /** 969 * Implements a path operation iterator. You can read path operation instructions by traversing the iterator. 970 * 971 * @syscap SystemCapability.Graphics.Drawing 972 * @crossplatform 973 * @since 20 974 * @arkts 1.1&1.2 975 */ 976 class PathIterator { 977 /** 978 * Creates an iterator and binds it with a path. 979 * @param { Path } path - Path object bound to the iterator. 980 * @syscap SystemCapability.Graphics.Drawing 981 * @since 18 982 */ 983 /** 984 * Creates an iterator and binds it with a path. 985 * @param { Path } path - Path object bound to the iterator. 986 * @syscap SystemCapability.Graphics.Drawing 987 * @crossplatform 988 * @since 20 989 * @arkts 1.1&1.2 990 */ 991 constructor(path: Path); 992 993 /** 994 * Retrieves the next operation in this path and moves the iterator to that operation. 995 * @param { Array<common2D.Point> } points - Indicates the point array. 996 * @param { number } offset - Indicates the offset into the array where entries should be placed. The default value is 0. 997 * @returns { PathIteratorVerb } Returns the next verb in this iterator's path. 998 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 999 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1000 * @syscap SystemCapability.Graphics.Drawing 1001 * @since 18 1002 */ 1003 /** 1004 * Retrieves the next operation in this path and moves the iterator to that operation. 1005 * @param { Array<common2D.Point> } points - Indicates the point array. 1006 * @param { number } offset - Indicates the offset into the array where entries should be placed. The default value is 0. 1007 * @returns { PathIteratorVerb } Returns the next verb in this iterator's path. 1008 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1009 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1010 * @syscap SystemCapability.Graphics.Drawing 1011 * @crossplatform 1012 * @since 20 1013 */ 1014 next(points: Array<common2D.Point>, offset?: number): PathIteratorVerb; 1015 1016 /** 1017 * Retrieves the next operation in this path, without moving the iterator. 1018 * @returns { PathIteratorVerb } Returns the next verb in the iteration. 1019 * @syscap SystemCapability.Graphics.Drawing 1020 * @since 18 1021 */ 1022 /** 1023 * Retrieves the next operation in this path, without moving the iterator. 1024 * @returns { PathIteratorVerb } Returns the next verb in the iteration. 1025 * @syscap SystemCapability.Graphics.Drawing 1026 * @crossplatform 1027 * @since 20 1028 */ 1029 peek(): PathIteratorVerb; 1030 1031 /** 1032 * Checks whether there is a next operation in the path operation iterator. 1033 * @returns { boolean } Returns true if there are more elements to be iterated through, false otherwise. 1034 * @syscap SystemCapability.Graphics.Drawing 1035 * @since 18 1036 */ 1037 /** 1038 * Checks whether there is a next operation in the path operation iterator. 1039 * @returns { boolean } Returns true if there are more elements to be iterated through, false otherwise. 1040 * @syscap SystemCapability.Graphics.Drawing 1041 * @crossplatform 1042 * @since 20 1043 */ 1044 hasNext(): boolean; 1045 } 1046 1047 /** 1048 * A compound geometric path consisting of line segments, arcs, quadratic Bezier curves, and cubic Bezier curves. 1049 * 1050 * @syscap SystemCapability.Graphics.Drawing 1051 * @since 11 1052 */ 1053 /** 1054 * A compound geometric path consisting of line segments, arcs, quadratic Bezier curves, and cubic Bezier curves. 1055 * 1056 * @syscap SystemCapability.Graphics.Drawing 1057 * @crossplatform 1058 * @since 20 1059 * @arkts 1.1&1.2 1060 */ 1061 class Path { 1062 /** 1063 * Constructs a path. 1064 * @syscap SystemCapability.Graphics.Drawing 1065 * @since 12 1066 */ 1067 /** 1068 * Constructs a path. 1069 * @syscap SystemCapability.Graphics.Drawing 1070 * @crossplatform 1071 * @since 20 1072 * @arkts 1.1&1.2 1073 */ 1074 constructor(); 1075 1076 /** 1077 * Constructs a copy of an existing path. 1078 * @param { Path } path - Path to copy. 1079 * @syscap SystemCapability.Graphics.Drawing 1080 * @since 12 1081 */ 1082 /** 1083 * Constructs a copy of an existing path. 1084 * @param { Path } path - Path to copy. 1085 * @syscap SystemCapability.Graphics.Drawing 1086 * @crossplatform 1087 * @since 20 1088 * @arkts 1.1&1.2 1089 */ 1090 constructor(path: Path); 1091 1092 /** 1093 * Sets the Path with the same content of another. 1094 * @param { Path } src - the path to copy content from. 1095 * @syscap SystemCapability.Graphics.Drawing 1096 * @crossplatform 1097 * @since 20 1098 */ 1099 set(src: Path): void; 1100 1101 /** 1102 * Sets the start point of this path. 1103 * @param { number } x - X coordinate of the start point. The value is a floating point number. 1104 * @param { number } y - Y coordinate of the start point. The value is a floating point number. 1105 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1106 * <br>2. Incorrect parameter types. 1107 * @syscap SystemCapability.Graphics.Drawing 1108 * @since 11 1109 */ 1110 /** 1111 * Sets the start point of this path. 1112 * @param { number } x - X coordinate of the start point. The value is a floating point number. 1113 * @param { number } y - Y coordinate of the start point. The value is a floating point number. 1114 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1115 * <br>2. Incorrect parameter types. 1116 * @syscap SystemCapability.Graphics.Drawing 1117 * @crossplatform 1118 * @since 20 1119 */ 1120 moveTo(x: number, y: number): void; 1121 1122 /** 1123 * Draws a line segment from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1124 * @param { number } x - X coordinate of the target point. The value is a floating point number. 1125 * @param { number } y - Y coordinate of the target point. The value is a floating point number. 1126 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1127 * <br>2. Incorrect parameter types. 1128 * @syscap SystemCapability.Graphics.Drawing 1129 * @since 11 1130 */ 1131 /** 1132 * Draws a line segment from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1133 * @param { number } x - X coordinate of the target point. The value is a floating point number. 1134 * @param { number } y - Y coordinate of the target point. The value is a floating point number. 1135 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1136 * <br>2. Incorrect parameter types. 1137 * @syscap SystemCapability.Graphics.Drawing 1138 * @crossplatform 1139 * @since 20 1140 */ 1141 lineTo(x: number, y: number): void; 1142 1143 /** 1144 * Draws an arc to this path using angle arc mode. This mode first defines a rectangle and takes its inscribed ellipse. 1145 * Then, it specifies a start angle and a sweep angle. The arc is the portion of the ellipse's circumference defined by the start angle 1146 * and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. 1147 * @param { number } x1 - X coordinate of the upper left corner of the rectangle. The value is a floating point number. 1148 * @param { number } y1 - Y coordinate of the upper left corner of the rectangle. The value is a floating point number. 1149 * @param { number } x2 - X coordinate of the lower right corner of the rectangle. The value is a floating point number. 1150 * @param { number } y2 - Y coordinate of the lower right corner of the rectangle. The value is a floating point number. 1151 * @param { number } startDeg - Start angle. The start direction (0°) of the angle is the positive direction of the X axis. 1152 * @param { number } sweepDeg - Angle to sweep, in degrees. A positive number indicates a clockwise sweep, 1153 * and a negative value indicates a counterclockwise swipe. The actual swipe degree is the modulo operation result of the input parameter by 360. 1154 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1155 * <br>2. Incorrect parameter types. 1156 * @syscap SystemCapability.Graphics.Drawing 1157 * @since 11 1158 */ 1159 /** 1160 * Draws an arc to this path using angle arc mode. This mode first defines a rectangle and takes its inscribed ellipse. 1161 * Then, it specifies a start angle and a sweep angle. The arc is the portion of the ellipse's circumference defined by the start angle 1162 * and the sweep angle. By default, a line segment from the last point of the path to the start point of the arc is also added. 1163 * @param { number } x1 - X coordinate of the upper left corner of the rectangle. The value is a floating point number. 1164 * @param { number } y1 - Y coordinate of the upper left corner of the rectangle. The value is a floating point number. 1165 * @param { number } x2 - X coordinate of the lower right corner of the rectangle. The value is a floating point number. 1166 * @param { number } y2 - Y coordinate of the lower right corner of the rectangle. The value is a floating point number. 1167 * @param { number } startDeg - Start angle. The start direction (0°) of the angle is the positive direction of the X axis. 1168 * @param { number } sweepDeg - Angle to sweep, in degrees. A positive number indicates a clockwise sweep, 1169 * and a negative value indicates a counterclockwise swipe. The actual swipe degree is the modulo operation result of the input parameter by 360. 1170 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1171 * <br>2. Incorrect parameter types. 1172 * @syscap SystemCapability.Graphics.Drawing 1173 * @crossplatform 1174 * @since 20 1175 * @arkts 1.1&1.2 1176 */ 1177 arcTo(x1: number, y1: number, x2: number, y2: number, startDeg: number, sweepDeg: number): void; 1178 1179 /** 1180 * Draws a quadratic Bezier curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1181 * @param { number } ctrlX - X coordinate of the control point. The value is a floating point number. 1182 * @param { number } ctrlY - Y coordinate of the control point. The value is a floating point number. 1183 * @param { number } endX - X coordinate of the target point. The value is a floating point number. 1184 * @param { number } endY - Y coordinate of the target point. The value is a floating point number. 1185 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1186 * <br>2. Incorrect parameter types. 1187 * @syscap SystemCapability.Graphics.Drawing 1188 * @since 11 1189 */ 1190 /** 1191 * Draws a quadratic Bezier curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1192 * @param { number } ctrlX - X coordinate of the control point. The value is a floating point number. 1193 * @param { number } ctrlY - Y coordinate of the control point. The value is a floating point number. 1194 * @param { number } endX - X coordinate of the target point. The value is a floating point number. 1195 * @param { number } endY - Y coordinate of the target point. The value is a floating point number. 1196 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1197 * <br>2. Incorrect parameter types. 1198 * @syscap SystemCapability.Graphics.Drawing 1199 * @crossplatform 1200 * @since 20 1201 */ 1202 quadTo(ctrlX: number, ctrlY: number, endX: number, endY: number): void; 1203 1204 /** 1205 * Draws a conic curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1206 * @param { number } ctrlX - X coordinate of the control point. The value is a floating point number. 1207 * @param { number } ctrlY - Y coordinate of the control point. The value is a floating point number. 1208 * @param { number } endX - X coordinate of the target point. The value is a floating point number. 1209 * @param { number } endY - Y coordinate of the target point. The value is a floating point number. 1210 * @param { number } weight - Weight of the curve, which determines its shape. The larger the value, 1211 * the closer of the curve to the control point. If the value is less than or equal to 0, 1212 * this API has the same effect as lineTo. If the value is 1, it has the same effect as quadTo. The value is a floating point number. 1213 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1214 * <br>2. Incorrect parameter types. 1215 * @syscap SystemCapability.Graphics.Drawing 1216 * @since 12 1217 */ 1218 /** 1219 * Draws a conic curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1220 * @param { number } ctrlX - X coordinate of the control point. The value is a floating point number. 1221 * @param { number } ctrlY - Y coordinate of the control point. The value is a floating point number. 1222 * @param { number } endX - X coordinate of the target point. The value is a floating point number. 1223 * @param { number } endY - Y coordinate of the target point. The value is a floating point number. 1224 * @param { number } weight - Weight of the curve, which determines its shape. The larger the value, 1225 * the closer of the curve to the control point. If the value is less than or equal to 0, 1226 * this API has the same effect as lineTo. If the value is 1, it has the same effect as quadTo. The value is a floating point number. 1227 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1228 * <br>2. Incorrect parameter types. 1229 * @syscap SystemCapability.Graphics.Drawing 1230 * @crossplatform 1231 * @since 20 1232 */ 1233 conicTo(ctrlX: number, ctrlY: number, endX: number, endY: number, weight: number): void; 1234 1235 /** 1236 * Draws a cubic Bezier curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1237 * @param { number } ctrlX1 - X coordinate of the first control point. The value is a floating point number. 1238 * @param { number } ctrlY1 - Y coordinate of the first control point. The value is a floating point number. 1239 * @param { number } ctrlX2 - X coordinate of the second control point. The value is a floating point number. 1240 * @param { number } ctrlY2 - Y coordinate of the second control point. The value is a floating point number. 1241 * @param { number } endX - X coordinate of the target point. The value is a floating point number. 1242 * @param { number } endY - Y coordinate of the target point. The value is a floating point number. 1243 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1244 * <br>2. Incorrect parameter types. 1245 * @syscap SystemCapability.Graphics.Drawing 1246 * @since 11 1247 */ 1248 /** 1249 * Draws a cubic Bezier curve from the last point of this path to the target point. If the path is empty, the start point (0, 0) is used. 1250 * @param { number } ctrlX1 - X coordinate of the first control point. The value is a floating point number. 1251 * @param { number } ctrlY1 - Y coordinate of the first control point. The value is a floating point number. 1252 * @param { number } ctrlX2 - X coordinate of the second control point. The value is a floating point number. 1253 * @param { number } ctrlY2 - Y coordinate of the second control point. The value is a floating point number. 1254 * @param { number } endX - X coordinate of the target point. The value is a floating point number. 1255 * @param { number } endY - Y coordinate of the target point. The value is a floating point number. 1256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1257 * <br>2. Incorrect parameter types. 1258 * @syscap SystemCapability.Graphics.Drawing 1259 * @crossplatform 1260 * @since 20 1261 */ 1262 cubicTo(ctrlX1: number, ctrlY1: number, ctrlX2: number, ctrlY2: number, endX: number, endY: number): void; 1263 1264 /** 1265 * Sets the start position relative to the last point of this path. If the path is empty, the start point (0, 0) is used. 1266 * @param { number } dx - X offset of the start point relative to the last point. A positive number indicates a rightward shift from the last point, 1267 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1268 * @param { number } dy - Y offset of the start point relative to the last point. A positive number indicates an upward shift from the last point, 1269 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1270 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1271 * <br>2. Incorrect parameter types. 1272 * @syscap SystemCapability.Graphics.Drawing 1273 * @since 12 1274 */ 1275 /** 1276 * Sets the start position relative to the last point of this path. If the path is empty, the start point (0, 0) is used. 1277 * @param { number } dx - X offset of the start point relative to the last point. A positive number indicates a rightward shift from the last point, 1278 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1279 * @param { number } dy - Y offset of the start point relative to the last point. A positive number indicates an upward shift from the last point, 1280 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1281 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1282 * <br>2. Incorrect parameter types. 1283 * @syscap SystemCapability.Graphics.Drawing 1284 * @crossplatform 1285 * @since 20 1286 */ 1287 rMoveTo(dx: number, dy: number): void; 1288 1289 /** 1290 * Draws a line segment from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used. 1291 * @param { number } dx - X offset of the target point relative to the last point. A positive number indicates a rightward shift from the last point, 1292 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1293 * @param { number } dy - Y offset of the target point relative to the last point. A positive number indicates an upward shift from the last point, 1294 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1295 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1296 * <br>2. Incorrect parameter types. 1297 * @syscap SystemCapability.Graphics.Drawing 1298 * @since 12 1299 */ 1300 /** 1301 * Draws a line segment from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used. 1302 * @param { number } dx - X offset of the target point relative to the last point. A positive number indicates a rightward shift from the last point, 1303 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1304 * @param { number } dy - Y offset of the target point relative to the last point. A positive number indicates an upward shift from the last point, 1305 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1306 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1307 * <br>2. Incorrect parameter types. 1308 * @syscap SystemCapability.Graphics.Drawing 1309 * @crossplatform 1310 * @since 20 1311 */ 1312 rLineTo(dx: number, dy: number): void; 1313 1314 /** 1315 * Draws a quadratic Bezier curve from the last point of this path to a point relative to the last point. 1316 * If the path is empty, the start point (0, 0) is used. 1317 * @param { number } dx1 - X offset of the control point relative to the last point. A positive number indicates a rightward shift from the last point, 1318 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1319 * @param { number } dy1 - Y offset of the control point relative to the last point. A positive number indicates an upward shift from the last point, 1320 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1321 * @param { number } dx2 - X offset of the target point relative to the last point. A positive number indicates a rightward shift from the last point, 1322 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1323 * @param { number } dy2 - Y offset of the target point relative to the last point. A positive number indicates an upward shift from the last point, 1324 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1325 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1326 * <br>2. Incorrect parameter types. 1327 * @syscap SystemCapability.Graphics.Drawing 1328 * @since 12 1329 */ 1330 /** 1331 * Draws a quadratic Bezier curve from the last point of this path to a point relative to the last point. 1332 * If the path is empty, the start point (0, 0) is used. 1333 * @param { number } dx1 - X offset of the control point relative to the last point. A positive number indicates a rightward shift from the last point, 1334 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1335 * @param { number } dy1 - Y offset of the control point relative to the last point. A positive number indicates an upward shift from the last point, 1336 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1337 * @param { number } dx2 - X offset of the target point relative to the last point. A positive number indicates a rightward shift from the last point, 1338 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1339 * @param { number } dy2 - Y offset of the target point relative to the last point. A positive number indicates an upward shift from the last point, 1340 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1341 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1342 * <br>2. Incorrect parameter types. 1343 * @syscap SystemCapability.Graphics.Drawing 1344 * @crossplatform 1345 * @since 20 1346 */ 1347 rQuadTo(dx1: number, dy1: number, dx2: number, dy2: number): void; 1348 1349 /** 1350 * Draws a conic curve from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used. 1351 * @param { number } ctrlX - X offset of the control point relative to the last point. A positive number indicates a rightward shift from the last point, 1352 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1353 * @param { number } ctrlY - Y offset of the control point relative to the last point. A positive number indicates an upward shift from the last point, 1354 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1355 * @param { number } endX - X offset of the target point relative to the last point. A positive number indicates a rightward shift from the last point, 1356 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1357 * @param { number } endY - Y offset of the target point relative to the last point. A positive number indicates an upward shift from the last point, 1358 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1359 * @param { number } weight - Weight of the curve, which determines its shape. The larger the value, the closer of the curve to the control point. 1360 * If the value is less than or equal to 0, this API is equivalent to rLineTo, that is, adding a line segment from the last point of the path 1361 * to the target point. If the value is 1, this API is equivalent to rQuadTo. The value is a floating point number. 1362 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1363 * <br>2. Incorrect parameter types. 1364 * @syscap SystemCapability.Graphics.Drawing 1365 * @since 12 1366 */ 1367 /** 1368 * Draws a conic curve from the last point of this path to a point relative to the last point. If the path is empty, the start point (0, 0) is used. 1369 * @param { number } ctrlX - X offset of the control point relative to the last point. A positive number indicates a rightward shift from the last point, 1370 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1371 * @param { number } ctrlY - Y offset of the control point relative to the last point. A positive number indicates an upward shift from the last point, 1372 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1373 * @param { number } endX - X offset of the target point relative to the last point. A positive number indicates a rightward shift from the last point, 1374 * and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1375 * @param { number } endY - Y offset of the target point relative to the last point. A positive number indicates an upward shift from the last point, 1376 * and a negative number indicates a downward shift from the last point. The value is a floating point number. 1377 * @param { number } weight - Weight of the curve, which determines its shape. The larger the value, the closer of the curve to the control point. 1378 * If the value is less than or equal to 0, this API is equivalent to rLineTo, that is, adding a line segment from the last point of the path 1379 * to the target point. If the value is 1, this API is equivalent to rQuadTo. The value is a floating point number. 1380 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1381 * <br>2. Incorrect parameter types. 1382 * @syscap SystemCapability.Graphics.Drawing 1383 * @crossplatform 1384 * @since 20 1385 */ 1386 rConicTo(ctrlX: number, ctrlY: number, endX: number, endY: number, weight: number): void; 1387 1388 /** 1389 * Draws a cubic Bezier curve from the last point of this path to a point relative to the last point. 1390 * If the path is empty, the start point (0, 0) is used. 1391 * @param { number } ctrlX1 - X offset of the first control point relative to the last point. A positive number indicates a rightward shift 1392 * from the last point, and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1393 * @param { number } ctrlY1 - Y offset of the first control point relative to the last point. A positive number indicates an upward shift 1394 * from the last point, and a negative number indicates a downward shift from the last point. The value is a floating point number. 1395 * @param { number } ctrlX2 - X offset of the second control point relative to the last point. A positive number indicates a rightward shift 1396 * from the last point, and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1397 * @param { number } ctrlY2 - Y offset of the second control point relative to the last point. A positive number indicates an upward shift 1398 * from the last point, and a negative number indicates a downward shift from the last point. The value is a floating point number. 1399 * @param { number } endX - X offset of the target point relative to the last point. A positive number indicates a rightward shift 1400 * from the last point, and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1401 * @param { number } endY - Y offset of the target point relative to the last point. A positive number indicates an upward shift 1402 * from the last point, and a negative number indicates a downward shift from the last point. The value is a floating point number. 1403 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1404 * <br>2. Incorrect parameter types. 1405 * @syscap SystemCapability.Graphics.Drawing 1406 * @since 12 1407 */ 1408 /** 1409 * Draws a cubic Bezier curve from the last point of this path to a point relative to the last point. 1410 * If the path is empty, the start point (0, 0) is used. 1411 * @param { number } ctrlX1 - X offset of the first control point relative to the last point. A positive number indicates a rightward shift 1412 * from the last point, and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1413 * @param { number } ctrlY1 - Y offset of the first control point relative to the last point. A positive number indicates an upward shift 1414 * from the last point, and a negative number indicates a downward shift from the last point. The value is a floating point number. 1415 * @param { number } ctrlX2 - X offset of the second control point relative to the last point. A positive number indicates a rightward shift 1416 * from the last point, and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1417 * @param { number } ctrlY2 - Y offset of the second control point relative to the last point. A positive number indicates an upward shift 1418 * from the last point, and a negative number indicates a downward shift from the last point. The value is a floating point number. 1419 * @param { number } endX - X offset of the target point relative to the last point. A positive number indicates a rightward shift 1420 * from the last point, and a negative number indicates a leftward shift from the last point. The value is a floating point number. 1421 * @param { number } endY - Y offset of the target point relative to the last point. A positive number indicates an upward shift 1422 * from the last point, and a negative number indicates a downward shift from the last point. The value is a floating point number. 1423 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1424 * <br>2. Incorrect parameter types. 1425 * @syscap SystemCapability.Graphics.Drawing 1426 * @crossplatform 1427 * @since 20 1428 */ 1429 rCubicTo(ctrlX1: number, ctrlY1: number, ctrlX2: number, ctrlY2: number, endX: number, endY: number): void; 1430 1431 /** 1432 * Adds a polygon to this path. 1433 * @param { Array<common2D.Point> } points - Array that holds the vertex coordinates of the polygon. 1434 * @param { boolean } close - Whether to close the path, that is, whether to add a line segment from the start point 1435 * to the end point of the path. The value true means to close the path, and false means the opposite. 1436 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1437 * <br>2. Incorrect parameter types. 1438 * @syscap SystemCapability.Graphics.Drawing 1439 * @since 12 1440 */ 1441 /** 1442 * Adds a polygon to this path. 1443 * @param { Array<common2D.Point> } points - Array that holds the vertex coordinates of the polygon. 1444 * @param { boolean } close - Whether to close the path, that is, whether to add a line segment from the start point 1445 * to the end point of the path. The value true means to close the path, and false means the opposite. 1446 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1447 * <br>2. Incorrect parameter types. 1448 * @syscap SystemCapability.Graphics.Drawing 1449 * @crossplatform 1450 * @since 20 1451 */ 1452 addPolygon(points: Array<common2D.Point>, close: boolean): void; 1453 1454 /** 1455 * Combines this path with the passed-in path based on the specified operation mode. 1456 * @param { Path } path - Path object, which will be combined with the current path. 1457 * @param { PathOp } pathOp - Operation mode. 1458 * @returns { boolean } boolean - Result of the path combination result. The value true means that the path combination is successful, 1459 * and false means the opposite. 1460 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1461 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1462 * @syscap SystemCapability.Graphics.Drawing 1463 * @since 12 1464 */ 1465 /** 1466 * Combines this path with the passed-in path based on the specified operation mode. 1467 * @param { Path } path - Path object, which will be combined with the current path. 1468 * @param { PathOp } pathOp - Operation mode. 1469 * @returns { boolean } boolean - Result of the path combination result. The value true means that the path combination is successful, 1470 * and false means the opposite. 1471 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1472 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1473 * @syscap SystemCapability.Graphics.Drawing 1474 * @crossplatform 1475 * @since 20 1476 */ 1477 op(path: Path, pathOp: PathOp): boolean; 1478 1479 /** 1480 * Adds an arc to this path. 1481 * 1482 * When startAngle and sweepAngle meet the following conditions, an oval instead of an arc is added: 1483 * 1484 * The result of startAngle modulo 90 is close to 0. 1485 * The value of sweepAngle is not in the range of (-360, 360). 1486 * 1487 * In other cases, this API adds an arc by applying the result of sweepAngle modulo 360 to the path. 1488 * @param { common2D.Rect } rect - Rectangular boundary that encapsulates the oval including the arc. 1489 * @param { number } startAngle - Start angle of the arc, in degrees. The value 0 indicates the positive direction of the X axis. 1490 * The value is a floating point number. 1491 * @param { number } sweepAngle - Angle to sweep, in degrees. A positive number indicates a clockwise sweep, 1492 * and a negative number indicates a counterclockwise sweep. The value is a floating point number. 1493 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1494 * <br>2. Incorrect parameter types. 1495 * @syscap SystemCapability.Graphics.Drawing 1496 * @since 12 1497 */ 1498 /** 1499 * Adds an arc to this path. 1500 * 1501 * When startAngle and sweepAngle meet the following conditions, an oval instead of an arc is added: 1502 * 1503 * The result of startAngle modulo 90 is close to 0. 1504 * The value of sweepAngle is not in the range of (-360, 360). 1505 * 1506 * In other cases, this API adds an arc by applying the result of sweepAngle modulo 360 to the path. 1507 * @param { common2D.Rect } rect - Rectangular boundary that encapsulates the oval including the arc. 1508 * @param { number } startAngle - Start angle of the arc, in degrees. The value 0 indicates the positive direction of the X axis. 1509 * The value is a floating point number. 1510 * @param { number } sweepAngle - Angle to sweep, in degrees. A positive number indicates a clockwise sweep, 1511 * and a negative number indicates a counterclockwise sweep. The value is a floating point number. 1512 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1513 * <br>2. Incorrect parameter types. 1514 * @syscap SystemCapability.Graphics.Drawing 1515 * @crossplatform 1516 * @since 20 1517 */ 1518 addArc(rect: common2D.Rect, startAngle: number, sweepAngle: number): void; 1519 1520 /** 1521 * Adds a circle to this path in the specified direction. The start point of the circle is (x + radius, y). 1522 * @param { number } x - X coordinate of the center of the circle. The value is a floating point number. 1523 * @param { number } y - Y coordinate of the center of the circle. The value is a floating point number. 1524 * @param { number } radius - Radius of the circle. The value is a floating point number. 1525 * If the value is less than or equal to 0, there is no effect. 1526 * @param { PathDirection } pathDirection - Direction of the path. The default direction is clockwise. 1527 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1528 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1529 * @syscap SystemCapability.Graphics.Drawing 1530 * @since 12 1531 */ 1532 /** 1533 * Adds a circle to this path in the specified direction. The start point of the circle is (x + radius, y). 1534 * @param { number } x - X coordinate of the center of the circle. The value is a floating point number. 1535 * @param { number } y - Y coordinate of the center of the circle. The value is a floating point number. 1536 * @param { number } radius - Radius of the circle. The value is a floating point number. 1537 * If the value is less than or equal to 0, there is no effect. 1538 * @param { PathDirection } pathDirection - Direction of the path. The default direction is clockwise. 1539 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1540 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1541 * @syscap SystemCapability.Graphics.Drawing 1542 * @crossplatform 1543 * @since 20 1544 */ 1545 addCircle(x: number, y: number, radius: number, pathDirection?: PathDirection): void; 1546 1547 /** 1548 * Adds the inscribed ellipse of a rectangle to this path in the specified direction. 1549 * @param { common2D.Rect } rect - Rectangular boundary of the oval. 1550 * @param { number } start - Start point of the oval, where 0, 1, 2, and 3 correspond to the upper, right, lower, and left points, respectively. 1551 * The value is an integer greater than or equal to 0. If the value is greater than or equal to 4, the remainder of 4 is used. 1552 * @param { PathDirection } pathDirection - Direction of the path. The default direction is clockwise. 1553 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1554 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1555 * @syscap SystemCapability.Graphics.Drawing 1556 * @since 12 1557 */ 1558 /** 1559 * Adds the inscribed ellipse of a rectangle to this path in the specified direction. 1560 * @param { common2D.Rect } rect - Rectangular boundary of the oval. 1561 * @param { number } start - Start point of the oval, where 0, 1, 2, and 3 correspond to the upper, right, lower, and left points, respectively. 1562 * The value is an integer greater than or equal to 0. If the value is greater than or equal to 4, the remainder of 4 is used. 1563 * @param { PathDirection } pathDirection - Direction of the path. The default direction is clockwise. 1564 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1565 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1566 * @syscap SystemCapability.Graphics.Drawing 1567 * @crossplatform 1568 * @since 20 1569 */ 1570 addOval(rect: common2D.Rect, start: number, pathDirection?: PathDirection): void; 1571 1572 /** 1573 * Adds a rectangle to this path in the specified direction. The start point is the upper left corner of the rectangle. 1574 * @param { common2D.Rect } rect - Rectangle. 1575 * @param { PathDirection } pathDirection - Direction of the path. The default direction is clockwise. 1576 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1577 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1578 * @syscap SystemCapability.Graphics.Drawing 1579 * @since 12 1580 */ 1581 /** 1582 * Adds a rectangle to this path in the specified direction. The start point is the upper left corner of the rectangle. 1583 * @param { common2D.Rect } rect - Rectangle. 1584 * @param { PathDirection } pathDirection - Direction of the path. The default direction is clockwise. 1585 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1586 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1587 * @syscap SystemCapability.Graphics.Drawing 1588 * @crossplatform 1589 * @since 20 1590 */ 1591 addRect(rect: common2D.Rect, pathDirection?: PathDirection): void; 1592 1593 /** 1594 * Adds a rounded rectangle to this path in the specified direction. When the path direction is clockwise, 1595 * the start point is at the intersection of the rounded rectangle's left boundary and its lower left corner. 1596 * When the path direction is counterclockwise, the start point is at the intersection point 1597 * between the left boundary and the upper left corner. 1598 * @param { RoundRect } roundRect - Rounded rectangle. 1599 * @param { PathDirection } pathDirection - The default value is CLOCKWISE. 1600 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1601 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1602 * @syscap SystemCapability.Graphics.Drawing 1603 * @since 12 1604 */ 1605 /** 1606 * Adds a rounded rectangle to this path in the specified direction. When the path direction is clockwise, 1607 * the start point is at the intersection of the rounded rectangle's left boundary and its lower left corner. 1608 * When the path direction is counterclockwise, the start point is at the intersection point 1609 * between the left boundary and the upper left corner. 1610 * @param { RoundRect } roundRect - Rounded rectangle. 1611 * @param { PathDirection } pathDirection - The default value is CLOCKWISE. 1612 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1613 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1614 * @syscap SystemCapability.Graphics.Drawing 1615 * @crossplatform 1616 * @since 20 1617 */ 1618 addRoundRect(roundRect: RoundRect, pathDirection?: PathDirection): void; 1619 1620 /** 1621 * Transforms the points in a path by a matrix and stores the resulting path in the current Path object. 1622 * @param { Path } path - Source Path object. 1623 * @param { Matrix | null } matrix - Matrix object. The default value is an identity matrix. 1624 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1625 * <br>2. Incorrect parameter types. 1626 * @syscap SystemCapability.Graphics.Drawing 1627 * @since 12 1628 */ 1629 /** 1630 * Transforms the points in a path by a matrix and stores the resulting path in the current Path object. 1631 * @param { Path } path - Source Path object. 1632 * @param { Matrix | null } matrix - Matrix object. The default value is an identity matrix. 1633 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1634 * <br>2. Incorrect parameter types. 1635 * @syscap SystemCapability.Graphics.Drawing 1636 * @crossplatform 1637 * @since 20 1638 */ 1639 addPath(path: Path, matrix?: Matrix | null): void; 1640 1641 /** 1642 * Transforms the points in this path by a matrix. 1643 * @param { Matrix } matrix - Matrix object. 1644 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1645 * <br>2. Incorrect parameter types. 1646 * @syscap SystemCapability.Graphics.Drawing 1647 * @since 12 1648 */ 1649 /** 1650 * Transforms the points in this path by a matrix. 1651 * @param { Matrix } matrix - Matrix object. 1652 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1653 * <br>2. Incorrect parameter types. 1654 * @syscap SystemCapability.Graphics.Drawing 1655 * @crossplatform 1656 * @since 20 1657 */ 1658 transform(matrix: Matrix): void; 1659 1660 /** 1661 * Checks whether a coordinate point is included in this path. For details, see PathFillType. 1662 * @param { number } x - X coordinate. The value is a floating point number. 1663 * @param { number } y - Y coordinate. The value is a floating point number. 1664 * @returns { boolean } Check result. The value true means that the coordinate point is included in the path, and false means the opposite. 1665 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1666 * <br>2. Incorrect parameter types. 1667 * @syscap SystemCapability.Graphics.Drawing 1668 * @since 12 1669 */ 1670 /** 1671 * Checks whether a coordinate point is included in this path. For details, see PathFillType. 1672 * @param { number } x - X coordinate. The value is a floating point number. 1673 * @param { number } y - Y coordinate. The value is a floating point number. 1674 * @returns { boolean } Check result. The value true means that the coordinate point is included in the path, and false means the opposite. 1675 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1676 * <br>2. Incorrect parameter types. 1677 * @syscap SystemCapability.Graphics.Drawing 1678 * @crossplatform 1679 * @since 20 1680 */ 1681 contains(x: number, y: number): boolean; 1682 1683 /** 1684 * Changes the last point of the path to specific value. 1685 * @param { number } x - Indicates the new x-axis value for the last point. 1686 * @param { number } y - Indicates the new y-axis value for the last point. 1687 * @syscap SystemCapability.Graphics.Drawing 1688 * @crossplatform 1689 * @since 20 1690 */ 1691 setLastPoint(x: number, y: number): void; 1692 1693 /** 1694 * Sets the fill type of this path. The fill type determines how "inside" of the path is drawn. 1695 * For example, when the fill type Winding is used, "inside" of the path is determined by a non-zero sum of signed edge crossings. 1696 * When EvenOdd is used, "inside" of the path is determined by an odd number of edge crossings. 1697 * @param { PathFillType } pathFillType - Fill type of the path. 1698 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1699 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1700 * @syscap SystemCapability.Graphics.Drawing 1701 * @since 12 1702 */ 1703 /** 1704 * Sets the fill type of this path. The fill type determines how "inside" of the path is drawn. 1705 * For example, when the fill type Winding is used, "inside" of the path is determined by a non-zero sum of signed edge crossings. 1706 * When EvenOdd is used, "inside" of the path is determined by an odd number of edge crossings. 1707 * @param { PathFillType } pathFillType - Fill type of the path. 1708 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1709 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1710 * @syscap SystemCapability.Graphics.Drawing 1711 * @crossplatform 1712 * @since 20 1713 */ 1714 setFillType(pathFillType: PathFillType): void; 1715 1716 /** 1717 * Gets fill type, the rule used to fill path. 1718 * @returns { PathFillType } Returns the pathFillType. 1719 * @syscap SystemCapability.Graphics.Drawing 1720 * @crossplatform 1721 * @since 20 1722 */ 1723 getFillType(): PathFillType; 1724 1725 /** 1726 * Obtains the minimum bounding rectangle that encloses this path. 1727 * @returns { common2D.Rect } Rect object. 1728 * @syscap SystemCapability.Graphics.Drawing 1729 * @since 12 1730 */ 1731 /** 1732 * Obtains the minimum bounding rectangle that encloses this path. 1733 * @returns { common2D.Rect } Rect object. 1734 * @syscap SystemCapability.Graphics.Drawing 1735 * @crossplatform 1736 * @since 20 1737 */ 1738 getBounds(): common2D.Rect; 1739 1740 /** 1741 * Closes this path by adding a line segment from the start point to the last point of the path. 1742 * @syscap SystemCapability.Graphics.Drawing 1743 * @since 11 1744 */ 1745 /** 1746 * Closes this path by adding a line segment from the start point to the last point of the path. 1747 * @syscap SystemCapability.Graphics.Drawing 1748 * @crossplatform 1749 * @since 20 1750 */ 1751 close(): void; 1752 1753 /** 1754 * Offsets this path by specified distances along the X axis and Y axis and stores the resulting path in the Path object returned. 1755 * @param { number } dx - X offset. A positive number indicates an offset towards the positive direction of the X axis, 1756 * and a negative number indicates an offset towards the negative direction of the X axis. The value is a floating point number. 1757 * @param { number } dy - Y offset. A positive number indicates an offset towards the positive direction of the Y axis, 1758 * and a negative number indicates an offset towards the negative direction of the Y axis. The value is a floating point number. 1759 * @returns { Path } New path generated. 1760 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1761 * <br>2. Incorrect parameter types. 1762 * @syscap SystemCapability.Graphics.Drawing 1763 * @since 12 1764 */ 1765 /** 1766 * Offsets this path by specified distances along the X axis and Y axis and stores the resulting path in the Path object returned. 1767 * @param { number } dx - X offset. A positive number indicates an offset towards the positive direction of the X axis, 1768 * and a negative number indicates an offset towards the negative direction of the X axis. The value is a floating point number. 1769 * @param { number } dy - Y offset. A positive number indicates an offset towards the positive direction of the Y axis, 1770 * and a negative number indicates an offset towards the negative direction of the Y axis. The value is a floating point number. 1771 * @returns { Path } New path generated. 1772 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1773 * <br>2. Incorrect parameter types. 1774 * @syscap SystemCapability.Graphics.Drawing 1775 * @crossplatform 1776 * @since 20 1777 */ 1778 offset(dx: number, dy: number): Path; 1779 1780 /** 1781 * Resets the path data. 1782 * @syscap SystemCapability.Graphics.Drawing 1783 * @since 11 1784 */ 1785 /** 1786 * Resets the path data. 1787 * @syscap SystemCapability.Graphics.Drawing 1788 * @crossplatform 1789 * @since 20 1790 * @arkts 1.1&1.2 1791 */ 1792 reset(): void; 1793 1794 /** 1795 * Clears any lines and curves from the path but keeps the internal storage for faster reuse. 1796 * @syscap SystemCapability.Graphics.Drawing 1797 * @crossplatform 1798 * @since 20 1799 */ 1800 rewind(): void; 1801 1802 /** 1803 * Check if the path is empty (has no line or curve). 1804 * 1805 * @returns { boolean } Returns true if the path is empty; returns false otherwise. 1806 * @syscap SystemCapability.Graphics.Drawing 1807 * @crossplatform 1808 * @since 20 1809 */ 1810 isEmpty(): boolean; 1811 1812 /** 1813 * Check if the path represents a rectangle. 1814 * 1815 * @param { common2D.Rect | null } rect - Indicates the Rect object. 1816 * @returns { boolean } Returns true if the path represents a rectangle; returns false otherwise. 1817 * @syscap SystemCapability.Graphics.Drawing 1818 * @crossplatform 1819 * @since 20 1820 */ 1821 isRect(rect: common2D.Rect | null): boolean; 1822 1823 /** 1824 * Obtains the path length. 1825 * @param { boolean } forceClosed - Whether the path is measured as a closed path. 1826 * The value true means that the path is considered closed during measurement, 1827 * and false means that the path is measured based on the actual closed status. 1828 * @returns { number } Return path length. 1829 * @syscap SystemCapability.Graphics.Drawing 1830 * @since 12 1831 */ 1832 /** 1833 * Obtains the path length. 1834 * @param { boolean } forceClosed - Whether the path is measured as a closed path. 1835 * The value true means that the path is considered closed during measurement, 1836 * and false means that the path is measured based on the actual closed status. 1837 * @returns { number } Return path length. 1838 * @syscap SystemCapability.Graphics.Drawing 1839 * @crossplatform 1840 * @since 20 1841 */ 1842 getLength(forceClosed: boolean): number; 1843 1844 /** 1845 * Obtains the coordinates and tangent at a distance from the start point of this path. 1846 * 1847 * @param { boolean } forceClosed - Whether the path is measured as a closed path. 1848 * The value true means that the path is considered closed during measurement, 1849 * and false means that the path is measured based on the actual closed status. 1850 * @param { number } distance - Distance from the start point. If a negative number is passed in, the value 0 is used. 1851 * If a value greater than the path length is passed in, the path length is used. The value is a floating point number. 1852 * @param { common2D.Point } position - Coordinates obtained. 1853 * @param { common2D.Point } tangent - Tangent obtained, where tangent.x and tangent.y represent the cosine 1854 * and sine of the tangent of the point, respectively. 1855 * @returns { boolean } - Check result. The value true means that they are obtained, and false means the opposite. 1856 * The values of position and tangent are not changed. 1857 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1858 * <br>2. Incorrect parameter types. 1859 * @syscap SystemCapability.Graphics.Drawing 1860 * @since 12 1861 */ 1862 /** 1863 * Obtains the coordinates and tangent at a distance from the start point of this path. 1864 * 1865 * @param { boolean } forceClosed - Whether the path is measured as a closed path. 1866 * The value true means that the path is considered closed during measurement, 1867 * and false means that the path is measured based on the actual closed status. 1868 * @param { number } distance - Distance from the start point. If a negative number is passed in, the value 0 is used. 1869 * If a value greater than the path length is passed in, the path length is used. The value is a floating point number. 1870 * @param { common2D.Point } position - Coordinates obtained. 1871 * @param { common2D.Point } tangent - Tangent obtained, where tangent.x and tangent.y represent the cosine 1872 * and sine of the tangent of the point, respectively. 1873 * @returns { boolean } - Check result. The value true means that they are obtained, and false means the opposite. 1874 * The values of position and tangent are not changed. 1875 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1876 * <br>2. Incorrect parameter types. 1877 * @syscap SystemCapability.Graphics.Drawing 1878 * @crossplatform 1879 * @since 20 1880 */ 1881 getPositionAndTangent(forceClosed: boolean, distance: number, position: common2D.Point, tangent: common2D.Point): boolean; 1882 1883 /** 1884 * Extracts a segment of this path and appends it to a destination path. 1885 * 1886 * @param { boolean } forceClosed - Whether the path is measured as a closed path. The value true means that the path is considered closed 1887 * during measurement, and false means that the path is measured based on the actual closed status. 1888 * @param { number } start - Distance from the start point of the path to the start point of the segment. If it is less than 0, it defaults to 0. 1889 * If it is greater than or equal to stop, the extraction fails. The value is a floating point number. 1890 * @param { number } stop - Distance from the start point of the path to the end point of the segment. If it is less than or equal to start, 1891 * the extraction fails. If it is greater than the path length, it defaults to the path length. The value is a floating point number. 1892 * @param { boolean } startWithMoveTo - Whether to execute moveto in the destination path to move to its start point. 1893 * The value true means to move to the start point, and false means the opposite. 1894 * @param { Path } dst - Destination path. If the extraction succeeds, the segment is appended to the path. If the extraction fails, nothing changes. 1895 * @returns { boolean } - Extraction result. The value **true** means that the extraction is successful, and **false** means the opposite. 1896 * @syscap SystemCapability.Graphics.Drawing 1897 * @since 18 1898 */ 1899 /** 1900 * Extracts a segment of this path and appends it to a destination path. 1901 * 1902 * @param { boolean } forceClosed - Whether the path is measured as a closed path. The value true means that the path is considered closed 1903 * during measurement, and false means that the path is measured based on the actual closed status. 1904 * @param { number } start - Distance from the start point of the path to the start point of the segment. If it is less than 0, it defaults to 0. 1905 * If it is greater than or equal to stop, the extraction fails. The value is a floating point number. 1906 * @param { number } stop - Distance from the start point of the path to the end point of the segment. If it is less than or equal to start, 1907 * the extraction fails. If it is greater than the path length, it defaults to the path length. The value is a floating point number. 1908 * @param { boolean } startWithMoveTo - Whether to execute moveto in the destination path to move to its start point. 1909 * The value true means to move to the start point, and false means the opposite. 1910 * @param { Path } dst - Destination path. If the extraction succeeds, the segment is appended to the path. If the extraction fails, nothing changes. 1911 * @returns { boolean } - Extraction result. The value **true** means that the extraction is successful, and **false** means the opposite. 1912 * @syscap SystemCapability.Graphics.Drawing 1913 * @crossplatform 1914 * @since 20 1915 */ 1916 getSegment(forceClosed: boolean, start: number, stop: number, startWithMoveTo: boolean, dst: Path): boolean; 1917 1918 /** 1919 * Checks whether a path is closed. 1920 * 1921 * @returns { boolean } - Check result. The value true means that the path is closed, and false means the opposite. 1922 * @syscap SystemCapability.Graphics.Drawing 1923 * @since 12 1924 */ 1925 /** 1926 * Checks whether a path is closed. 1927 * 1928 * @returns { boolean } - Check result. The value true means that the path is closed, and false means the opposite. 1929 * @syscap SystemCapability.Graphics.Drawing 1930 * @crossplatform 1931 * @since 20 1932 */ 1933 isClosed(): boolean; 1934 1935 /** 1936 * Obtains a transformation matrix at a specific position along the path, which represents the coordinates and orientation of that point. 1937 * 1938 * @param { boolean } forceClosed - Whether the path is measured as a closed path. The value true means that the path is considered closed 1939 * during measurement, and false means that the path is measured based on the actual closed status. 1940 * @param { number } distance - Distance from the start point. If a negative number is passed in, the value 0 is used. 1941 * If a value greater than the path length is passed in, the path length is used. The value is a floating point number. 1942 * @param { Matrix } matrix - Matrix object used to store the matrix obtained. 1943 * @param { PathMeasureMatrixFlags } flags - Type of the matrix information obtained. 1944 * @returns { boolean } - Result indicating whether the transformation matrix is obtained. 1945 * The value true means that the operation is successful, and false means the opposite. 1946 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 1947 * @syscap SystemCapability.Graphics.Drawing 1948 * @since 12 1949 */ 1950 /** 1951 * Obtains a transformation matrix at a specific position along the path, which represents the coordinates and orientation of that point. 1952 * 1953 * @param { boolean } forceClosed - Whether the path is measured as a closed path. The value true means that the path is considered closed 1954 * during measurement, and false means that the path is measured based on the actual closed status. 1955 * @param { number } distance - Distance from the start point. If a negative number is passed in, the value 0 is used. 1956 * If a value greater than the path length is passed in, the path length is used. The value is a floating point number. 1957 * @param { Matrix } matrix - Matrix object used to store the matrix obtained. 1958 * @param { PathMeasureMatrixFlags } flags - Type of the matrix information obtained. 1959 * @returns { boolean } - Result indicating whether the transformation matrix is obtained. 1960 * The value true means that the operation is successful, and false means the opposite. 1961 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 1962 * @syscap SystemCapability.Graphics.Drawing 1963 * @crossplatform 1964 * @since 20 1965 */ 1966 getMatrix(forceClosed: boolean, distance: number, matrix: Matrix, flags: PathMeasureMatrixFlags): boolean; 1967 1968 /** 1969 * Parses the path represented by an SVG string. 1970 * 1971 * @param { string } str - String in SVG format, which is used to describe the path. 1972 * @returns { boolean } Result of the parsing operation. The value true means that the operation is successful, and false means the opposite. 1973 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 1974 * @syscap SystemCapability.Graphics.Drawing 1975 * @since 12 1976 */ 1977 /** 1978 * Parses the path represented by an SVG string. 1979 * 1980 * @param { string } str - String in SVG format, which is used to describe the path. 1981 * @returns { boolean } Result of the parsing operation. The value true means that the operation is successful, and false means the opposite. 1982 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 1983 * @syscap SystemCapability.Graphics.Drawing 1984 * @crossplatform 1985 * @since 20 1986 */ 1987 buildFromSvgString(str: string): boolean; 1988 1989 /** 1990 * Obtains the operation iterator of this path. 1991 * 1992 * @returns { PathIterator } Indicates the pointer to an pathIterator object. 1993 * @syscap SystemCapability.Graphics.Drawing 1994 * @since 18 1995 */ 1996 /** 1997 * Obtains the operation iterator of this path. 1998 * 1999 * @returns { PathIterator } Indicates the pointer to an pathIterator object. 2000 * @syscap SystemCapability.Graphics.Drawing 2001 * @crossplatform 2002 * @since 20 2003 */ 2004 getPathIterator(): PathIterator; 2005 2006 /** 2007 * Approximates the path with a series of line segments. 2008 * 2009 * @param { number } acceptableError - Indicates the acceptable error for a line on the path. Should be no less than 0. 2010 * @returns { Array<number> } - Returns with the array containing point components. 2011 * <br>There are three components for each point: 2012 * <br>1. Fraction along the length of the path that the point resides [0.0, 1.0]. 2013 * <br>2. The x coordinate of the point. 2014 * <br>3. The y coordinate of the point. 2015 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 2016 * @syscap SystemCapability.Graphics.Drawing 2017 * @crossplatform 2018 * @since 20 2019 */ 2020 approximate(acceptableError: number): Array<number>; 2021 2022 /** 2023 * Performs interpolation between the current path and another path based on a given weight, and stores the result in the target path object. 2024 * 2025 * @param { Path } other - Indicates the other path to be interpolated with the current path. 2026 * @param { number } weight - Indicates the interpolation weight, which must be in the range [0, 1]. 2027 * @param { Path } interpolatedPath - Indicates the target path object where the interpolation result will be stored. 2028 * @returns { boolean } - Returns true if the interpolation operation was successful; returns false otherwise. 2029 * <br>Possible reasons for failure include: 2030 * <br>1. The 'other' is incompatible with the current path. 2031 * <br>2. The 'weight' is outside the [0, 1] range. 2032 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 2033 * @syscap SystemCapability.Graphics.Drawing 2034 * @crossplatform 2035 * @since 20 2036 */ 2037 interpolate(other: Path, weight: number, interpolatedPath: Path): boolean; 2038 2039 /** 2040 * Checks whether the current path is compatible with another path (other) for interpolation, which means 2041 * they have exactly the same structure, both paths must have the same operations, in the same order. 2042 * If any of the operations are of type PathIteratorVerb.CONIC, then the weights of those conics must also match. 2043 * 2044 * @param { Path } other - Indicates the path to be checked for compatibility with the current path. 2045 * @returns { boolean } - Returns true if the current path and the other path are compatible for interpolation; returns false otherwise. 2046 * @syscap SystemCapability.Graphics.Drawing 2047 * @crossplatform 2048 * @since 20 2049 */ 2050 isInterpolate(other: Path): boolean; 2051 } 2052 2053 /** 2054 * Enumerates the modes for drawing multiple points in an array. 2055 * @enum { number } 2056 * @syscap SystemCapability.Graphics.Drawing 2057 * @since 12 2058 */ 2059 /** 2060 * Enumerates the modes for drawing multiple points in an array. 2061 * @enum { number } 2062 * @syscap SystemCapability.Graphics.Drawing 2063 * @crossplatform 2064 * @since 20 2065 */ 2066 enum PointMode { 2067 /** 2068 * Draws each point separately. 2069 * @syscap SystemCapability.Graphics.Drawing 2070 * @since 12 2071 */ 2072 /** 2073 * Draws each point separately. 2074 * @syscap SystemCapability.Graphics.Drawing 2075 * @crossplatform 2076 * @since 20 2077 */ 2078 POINTS = 0, 2079 2080 /** 2081 * Draws every two points as a line segment. 2082 * @syscap SystemCapability.Graphics.Drawing 2083 * @since 12 2084 */ 2085 /** 2086 * Draws every two points as a line segment. 2087 * @syscap SystemCapability.Graphics.Drawing 2088 * @crossplatform 2089 * @since 20 2090 */ 2091 LINES = 1, 2092 2093 /** 2094 * Draws an array of points as an open polygon. 2095 * @syscap SystemCapability.Graphics.Drawing 2096 * @since 12 2097 */ 2098 /** 2099 * Draws the array of points as a open polygon. 2100 * @syscap SystemCapability.Graphics.Drawing 2101 * @crossplatform 2102 * @since 20 2103 */ 2104 POLYGON = 2, 2105 } 2106 2107 /** 2108 * Enumerates the filter modes. 2109 * @enum { number } 2110 * @syscap SystemCapability.Graphics.Drawing 2111 * @since 12 2112 */ 2113 /** 2114 * Enumerates the filter modes. 2115 * @enum { number } 2116 * @syscap SystemCapability.Graphics.Drawing 2117 * @crossplatform 2118 * @since 20 2119 * @arkts 1.1&1.2 2120 */ 2121 enum FilterMode { 2122 /** 2123 * Nearest filter mode. 2124 * @syscap SystemCapability.Graphics.Drawing 2125 * @since 12 2126 */ 2127 /** 2128 * Nearest filter mode. 2129 * @syscap SystemCapability.Graphics.Drawing 2130 * @crossplatform 2131 * @since 20 2132 * @arkts 1.1&1.2 2133 */ 2134 FILTER_MODE_NEAREST = 0, 2135 2136 /** 2137 * Linear filter mode. 2138 * @syscap SystemCapability.Graphics.Drawing 2139 * @since 12 2140 */ 2141 /** 2142 * Linear filter mode. 2143 * @syscap SystemCapability.Graphics.Drawing 2144 * @crossplatform 2145 * @since 20 2146 * @arkts 1.1&1.2 2147 */ 2148 FILTER_MODE_LINEAR = 1, 2149 } 2150 2151 /** 2152 * Enumerates the shadow drawing behaviors. 2153 * @enum { number } 2154 * @syscap SystemCapability.Graphics.Drawing 2155 * @since 12 2156 */ 2157 /** 2158 * Enumerates the shadow drawing behaviors. 2159 * @enum { number } 2160 * @syscap SystemCapability.Graphics.Drawing 2161 * @crossplatform 2162 * @since 20 2163 */ 2164 enum ShadowFlag { 2165 /** 2166 * None of the flags are enabled. 2167 * @syscap SystemCapability.Graphics.Drawing 2168 * @since 12 2169 */ 2170 /** 2171 * None of the flags are enabled. 2172 * @syscap SystemCapability.Graphics.Drawing 2173 * @crossplatform 2174 * @since 20 2175 */ 2176 NONE = 0, 2177 2178 /** 2179 * The occluder is transparent. 2180 * @syscap SystemCapability.Graphics.Drawing 2181 * @since 12 2182 */ 2183 /** 2184 * The occluder is transparent. 2185 * @syscap SystemCapability.Graphics.Drawing 2186 * @crossplatform 2187 * @since 20 2188 */ 2189 TRANSPARENT_OCCLUDER = 1, 2190 2191 /** 2192 * Only the geometric shadow effect is used. 2193 * @syscap SystemCapability.Graphics.Drawing 2194 * @since 12 2195 */ 2196 /** 2197 * Only the geometric shadow effect is used. 2198 * @syscap SystemCapability.Graphics.Drawing 2199 * @crossplatform 2200 * @since 20 2201 */ 2202 GEOMETRIC_ONLY = 2, 2203 2204 /** 2205 * All the flags are enabled. 2206 * @syscap SystemCapability.Graphics.Drawing 2207 * @since 12 2208 */ 2209 /** 2210 * All the flags are enabled. 2211 * @syscap SystemCapability.Graphics.Drawing 2212 * @crossplatform 2213 * @since 20 2214 */ 2215 ALL = 3, 2216 } 2217 2218 /** 2219 * Implements sampling options. 2220 * @syscap SystemCapability.Graphics.Drawing 2221 * @since 12 2222 */ 2223 /** 2224 * Implements sampling options. 2225 * @syscap SystemCapability.Graphics.Drawing 2226 * @crossplatform 2227 * @since 20 2228 * @arkts 1.1&1.2 2229 */ 2230 class SamplingOptions { 2231 /** 2232 * Creates a SamplingOptions object. The default value of FilterMode is FILTER_MODE_NEAREST. 2233 * @syscap SystemCapability.Graphics.Drawing 2234 * @since 12 2235 */ 2236 /** 2237 * Creates a SamplingOptions object. The default value of FilterMode is FILTER_MODE_NEAREST. 2238 * @syscap SystemCapability.Graphics.Drawing 2239 * @crossplatform 2240 * @since 20 2241 * @arkts 1.1&1.2 2242 */ 2243 constructor(); 2244 /** 2245 * Creates a SamplingOptions object. 2246 * @param { FilterMode } filterMode - Storage filter mode. 2247 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2248 * <br>2. Incorrect parameter types. 2249 * @syscap SystemCapability.Graphics.Drawing 2250 * @since 12 2251 */ 2252 /** 2253 * Creates a SamplingOptions object. 2254 * @param { FilterMode } filterMode - Storage filter mode. 2255 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2256 * <br>2. Incorrect parameter types. 2257 * @syscap SystemCapability.Graphics.Drawing 2258 * @crossplatform 2259 * @since 20 2260 * @arkts 1.1&1.2 2261 */ 2262 constructor(filterMode: FilterMode); 2263 } 2264 2265 /** 2266 * Describes font feature for drawing and measuring single character. 2267 * @typedef FontFeature 2268 * @syscap SystemCapability.Graphics.Drawing 2269 * @crossplatform 2270 * @since 20 2271 */ 2272 interface FontFeature { 2273 /** 2274 * The name of font feature. 2275 * @type { string } feature name 2276 * @syscap SystemCapability.Graphics.Drawing 2277 * @crossplatform 2278 * @since 20 2279 */ 2280 name: string; 2281 /** 2282 * The value of font feature. 2283 * @type { number } feature value 2284 * @syscap SystemCapability.Graphics.Drawing 2285 * @crossplatform 2286 * @since 20 2287 */ 2288 value: number; 2289 } 2290 2291 /** 2292 * A carrier that carries the drawn content and drawing status. 2293 * @syscap SystemCapability.Graphics.Drawing 2294 * @since 11 2295 */ 2296 /** 2297 * A carrier that carries the drawn content and drawing status. 2298 * @syscap SystemCapability.Graphics.Drawing 2299 * @crossplatform 2300 * @since 20 2301 * @arkts 1.1&1.2 2302 */ 2303 class Canvas { 2304 /** 2305 * Creates a Canvas object that uses a PixelMap as the drawing target. 2306 * @param { image.PixelMap } pixelmap - PixelMap used to create the object. 2307 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2308 * <br>2. Incorrect parameter types. 2309 * @syscap SystemCapability.Graphics.Drawing 2310 * @since 11 2311 */ 2312 /** 2313 * Creates a Canvas object that uses a PixelMap as the drawing target. 2314 * @param { image.PixelMap } pixelmap - PixelMap used to create the object. 2315 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2316 * <br>2. Incorrect parameter types. 2317 * @syscap SystemCapability.Graphics.Drawing 2318 * @crossplatform 2319 * @since 20 2320 * @arkts 1.1&1.2 2321 */ 2322 constructor(pixelmap: image.PixelMap); 2323 2324 /** 2325 * Draws a rectangle. By default, black is used for filling. 2326 * @param { common2D.Rect } rect - Rectangle to draw. 2327 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2328 * <br>2. Incorrect parameter types. 2329 * @syscap SystemCapability.Graphics.Drawing 2330 * @since 11 2331 */ 2332 /** 2333 * Draws a rectangle. By default, black is used for filling. 2334 * @param { common2D.Rect } rect - Rectangle to draw. 2335 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2336 * <br>2. Incorrect parameter types. 2337 * @syscap SystemCapability.Graphics.Drawing 2338 * @crossplatform 2339 * @since 20 2340 * @arkts 1.1&1.2 2341 */ 2342 drawRect(rect: common2D.Rect): void; 2343 2344 /** 2345 * Draws a rectangle. By default, black is used for filling. This API provides better performance than drawRect and is recommended. 2346 * @param { number } left - X coordinate of the upper left corner of the rectangle. The value is a floating point number. 2347 * @param { number } top - Y coordinate of the upper left corner of the rectangle. The value is a floating point number. 2348 * @param { number } right - X coordinate of the lower right corner of the rectangle. The value is a floating point number. 2349 * @param { number } bottom - Y coordinate of the lower right corner of the rectangle. The value is a floating point number. 2350 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2351 * <br>2. Incorrect parameter types. 2352 * @syscap SystemCapability.Graphics.Drawing 2353 * @since 12 2354 */ 2355 /** 2356 * Draws a rectangle. By default, black is used for filling. This API provides better performance than drawRect and is recommended. 2357 * @param { number } left - X coordinate of the upper left corner of the rectangle. The value is a floating point number. 2358 * @param { number } top - Y coordinate of the upper left corner of the rectangle. The value is a floating point number. 2359 * @param { number } right - X coordinate of the lower right corner of the rectangle. The value is a floating point number. 2360 * @param { number } bottom - Y coordinate of the lower right corner of the rectangle. The value is a floating point number. 2361 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2362 * <br>2. Incorrect parameter types. 2363 * @syscap SystemCapability.Graphics.Drawing 2364 * @crossplatform 2365 * @since 20 2366 * @arkts 1.1&1.2 2367 */ 2368 drawRect(left: number, top: number, right: number, bottom: number): void; 2369 2370 /** 2371 * Draws a rounded rectangle. 2372 * @param { RoundRect } roundRect - Indicates the RectRound object. 2373 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2374 * <br>2. Incorrect parameter types. 2375 * @syscap SystemCapability.Graphics.Drawing 2376 * @since 12 2377 */ 2378 /** 2379 * Draws a rounded rectangle. 2380 * @param { RoundRect } roundRect - Indicates the RectRound object. 2381 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2382 * <br>2. Incorrect parameter types. 2383 * @syscap SystemCapability.Graphics.Drawing 2384 * @crossplatform 2385 * @since 20 2386 */ 2387 drawRoundRect(roundRect: RoundRect): void; 2388 2389 /** 2390 * Draws two nested rounded rectangles. The outer rectangle boundary must contain the inner rectangle boundary. 2391 * Otherwise, there is no drawing effect. 2392 * @param { RoundRect } outer - Outer rounded rectangle. 2393 * @param { RoundRect } inner - Inner rounded rectangle. 2394 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2395 * <br>2. Incorrect parameter types. 2396 * @syscap SystemCapability.Graphics.Drawing 2397 * @since 12 2398 */ 2399 /** 2400 * Draws two nested rounded rectangles. The outer rectangle boundary must contain the inner rectangle boundary. 2401 * Otherwise, there is no drawing effect. 2402 * @param { RoundRect } outer - Outer rounded rectangle. 2403 * @param { RoundRect } inner - Inner rounded rectangle. 2404 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2405 * <br>2. Incorrect parameter types. 2406 * @syscap SystemCapability.Graphics.Drawing 2407 * @crossplatform 2408 * @since 20 2409 */ 2410 drawNestedRoundRect(outer: RoundRect, inner: RoundRect): void; 2411 2412 /** 2413 * Uses a brush to fill the drawable area of the canvas. 2414 * @param { Brush } brush - Indicates the Brush object. 2415 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2416 * <br>2. Incorrect parameter types. 2417 * @syscap SystemCapability.Graphics.Drawing 2418 * @since 12 2419 */ 2420 /** 2421 * Uses a brush to fill the drawable area of the canvas. 2422 * @param { Brush } brush - Indicates the Brush object. 2423 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2424 * <br>2. Incorrect parameter types. 2425 * @syscap SystemCapability.Graphics.Drawing 2426 * @crossplatform 2427 * @since 20 2428 */ 2429 drawBackground(brush: Brush): void; 2430 2431 /** 2432 * Draws a spot shadow and uses a given path to outline the ambient shadow. 2433 * @param { Path } path - Path object, which is used to outline the shadow. 2434 * @param { common2D.Point3d } planeParams - 3D vector, which is used to determine the z-axis offset of an occluder relative to the canvas, 2435 * based on its x and y coordinates. 2436 * @param { common2D.Point3d } devLightPos - Position of the light relative to the canvas. 2437 * @param { number } lightRadius - Radius of the light. The value is a floating point number. 2438 * @param { common2D.Color } ambientColor - Color of the ambient shadow. 2439 * @param { common2D.Color } spotColor - Color of the spot shadow. 2440 * @param { ShadowFlag } flag - Shadow flag. 2441 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2442 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2443 * @syscap SystemCapability.Graphics.Drawing 2444 * @since 12 2445 */ 2446 /** 2447 * Draws a spot shadow and uses a given path to outline the ambient shadow. 2448 * @param { Path } path - Path object, which is used to outline the shadow. 2449 * @param { common2D.Point3d } planeParams - 3D vector, which is used to determine the z-axis offset of an occluder relative to the canvas, 2450 * based on its x and y coordinates. 2451 * @param { common2D.Point3d } devLightPos - Position of the light relative to the canvas. 2452 * @param { number } lightRadius - Radius of the light. The value is a floating point number. 2453 * @param { common2D.Color } ambientColor - Color of the ambient shadow. 2454 * @param { common2D.Color } spotColor - Color of the spot shadow. 2455 * @param { ShadowFlag } flag - Shadow flag. 2456 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2457 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2458 * @syscap SystemCapability.Graphics.Drawing 2459 * @crossplatform 2460 * @since 20 2461 */ 2462 drawShadow(path: Path, planeParams: common2D.Point3d, devLightPos: common2D.Point3d, lightRadius: number, 2463 ambientColor: common2D.Color, spotColor: common2D.Color, flag: ShadowFlag) : void; 2464 2465 /** 2466 * Draws a spot shadow and uses a given path to outline the ambient shadow. 2467 * @param { Path } path - Path object, which is used to outline the shadow. 2468 * @param { common2D.Point3d } planeParams - 3D vector, which is used to calculate the offset in the Z axis. 2469 * @param { common2D.Point3d } devLightPos - Position of the light relative to the canvas. 2470 * @param { number } lightRadius - Radius of the light. The value is a floating point number. 2471 * @param { common2D.Color | number } ambientColor - Ambient shadow color, represented by a 32-bit unsigned integer in hexadecimal ARGB format. 2472 * @param { common2D.Color | number } spotColor - Spot shadow color, represented by a 32-bit unsigned integer in hexadecimal ARGB format. 2473 * @param { ShadowFlag } flag - Indicates the flag to control opaque occluder, shadow, and light position. 2474 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2475 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2476 * @syscap SystemCapability.Graphics.Drawing 2477 * @since 18 2478 */ 2479 /** 2480 * Draws a spot shadow and uses a given path to outline the ambient shadow. 2481 * @param { Path } path - Path object, which is used to outline the shadow. 2482 * @param { common2D.Point3d } planeParams - 3D vector, which is used to calculate the offset in the Z axis. 2483 * @param { common2D.Point3d } devLightPos - Position of the light relative to the canvas. 2484 * @param { number } lightRadius - Radius of the light. The value is a floating point number. 2485 * @param { common2D.Color | number } ambientColor - Ambient shadow color, represented by a 32-bit unsigned integer in hexadecimal ARGB format. 2486 * @param { common2D.Color | number } spotColor - Spot shadow color, represented by a 32-bit unsigned integer in hexadecimal ARGB format. 2487 * @param { ShadowFlag } flag - Indicates the flag to control opaque occluder, shadow, and light position. 2488 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2489 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2490 * @syscap SystemCapability.Graphics.Drawing 2491 * @crossplatform 2492 * @since 20 2493 */ 2494 drawShadow(path: Path, planeParams: common2D.Point3d, devLightPos: common2D.Point3d, lightRadius: number, 2495 ambientColor: common2D.Color | number, spotColor: common2D.Color | number, flag: ShadowFlag) : void; 2496 2497 /** 2498 * Draws a circle. If the radius is less than or equal to zero, nothing is drawn. By default, black is used for filling. 2499 * @param { number } x - X coordinate of the center of the circle. The value is a floating point number. 2500 * @param { number } y - Y coordinate of the center of the circle. The value is a floating point number. 2501 * @param { number } radius - Radius of the circle. The value is a floating point number greater than 0. 2502 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2503 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2504 * @syscap SystemCapability.Graphics.Drawing 2505 * @since 11 2506 */ 2507 /** 2508 * Draws a circle. If the radius is less than or equal to zero, nothing is drawn. By default, black is used for filling. 2509 * @param { number } x - X coordinate of the center of the circle. The value is a floating point number. 2510 * @param { number } y - Y coordinate of the center of the circle. The value is a floating point number. 2511 * @param { number } radius - Radius of the circle. The value is a floating point number greater than 0. 2512 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2513 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2514 * @syscap SystemCapability.Graphics.Drawing 2515 * @crossplatform 2516 * @since 20 2517 */ 2518 drawCircle(x: number, y: number, radius: number): void; 2519 2520 /** 2521 * Draw a pixelmap, with the upper left corner at (left, top). 2522 * @param { image.PixelMap } pixelmap - PixelMap. 2523 * @param { number } left - Left side of image. 2524 * @param { number } top - Top side of image. 2525 * @throws { BusinessError } 401 - Parameter error. 2526 * @syscap SystemCapability.Graphics.Drawing 2527 * @since 11 2528 */ 2529 /** 2530 * Draws an image. The coordinates of the upper left corner of the image are (left, top). 2531 * @param { image.PixelMap } pixelmap - PixelMap. 2532 * @param { number } left - X coordinate of the upper left corner of the image. The value is a floating point number. 2533 * @param { number } top - Y coordinate of the upper left corner of the image. The value is a floating point number. 2534 * @param { SamplingOptions } samplingOptions - Sampling options. By default, the SamplingOptions object created using the no-argument constructor is used. 2535 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2536 * <br>2. Incorrect parameter types. 2537 * @syscap SystemCapability.Graphics.Drawing 2538 * @since 12 2539 */ 2540 /** 2541 * Draws an image. The coordinates of the upper left corner of the image are (left, top). 2542 * @param { image.PixelMap } pixelmap - PixelMap. 2543 * @param { number } left - X coordinate of the upper left corner of the image. The value is a floating point number. 2544 * @param { number } top - Y coordinate of the upper left corner of the image. The value is a floating point number. 2545 * @param { SamplingOptions } samplingOptions - Sampling options. By default, the SamplingOptions object created using the no-argument constructor is used. 2546 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2547 * <br>2. Incorrect parameter types. 2548 * @syscap SystemCapability.Graphics.Drawing 2549 * @crossplatform 2550 * @since 20 2551 */ 2552 drawImage(pixelmap: image.PixelMap, left: number, top: number, samplingOptions?: SamplingOptions): void; 2553 2554 /** 2555 * Splits an image into multiple sections based on the lattice object's configuration and 2556 * draws each section into the specified target rectangle on the canvas. 2557 * The intersections of even-numbered rows and columns (starting from 0) are fixed points. 2558 * If the fixed lattice area fits within the target rectangle, it will be drawn without scaling. 2559 * Otherwise, it will be scaled proportionally to fit the target rectangle. 2560 * Any remaining space will be filled by stretching or compressing the remaining sections to cover the entire target rectangle. 2561 * @param { image.PixelMap } pixelmap - The source image. 2562 * @param { Lattice } lattice - The area of source image. 2563 * @param { common2D.Rect } dstRect - The area of destination canvas. 2564 * @param { FilterMode } filterMode - Filter mode. 2565 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2566 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2567 * @syscap SystemCapability.Graphics.Drawing 2568 * @since 18 2569 */ 2570 /** 2571 * Splits an image into multiple sections based on the lattice object's configuration and 2572 * draws each section into the specified target rectangle on the canvas. 2573 * The intersections of even-numbered rows and columns (starting from 0) are fixed points. 2574 * If the fixed lattice area fits within the target rectangle, it will be drawn without scaling. 2575 * Otherwise, it will be scaled proportionally to fit the target rectangle. 2576 * Any remaining space will be filled by stretching or compressing the remaining sections to cover the entire target rectangle. 2577 * @param { image.PixelMap } pixelmap - The source image. 2578 * @param { Lattice } lattice - The area of source image. 2579 * @param { common2D.Rect } dstRect - The area of destination canvas. 2580 * @param { FilterMode } filterMode - Filter mode. 2581 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2582 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2583 * @syscap SystemCapability.Graphics.Drawing 2584 * @crossplatform 2585 * @since 20 2586 */ 2587 drawImageLattice(pixelmap: image.PixelMap, lattice: Lattice, dstRect: common2D.Rect, 2588 filterMode: FilterMode): void; 2589 2590 /** 2591 * Splits an image into nine sections using two horizontal and two vertical lines: four edge sections, four corner sections, and a central section. 2592 * If the four corner sections are smaller than the target rectangle, they will be drawn in the target rectangle without scaling. 2593 * Otherwise, they will be scaled to fit the target rectangle. Any remaining space will be filled by stretching or 2594 * compressing the other five sections to cover the entire target rectangle. 2595 * @param { image.PixelMap } pixelmap - PixelMap to split. 2596 * @param { common2D.Rect } center - Central rectangle that divides the image into nine sections by extending its four edges. 2597 * @param { common2D.Rect } dstRect - Target rectangle drawn on the canvas. 2598 * @param { FilterMode } filterMode - Filter mode. 2599 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2600 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2601 * @syscap SystemCapability.Graphics.Drawing 2602 * @since 18 2603 */ 2604 /** 2605 * Splits an image into nine sections using two horizontal and two vertical lines: four edge sections, four corner sections, and a central section. 2606 * If the four corner sections are smaller than the target rectangle, they will be drawn in the target rectangle without scaling. 2607 * Otherwise, they will be scaled to fit the target rectangle. Any remaining space will be filled by stretching or 2608 * compressing the other five sections to cover the entire target rectangle. 2609 * @param { image.PixelMap } pixelmap - PixelMap to split. 2610 * @param { common2D.Rect } center - Central rectangle that divides the image into nine sections by extending its four edges. 2611 * @param { common2D.Rect } dstRect - Target rectangle drawn on the canvas. 2612 * @param { FilterMode } filterMode - Filter mode. 2613 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2614 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2615 * @syscap SystemCapability.Graphics.Drawing 2616 * @crossplatform 2617 * @since 20 2618 */ 2619 drawImageNine(pixelmap: image.PixelMap, center: common2D.Rect, dstRect: common2D.Rect, 2620 filterMode: FilterMode): void; 2621 2622 /** 2623 * Draws an image onto a specified area of the canvas. 2624 * @param { image.PixelMap } pixelmap - The source image. 2625 * @param { common2D.Rect } dstRect - Rectangle object, which specifies the area of the canvas onto which the image will be drawn. 2626 * @param { SamplingOptions } samplingOptions - Sampling options. 2627 * By default, the SamplingOptions object created using the no-argument constructor is used. 2628 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2629 * <br>2. Incorrect parameter types. 2630 * @syscap SystemCapability.Graphics.Drawing 2631 * @since 12 2632 */ 2633 /** 2634 * Draws an image onto a specified area of the canvas. 2635 * @param { image.PixelMap } pixelmap - The source image. 2636 * @param { common2D.Rect } dstRect - Rectangle object, which specifies the area of the canvas onto which the image will be drawn. 2637 * @param { SamplingOptions } samplingOptions - Sampling options. 2638 * By default, the SamplingOptions object created using the no-argument constructor is used. 2639 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2640 * <br>2. Incorrect parameter types. 2641 * @syscap SystemCapability.Graphics.Drawing 2642 * @crossplatform 2643 * @since 20 2644 * @arkts 1.1&1.2 2645 */ 2646 drawImageRect(pixelmap: image.PixelMap, dstRect: common2D.Rect, samplingOptions?: SamplingOptions): void; 2647 2648 /** 2649 * Draws a portion of an image onto a specified area of the canvas. 2650 * @param { image.PixelMap } pixelmap - The source image. 2651 * @param { common2D.Rect } srcRect - Rectangle object, which specifies the portion of the image to draw. 2652 * @param { common2D.Rect } dstRect - Rectangle object, which specifies the area of the canvas onto which the image will be drawn. 2653 * @param { SamplingOptions } samplingOptions - Sampling options. 2654 * By default, the SamplingOptions object created using the no-argument constructor is used. 2655 * @param { SrcRectConstraint } constraint - Constraint type of the source rectangle. The default value is STRICT. 2656 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2657 * <br>2. Incorrect parameter types. 2658 * @syscap SystemCapability.Graphics.Drawing 2659 * @since 12 2660 */ 2661 /** 2662 * Draws a portion of an image onto a specified area of the canvas. 2663 * @param { image.PixelMap } pixelmap - The source image. 2664 * @param { common2D.Rect } srcRect - Rectangle object, which specifies the portion of the image to draw. 2665 * @param { common2D.Rect } dstRect - Rectangle object, which specifies the area of the canvas onto which the image will be drawn. 2666 * @param { SamplingOptions } samplingOptions - Sampling options. 2667 * By default, the SamplingOptions object created using the no-argument constructor is used. 2668 * @param { SrcRectConstraint } constraint - Constraint type of the source rectangle. The default value is STRICT. 2669 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2670 * <br>2. Incorrect parameter types. 2671 * @syscap SystemCapability.Graphics.Drawing 2672 * @crossplatform 2673 * @since 20 2674 */ 2675 drawImageRectWithSrc(pixelmap: image.PixelMap, srcRect: common2D.Rect, dstRect: common2D.Rect, 2676 samplingOptions?: SamplingOptions, constraint?: SrcRectConstraint): void; 2677 2678 /** 2679 * Fills the drawable area of the canvas with the specified color and blend mode. 2680 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 2681 * @param { BlendMode } blendMode - Blend mode. The default mode is SRC_OVER. 2682 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2683 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2684 * @syscap SystemCapability.Graphics.Drawing 2685 * @since 11 2686 */ 2687 /** 2688 * Fills the drawable area of the canvas with the specified color and blend mode. 2689 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 2690 * @param { BlendMode } blendMode - Blend mode. The default mode is SRC_OVER. 2691 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2692 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2693 * @syscap SystemCapability.Graphics.Drawing 2694 * @crossplatform 2695 * @since 20 2696 */ 2697 drawColor(color: common2D.Color, blendMode?: BlendMode): void; 2698 2699 /** 2700 * Fills the drawable area of the canvas with the specified color and blend mode. This API provides better performance and is recommended. 2701 * @param { number } alpha - Alpha channel value of the color in ARGB format. 2702 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2703 * @param { number } red - Red channel value of the color in ARGB format. 2704 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2705 * @param { number } green - Green channel value of the color in ARGB format. 2706 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2707 * @param { number } blue - Blue channel value of the color in ARGB format. 2708 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2709 * @param { BlendMode } blendMode - Blend mode. The default mode is SRC_OVER. 2710 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2711 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2712 * @syscap SystemCapability.Graphics.Drawing 2713 * @since 12 2714 */ 2715 /** 2716 * Fills the drawable area of the canvas with the specified color and blend mode. This API provides better performance and is recommended. 2717 * @param { number } alpha - Alpha channel value of the color in ARGB format. 2718 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2719 * @param { number } red - Red channel value of the color in ARGB format. 2720 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2721 * @param { number } green - Green channel value of the color in ARGB format. 2722 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2723 * @param { number } blue - Blue channel value of the color in ARGB format. 2724 * The value is an integer ranging from 0 to 255. Any passed-in floating point number is rounded down. 2725 * @param { BlendMode } blendMode - Blend mode. The default mode is SRC_OVER. 2726 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2727 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2728 * @syscap SystemCapability.Graphics.Drawing 2729 * @crossplatform 2730 * @since 20 2731 */ 2732 drawColor(alpha: number, red: number, green: number, blue: number, blendMode?: BlendMode): void; 2733 2734 /** 2735 * Fills the drawable area of the canvas with the specified color and blend mode. 2736 * @param { number } color - Color in hexadecimal ARGB format. 2737 * @param { BlendMode } blendMode - Blend mode. The default mode is SRC_OVER. 2738 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2739 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2740 * @syscap SystemCapability.Graphics.Drawing 2741 * @since 18 2742 */ 2743 /** 2744 * Fills the drawable area of the canvas with the specified color and blend mode. 2745 * @param { number } color - Color in hexadecimal ARGB format. 2746 * @param { BlendMode } blendMode - Blend mode. The default mode is SRC_OVER. 2747 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2748 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2749 * @syscap SystemCapability.Graphics.Drawing 2750 * @crossplatform 2751 * @since 20 2752 */ 2753 drawColor(color: number, blendMode?: BlendMode): void; 2754 2755 /** 2756 * Draws an oval on the canvas, where the shape and position of the oval are defined by its bounding rectangle. 2757 * @param { common2D.Rect } oval - Rectangle. The oval inscribed within the rectangle is the oval to draw. 2758 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2759 * <br>2. Incorrect parameter types. 2760 * @syscap SystemCapability.Graphics.Drawing 2761 * @since 12 2762 */ 2763 /** 2764 * Draws an oval on the canvas, where the shape and position of the oval are defined by its bounding rectangle. 2765 * @param { common2D.Rect } oval - Rectangle. The oval inscribed within the rectangle is the oval to draw. 2766 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2767 * <br>2. Incorrect parameter types. 2768 * @syscap SystemCapability.Graphics.Drawing 2769 * @crossplatform 2770 * @since 20 2771 */ 2772 drawOval(oval: common2D.Rect): void; 2773 2774 /** 2775 * Draws an arc on the canvas, with the start angle and sweep angle specified. 2776 * If the absolute value of the sweep angle exceeds 360 degrees, an ellipse is drawn. 2777 * @param { common2D.Rect } arc - Rectangular boundary that encapsulates the oval including the arc. 2778 * @param { number } startAngle - Start angle, in degrees. The value is a floating point number. 2779 * When the degree is 0, the start point is located at the right end of the oval. 2780 * A positive number indicates that the start point is placed clockwise, 2781 * and a negative number indicates that the start point is placed counterclockwise. 2782 * @param { number } sweepAngle - Angle to sweep, in degrees. The value is a floating point number. 2783 * A positive number indicates a clockwise sweep, and a negative value indicates a counterclockwise swipe. 2784 * The valid range is from -360 degrees to 360 degrees. If the absolute value of the sweep angle exceeds 360 degrees, 2785 * an ellipse is drawn. 2786 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2787 * <br>2. Incorrect parameter types. 2788 * @syscap SystemCapability.Graphics.Drawing 2789 * @since 12 2790 */ 2791 /** 2792 * Draws an arc on the canvas, with the start angle and sweep angle specified. 2793 * If the absolute value of the sweep angle exceeds 360 degrees, an ellipse is drawn. 2794 * @param { common2D.Rect } arc - Rectangular boundary that encapsulates the oval including the arc. 2795 * @param { number } startAngle - Start angle, in degrees. The value is a floating point number. 2796 * When the degree is 0, the start point is located at the right end of the oval. 2797 * A positive number indicates that the start point is placed clockwise, 2798 * and a negative number indicates that the start point is placed counterclockwise. 2799 * @param { number } sweepAngle - Angle to sweep, in degrees. The value is a floating point number. 2800 * A positive number indicates a clockwise sweep, and a negative value indicates a counterclockwise swipe. 2801 * The valid range is from -360 degrees to 360 degrees. If the absolute value of the sweep angle exceeds 360 degrees, 2802 * an ellipse is drawn. 2803 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2804 * <br>2. Incorrect parameter types. 2805 * @syscap SystemCapability.Graphics.Drawing 2806 * @crossplatform 2807 * @since 20 2808 */ 2809 drawArc(arc: common2D.Rect, startAngle: number, sweepAngle: number): void; 2810 2811 /** 2812 * Draws an arc on the canvas. It enables you to define the start angle, sweep angle, 2813 * and whether the arc's endpoints should connect to its center. 2814 * @param { common2D.Rect } arc - Rectangular boundary that encapsulates the oval including the arc. 2815 * @param { number } startAngle - Start angle, in degrees. The value is a floating point number. 2816 * When the degree is 0, the start point is located at the right end of the oval. 2817 * A positive number indicates that the start point is placed clockwise, 2818 * and a negative number indicates that the start point is placed counterclockwise. 2819 * @param { number } sweepAngle - Angle to sweep, in degrees. The value is a floating point number. 2820 * A positive number indicates a clockwise sweep, and a negative value indicates a counterclockwise swipe. 2821 * The swipe angle can exceed 360 degrees, and a complete ellipse is drawn. 2822 * @param { boolean } useCenter - Whether the start point and end point of the arc are connected to its center. 2823 * The value true means that they are connected to the center; the value false means the opposite. 2824 * @syscap SystemCapability.Graphics.Drawing 2825 * @since 18 2826 */ 2827 /** 2828 * Draws an arc on the canvas. It enables you to define the start angle, sweep angle, 2829 * and whether the arc's endpoints should connect to its center. 2830 * @param { common2D.Rect } arc - Rectangular boundary that encapsulates the oval including the arc. 2831 * @param { number } startAngle - Start angle, in degrees. The value is a floating point number. 2832 * When the degree is 0, the start point is located at the right end of the oval. 2833 * A positive number indicates that the start point is placed clockwise, 2834 * and a negative number indicates that the start point is placed counterclockwise. 2835 * @param { number } sweepAngle - Angle to sweep, in degrees. The value is a floating point number. 2836 * A positive number indicates a clockwise sweep, and a negative value indicates a counterclockwise swipe. 2837 * The swipe angle can exceed 360 degrees, and a complete ellipse is drawn. 2838 * @param { boolean } useCenter - Whether the start point and end point of the arc are connected to its center. 2839 * The value true means that they are connected to the center; the value false means the opposite. 2840 * @syscap SystemCapability.Graphics.Drawing 2841 * @crossplatform 2842 * @since 20 2843 */ 2844 drawArcWithCenter(arc: common2D.Rect, startAngle: number, sweepAngle: number, useCenter: boolean): void; 2845 2846 /** 2847 * Draws a point. 2848 * @param { number } x - X coordinate of the point. The value is a floating point number. 2849 * @param { number } y - Y coordinate of the point. The value is a floating point number. 2850 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2851 * <br>2. Incorrect parameter types. 2852 * @syscap SystemCapability.Graphics.Drawing 2853 * @since 11 2854 */ 2855 /** 2856 * Draws a point. 2857 * @param { number } x - X coordinate of the point. The value is a floating point number. 2858 * @param { number } y - Y coordinate of the point. The value is a floating point number. 2859 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2860 * <br>2. Incorrect parameter types. 2861 * @syscap SystemCapability.Graphics.Drawing 2862 * @crossplatform 2863 * @since 20 2864 */ 2865 drawPoint(x: number, y: number): void; 2866 2867 /** 2868 * Draws a group of points, line segments, or polygons on the canvas, with the specified drawing mode. An array is used to hold these points. 2869 * @param { Array<common2D.Point> } points - Array that holds the points to draw. The length cannot be 0. 2870 * @param { PointMode } mode - Mode in which the points are drawn. The default value is drawing.PointMode.POINTS. 2871 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2872 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2873 * @syscap SystemCapability.Graphics.Drawing 2874 * @since 12 2875 */ 2876 /** 2877 * Draws a group of points, line segments, or polygons on the canvas, with the specified drawing mode. An array is used to hold these points. 2878 * @param { Array<common2D.Point> } points - Array that holds the points to draw. The length cannot be 0. 2879 * @param { PointMode } mode - Mode in which the points are drawn. The default value is drawing.PointMode.POINTS. 2880 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2881 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2882 * @syscap SystemCapability.Graphics.Drawing 2883 * @crossplatform 2884 * @since 20 2885 */ 2886 drawPoints(points: Array<common2D.Point>, mode?: PointMode): void; 2887 2888 /** 2889 * Draws a custom path, which contains a set of path outlines. Each path outline can be open or closed. 2890 * @param { Path } path - Path object to draw. 2891 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2892 * <br>2. Incorrect parameter types. 2893 * @syscap SystemCapability.Graphics.Drawing 2894 * @since 11 2895 */ 2896 /** 2897 * Draws a custom path, which contains a set of path outlines. Each path outline can be open or closed. 2898 * @param { Path } path - Path object to draw. 2899 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2900 * <br>2. Incorrect parameter types. 2901 * @syscap SystemCapability.Graphics.Drawing 2902 * @crossplatform 2903 * @since 20 2904 */ 2905 drawPath(path: Path): void; 2906 2907 /** 2908 * Draws a line segment from the start point to the end point. If the coordinates of the start point are the same as those of the end point, 2909 * nothing is drawn. 2910 * @param { number } x0 - X coordinate of the start point of the line segment. The value is a floating point number. 2911 * @param { number } y0 - Y coordinate of the start point of the line segment. The value is a floating point number. 2912 * @param { number } x1 - X coordinate of the end point of the line segment. The value is a floating point number. 2913 * @param { number } y1 - Y coordinate of the end point of the line segment. The value is a floating point number. 2914 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2915 * <br>2. Incorrect parameter types. 2916 * @syscap SystemCapability.Graphics.Drawing 2917 * @since 11 2918 */ 2919 /** 2920 * Draws a line segment from the start point to the end point. If the coordinates of the start point are the same as those of the end point, 2921 * nothing is drawn. 2922 * @param { number } x0 - X coordinate of the start point of the line segment. The value is a floating point number. 2923 * @param { number } y0 - Y coordinate of the start point of the line segment. The value is a floating point number. 2924 * @param { number } x1 - X coordinate of the end point of the line segment. The value is a floating point number. 2925 * @param { number } y1 - Y coordinate of the end point of the line segment. The value is a floating point number. 2926 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2927 * <br>2. Incorrect parameter types. 2928 * @syscap SystemCapability.Graphics.Drawing 2929 * @crossplatform 2930 * @since 20 2931 */ 2932 drawLine(x0: number, y0: number, x1: number, y1: number): void; 2933 2934 /** 2935 * Draws a single character. If the typeface of the current font does not support the character to draw, 2936 * the system typeface is used to draw the character. 2937 * @param { string } text - Single character to draw. The length of the string must be 1. 2938 * @param { Font } font - Font object. 2939 * @param { number } x - X coordinate of the left point (red point in the figure below) of the character baseline (blue line in the figure below). 2940 * The value is a floating point number. 2941 * @param { number } y - Y coordinate of the left point (red point in the figure below) of the character baseline (blue line in the figure below). 2942 * The value is a floating point number. 2943 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2944 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2945 * @syscap SystemCapability.Graphics.Drawing 2946 * @since 12 2947 */ 2948 /** 2949 * Draws a single character. If the typeface of the current font does not support the character to draw, 2950 * the system typeface is used to draw the character. 2951 * @param { string } text - Single character to draw. The length of the string must be 1. 2952 * @param { Font } font - Font object. 2953 * @param { number } x - X coordinate of the left point (red point in the figure below) of the character baseline (blue line in the figure below). 2954 * The value is a floating point number. 2955 * @param { number } y - Y coordinate of the left point (red point in the figure below) of the character baseline (blue line in the figure below). 2956 * The value is a floating point number. 2957 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2958 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2959 * @syscap SystemCapability.Graphics.Drawing 2960 * @crossplatform 2961 * @since 20 2962 */ 2963 drawSingleCharacter(text: string, font: Font, x: number, y: number): void; 2964 2965 /** 2966 * Draws a single character with font feature. 2967 * @param { string } text - A string containing only a single character. 2968 * @param { Font } font - Font object. 2969 * @param { number } x - X coordinate of the single character start point. 2970 * @param { number } y - Y coordinate of the single character start point. 2971 * @param { Array<FontFeature> } features - Font Feature Array. 2972 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 2973 * @syscap SystemCapability.Graphics.Drawing 2974 * @crossplatform 2975 * @since 20 2976 */ 2977 drawSingleCharacterWithFeatures(text: string, font: Font, x: number, y: number, features: Array<FontFeature>): void; 2978 2979 /** 2980 * Draws a text blob. If the typeface used to construct blob does not support a character, that character will not be drawn. 2981 * @param { TextBlob } blob - TextBlob to draw. 2982 * @param { number } x - X coordinate of the left point (red point in the figure below) of the text baseline (blue line in the figure below). 2983 * The value is a floating point number. 2984 * @param { number } y - Y coordinate of the left point (red point in the figure below) of the text baseline (blue line in the figure below). 2985 * The value is a floating point number. 2986 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2987 * <br>2. Incorrect parameter types. 2988 * @syscap SystemCapability.Graphics.Drawing 2989 * @since 11 2990 */ 2991 /** 2992 * Draws a text blob. If the typeface used to construct blob does not support a character, that character will not be drawn. 2993 * @param { TextBlob } blob - TextBlob to draw. 2994 * @param { number } x - X coordinate of the left point (red point in the figure below) of the text baseline (blue line in the figure below). 2995 * The value is a floating point number. 2996 * @param { number } y - Y coordinate of the left point (red point in the figure below) of the text baseline (blue line in the figure below). 2997 * The value is a floating point number. 2998 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2999 * <br>2. Incorrect parameter types. 3000 * @syscap SystemCapability.Graphics.Drawing 3001 * @crossplatform 3002 * @since 20 3003 */ 3004 drawTextBlob(blob: TextBlob, x: number, y: number): void; 3005 3006 /** 3007 * Draws a PixelMap based on a mesh, where mesh vertices are evenly distributed across the PixelMap. 3008 * @param { image.PixelMap } pixelmap - PixelMap to draw. 3009 * @param { number } meshWidth - Number of columns in the mesh. The value is an integer greater than 0. 3010 * @param { number } meshHeight - Number of rows in the mesh. The value is an integer greater than 0. 3011 * @param { Array<number> } vertices - Array of vertices, which specify the position to draw. 3012 * The value is a floating-point array and the size must be ((meshWidth+1) * (meshHeight+1) + vertOffset) * 2. 3013 * @param { number } vertOffset - Number of vert elements to skip before drawing. The value is an integer greater than or equal to 0. 3014 * @param { Array<number> } colors - Array of colors, which specify the color at each vertex. 3015 * The value is an integer array and can be null. The size must be (meshWidth+1) * (meshHeight+1) + colorOffset. 3016 * @param { number } colorOffset - Number of color elements to skip before drawing. The value is an integer greater than or equal to 0. 3017 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3018 * <br>2. Incorrect parameter types. 3019 * @syscap SystemCapability.Graphics.Drawing 3020 * @since 12 3021 */ 3022 /** 3023 * Draws a PixelMap based on a mesh, where mesh vertices are evenly distributed across the PixelMap. 3024 * @param { image.PixelMap } pixelmap - PixelMap to draw. 3025 * @param { number } meshWidth - Number of columns in the mesh. The value is an integer greater than 0. 3026 * @param { number } meshHeight - Number of rows in the mesh. The value is an integer greater than 0. 3027 * @param { Array<number> } vertices - Array of vertices, which specify the position to draw. 3028 * The value is a floating-point array and the size must be ((meshWidth+1) * (meshHeight+1) + vertOffset) * 2. 3029 * @param { number } vertOffset - Number of vert elements to skip before drawing. The value is an integer greater than or equal to 0. 3030 * @param { Array<number> } colors - Array of colors, which specify the color at each vertex. 3031 * The value is an integer array and can be null. The size must be (meshWidth+1) * (meshHeight+1) + colorOffset. 3032 * @param { number } colorOffset - Number of color elements to skip before drawing. The value is an integer greater than or equal to 0. 3033 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3034 * <br>2. Incorrect parameter types. 3035 * @syscap SystemCapability.Graphics.Drawing 3036 * @crossplatform 3037 * @since 20 3038 * @arkts 1.1&1.2 3039 */ 3040 drawPixelMapMesh(pixelmap: image.PixelMap, meshWidth: number, meshHeight: number, 3041 vertices: Array<number>, vertOffset: number, colors: Array<number>, colorOffset: number): void; 3042 3043 /** 3044 * Draws a region. 3045 * @param { Region } region - Region to draw. 3046 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3047 * <br>2. Incorrect parameter types. 3048 * @syscap SystemCapability.Graphics.Drawing 3049 * @since 12 3050 */ 3051 /** 3052 * Draws a region. 3053 * @param { Region } region - Region to draw. 3054 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3055 * <br>2. Incorrect parameter types. 3056 * @syscap SystemCapability.Graphics.Drawing 3057 * @crossplatform 3058 * @since 20 3059 */ 3060 drawRegion(region: Region): void; 3061 3062 /** 3063 * Attaches a pen to the canvas. When you draw on the canvas, the pen's style is used to outline shapes. 3064 * @param { Pen } pen - Pen object. 3065 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3066 * <br>2. Incorrect parameter types. 3067 * @syscap SystemCapability.Graphics.Drawing 3068 * @since 11 3069 */ 3070 /** 3071 * Attaches a pen to the canvas. When you draw on the canvas, the pen's style is used to outline shapes. 3072 * @param { Pen } pen - Pen object. 3073 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3074 * <br>2. Incorrect parameter types. 3075 * @syscap SystemCapability.Graphics.Drawing 3076 * @crossplatform 3077 * @since 20 3078 * @arkts 1.1&1.2 3079 */ 3080 attachPen(pen: Pen): void; 3081 3082 /** 3083 * Attaches a brush to the canvas. When you draw on the canvas, the brush's style is used to fill the interior of shapes. 3084 * @param { Brush } brush - Brush object. 3085 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3086 * <br>2. Incorrect parameter types. 3087 * @syscap SystemCapability.Graphics.Drawing 3088 * @since 11 3089 */ 3090 /** 3091 * Attaches a brush to the canvas. When you draw on the canvas, the brush's style is used to fill the interior of shapes. 3092 * @param { Brush } brush - Brush object. 3093 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3094 * <br>2. Incorrect parameter types. 3095 * @syscap SystemCapability.Graphics.Drawing 3096 * @crossplatform 3097 * @since 20 3098 * @arkts 1.1&1.2 3099 */ 3100 attachBrush(brush: Brush): void; 3101 3102 /** 3103 * Detaches the pen from the canvas. When you draw on the canvas, the pen is no longer used to outline shapes. 3104 * @syscap SystemCapability.Graphics.Drawing 3105 * @since 11 3106 */ 3107 /** 3108 * Detaches the pen from the canvas. When you draw on the canvas, the pen is no longer used to outline shapes. 3109 * @syscap SystemCapability.Graphics.Drawing 3110 * @crossplatform 3111 * @since 20 3112 * @arkts 1.1&1.2 3113 */ 3114 detachPen(): void; 3115 3116 /** 3117 * Detaches the brush from the canvas. When you draw on the canvas, the brush is no longer used to fill the interior of shapes. 3118 * @syscap SystemCapability.Graphics.Drawing 3119 * @since 11 3120 */ 3121 /** 3122 * Detaches the brush from the canvas. When you draw on the canvas, the brush is no longer used to fill the interior of shapes. 3123 * @syscap SystemCapability.Graphics.Drawing 3124 * @crossplatform 3125 * @since 20 3126 * @arkts 1.1&1.2 3127 */ 3128 detachBrush(): void; 3129 3130 /** 3131 * Saves the canvas states (canvas matrix and drawable area) to the top of the stack. This API must be used in pair with restore. 3132 * @returns { number } Number of canvas statuses. The value is a positive integer. 3133 * @syscap SystemCapability.Graphics.Drawing 3134 * @since 12 3135 */ 3136 /** 3137 * Saves the canvas states (canvas matrix and drawable area) to the top of the stack. This API must be used in pair with restore. 3138 * @returns { number } Number of canvas statuses. The value is a positive integer. 3139 * @syscap SystemCapability.Graphics.Drawing 3140 * @crossplatform 3141 * @since 20 3142 * @arkts 1.1&1.2 3143 */ 3144 save(): number; 3145 3146 /** 3147 * Saves the matrix and cropping region of the canvas, and allocates a PixelMap for subsequent drawing. 3148 * If you call restore, changes made to the matrix and clipping region are discarded, and the PixelMap is drawn. 3149 * @param { common2D.Rect | null} rect - Rect object, which is used to limit the size of the graphics layer. 3150 * The default value is the current canvas size. 3151 * @param { Brush | null} brush - Brush object. The alpha value, filter effect, and blend mode of the brush are applied when the PixelMap is drawn. 3152 * If null is passed in, no effect is applied. 3153 * @returns { number } Number of canvas statuses that have been saved. The value is a positive integer. 3154 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 3155 * @syscap SystemCapability.Graphics.Drawing 3156 * @since 12 3157 */ 3158 /** 3159 * Saves the matrix and cropping region of the canvas, and allocates a PixelMap for subsequent drawing. 3160 * If you call restore, changes made to the matrix and clipping region are discarded, and the PixelMap is drawn. 3161 * @param { common2D.Rect | null} rect - Rect object, which is used to limit the size of the graphics layer. 3162 * The default value is the current canvas size. 3163 * @param { Brush | null} brush - Brush object. The alpha value, filter effect, and blend mode of the brush are applied when the PixelMap is drawn. 3164 * If null is passed in, no effect is applied. 3165 * @returns { number } Number of canvas statuses that have been saved. The value is a positive integer. 3166 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 3167 * @syscap SystemCapability.Graphics.Drawing 3168 * @crossplatform 3169 * @since 20 3170 * @arkts 1.1&1.2 3171 */ 3172 saveLayer(rect?: common2D.Rect | null, brush?: Brush | null): number; 3173 3174 /** 3175 * Clears the canvas with a given color. This API has the same effect as drawColor. 3176 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 3177 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3178 * <br>2. Incorrect parameter types. 3179 * @syscap SystemCapability.Graphics.Drawing 3180 * @since 12 3181 */ 3182 /** 3183 * Clears the canvas with a given color. This API has the same effect as drawColor. 3184 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 3185 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3186 * <br>2. Incorrect parameter types. 3187 * @syscap SystemCapability.Graphics.Drawing 3188 * @crossplatform 3189 * @since 20 3190 */ 3191 clear(color: common2D.Color): void; 3192 3193 /** 3194 * Clears the canvas with a given color. 3195 * @param { common2D.Color | number } color - Color, represented by an unsigned integer in hexadecimal ARGB format. 3196 * @syscap SystemCapability.Graphics.Drawing 3197 * @since 18 3198 */ 3199 /** 3200 * Clears the canvas with a given color. 3201 * @param { common2D.Color | number } color - Color, represented by an unsigned integer in hexadecimal ARGB format. 3202 * @syscap SystemCapability.Graphics.Drawing 3203 * @crossplatform 3204 * @since 20 3205 */ 3206 clear(color: common2D.Color | number): void; 3207 3208 /** 3209 * Restores the canvas state (canvas matrix and clipping area) saved on the top of the stack. 3210 * @syscap SystemCapability.Graphics.Drawing 3211 * @since 12 3212 */ 3213 /** 3214 * Restores the canvas state (canvas matrix and clipping area) saved on the top of the stack. 3215 * @syscap SystemCapability.Graphics.Drawing 3216 * @crossplatform 3217 * @since 20 3218 * @arkts 1.1&1.2 3219 */ 3220 restore(): void; 3221 3222 /** 3223 * Restores the canvas state (canvas matrix and clipping area) to a specified number. 3224 * @param { number } count - Depth of the canvas statuses to restore. The value is an integer. 3225 * If the value is less than or equal to 1, the canvas is restored to the initial state. 3226 * If the value is greater than the number of canvas statuses that have been saved, no operation is performed. 3227 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3228 * <br>2. Incorrect parameter types. 3229 * @syscap SystemCapability.Graphics.Drawing 3230 * @since 12 3231 */ 3232 /** 3233 * Restores the canvas state (canvas matrix and clipping area) to a specified number. 3234 * @param { number } count - Depth of the canvas statuses to restore. The value is an integer. 3235 * If the value is less than or equal to 1, the canvas is restored to the initial state. 3236 * If the value is greater than the number of canvas statuses that have been saved, no operation is performed. 3237 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3238 * <br>2. Incorrect parameter types. 3239 * @syscap SystemCapability.Graphics.Drawing 3240 * @crossplatform 3241 * @since 20 3242 */ 3243 restoreToCount(count: number): void; 3244 3245 /** 3246 * Obtains the number of canvas states (canvas matrix and clipping area) saved in the stack. 3247 * @returns { number } Number of canvas statuses that have been saved. The value is a positive integer. 3248 * @syscap SystemCapability.Graphics.Drawing 3249 * @since 12 3250 */ 3251 /** 3252 * Obtains the number of canvas states (canvas matrix and clipping area) saved in the stack. 3253 * @returns { number } Number of canvas statuses that have been saved. The value is a positive integer. 3254 * @syscap SystemCapability.Graphics.Drawing 3255 * @crossplatform 3256 * @since 20 3257 * @arkts 1.1&1.2 3258 */ 3259 getSaveCount(): number; 3260 3261 /** 3262 * Obtains the canvas width. 3263 * @returns { number } Canvas width. The value is a floating point number. 3264 * @syscap SystemCapability.Graphics.Drawing 3265 * @since 12 3266 */ 3267 /** 3268 * Obtains the canvas width. 3269 * @returns { number } Canvas width. The value is a floating point number. 3270 * @syscap SystemCapability.Graphics.Drawing 3271 * @crossplatform 3272 * @since 20 3273 */ 3274 getWidth(): number; 3275 3276 /** 3277 * Obtains the canvas height. 3278 * @returns { number } Canvas height. The value is a floating point number. 3279 * @syscap SystemCapability.Graphics.Drawing 3280 * @since 12 3281 */ 3282 /** 3283 * Obtains the canvas height. 3284 * @returns { number } Canvas height. The value is a floating point number. 3285 * @syscap SystemCapability.Graphics.Drawing 3286 * @crossplatform 3287 * @since 20 3288 */ 3289 getHeight(): number; 3290 3291 /** 3292 * Obtains the bounds of the cropping region of the canvas. 3293 * @returns { common2D.Rect } Rect object. 3294 * @syscap SystemCapability.Graphics.Drawing 3295 * @since 12 3296 */ 3297 /** 3298 * Obtains the bounds of the cropping region of the canvas. 3299 * @returns { common2D.Rect } Rect object. 3300 * @syscap SystemCapability.Graphics.Drawing 3301 * @crossplatform 3302 * @since 20 3303 */ 3304 getLocalClipBounds(): common2D.Rect; 3305 3306 /** 3307 * Obtains the canvas matrix. 3308 * @returns { Matrix } Canvas matrix. 3309 * @syscap SystemCapability.Graphics.Drawing 3310 * @since 12 3311 */ 3312 /** 3313 * Obtains the canvas matrix. 3314 * @returns { Matrix } Canvas matrix. 3315 * @syscap SystemCapability.Graphics.Drawing 3316 * @crossplatform 3317 * @since 20 3318 */ 3319 getTotalMatrix(): Matrix; 3320 3321 /** 3322 * Applies a scaling matrix on top of the current canvas matrix (identity matrix by default). 3323 * Subsequent drawing and clipping operations will automatically have a scaling effect applied to the shapes and positions. 3324 * @param { number } sx - Scale ratio on the X axis. The value is a floating point number. 3325 * @param { number } sy - Scale ratio on the Y axis. The value is a floating point number. 3326 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3327 * <br>2. Incorrect parameter types. 3328 * @syscap SystemCapability.Graphics.Drawing 3329 * @since 12 3330 */ 3331 /** 3332 * Applies a scaling matrix on top of the current canvas matrix (identity matrix by default). 3333 * Subsequent drawing and clipping operations will automatically have a scaling effect applied to the shapes and positions. 3334 * @param { number } sx - Scale ratio on the X axis. The value is a floating point number. 3335 * @param { number } sy - Scale ratio on the Y axis. The value is a floating point number. 3336 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3337 * <br>2. Incorrect parameter types. 3338 * @syscap SystemCapability.Graphics.Drawing 3339 * @crossplatform 3340 * @since 20 3341 */ 3342 scale(sx: number, sy: number): void; 3343 3344 /** 3345 * Applies a skewing matrix on top of the current canvas matrix (identity matrix by default). 3346 * Subsequent drawing and clipping operations will automatically have a skewing effect applied to the shapes and positions. 3347 * @param { number } sx - Amount of tilt on the X axis. The value is a floating point number. 3348 * A positive number tilts the drawing rightwards along the positive direction of the Y axis, 3349 * and a negative number tilts the drawing leftwards along the positive direction of the Y axis. 3350 * @param { number } sy - Amount of tilt on the Y axis. The value is a floating point number. 3351 * A positive number tilts the drawing downwards along the positive direction of the X axis, 3352 * and a negative number tilts the drawing upwards along the positive direction of the X axis. 3353 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3354 * <br>2. Incorrect parameter types. 3355 * @syscap SystemCapability.Graphics.Drawing 3356 * @since 12 3357 */ 3358 /** 3359 * Applies a skewing matrix on top of the current canvas matrix (identity matrix by default). 3360 * Subsequent drawing and clipping operations will automatically have a skewing effect applied to the shapes and positions. 3361 * @param { number } sx - Amount of tilt on the X axis. The value is a floating point number. 3362 * A positive number tilts the drawing rightwards along the positive direction of the Y axis, 3363 * and a negative number tilts the drawing leftwards along the positive direction of the Y axis. 3364 * @param { number } sy - Amount of tilt on the Y axis. The value is a floating point number. 3365 * A positive number tilts the drawing downwards along the positive direction of the X axis, 3366 * and a negative number tilts the drawing upwards along the positive direction of the X axis. 3367 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3368 * <br>2. Incorrect parameter types. 3369 * @syscap SystemCapability.Graphics.Drawing 3370 * @crossplatform 3371 * @since 20 3372 */ 3373 skew(sx: number, sy: number) : void; 3374 3375 /** 3376 * Applies a rotation matrix on top of the current canvas matrix (identity matrix by default). 3377 * Subsequent drawing and clipping operations will automatically have a rotation effect applied to their shapes and positions. 3378 * @param { number } degrees - Angle to rotate, in degrees. The value is a floating point number. 3379 * A positive value indicates a clockwise rotation, and a negative value indicates a counterclockwise rotation. 3380 * @param { number } sx - X coordinate of the rotation center. The value is a floating point number. 3381 * @param { number } sy - Y coordinate of the rotation center. The value is a floating point number. 3382 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3383 * <br>2. Incorrect parameter types. 3384 * @syscap SystemCapability.Graphics.Drawing 3385 * @since 12 3386 */ 3387 /** 3388 * Applies a rotation matrix on top of the current canvas matrix (identity matrix by default). 3389 * Subsequent drawing and clipping operations will automatically have a rotation effect applied to their shapes and positions. 3390 * @param { number } degrees - Angle to rotate, in degrees. The value is a floating point number. 3391 * A positive value indicates a clockwise rotation, and a negative value indicates a counterclockwise rotation. 3392 * @param { number } sx - X coordinate of the rotation center. The value is a floating point number. 3393 * @param { number } sy - Y coordinate of the rotation center. The value is a floating point number. 3394 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3395 * <br>2. Incorrect parameter types. 3396 * @syscap SystemCapability.Graphics.Drawing 3397 * @crossplatform 3398 * @since 20 3399 * @arkts 1.1&1.2 3400 */ 3401 rotate(degrees: number, sx: number, sy: number) : void; 3402 3403 /** 3404 * Applies a translation matrix on top of the current canvas matrix (identity matrix by default). 3405 * Subsequent drawing and clipping operations will automatically have a translation effect applied to the shapes and positions. 3406 * @param { number } dx - Distance to translate on the X axis. The value is a floating point number. 3407 * @param { number } dy - Distance to translate on the Y axis. The value is a floating point number. 3408 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3409 * <br>2. Incorrect parameter types. 3410 * @syscap SystemCapability.Graphics.Drawing 3411 * @since 12 3412 */ 3413 /** 3414 * Applies a translation matrix on top of the current canvas matrix (identity matrix by default). 3415 * Subsequent drawing and clipping operations will automatically have a translation effect applied to the shapes and positions. 3416 * @param { number } dx - Distance to translate on the X axis. The value is a floating point number. 3417 * @param { number } dy - Distance to translate on the Y axis. The value is a floating point number. 3418 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3419 * <br>2. Incorrect parameter types. 3420 * @syscap SystemCapability.Graphics.Drawing 3421 * @crossplatform 3422 * @since 20 3423 */ 3424 translate(dx: number, dy: number): void; 3425 3426 /** 3427 * Clips the drawable area of the canvas using a custom path. 3428 * @param { Path } path - To combine with clip. 3429 * @param { ClipOp } clipOp - Clip mode. The default value is INTERSECT. 3430 * @param { boolean } doAntiAlias - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, 3431 * and false means the opposite. The default value is false. 3432 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3433 * <br>2. Incorrect parameter types. 3434 * @syscap SystemCapability.Graphics.Drawing 3435 * @since 12 3436 */ 3437 /** 3438 * Clips the drawable area of the canvas using a custom path. 3439 * @param { Path } path - To combine with clip. 3440 * @param { ClipOp } clipOp - Clip mode. The default value is INTERSECT. 3441 * @param { boolean } doAntiAlias - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, 3442 * and false means the opposite. The default value is false. 3443 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3444 * <br>2. Incorrect parameter types. 3445 * @syscap SystemCapability.Graphics.Drawing 3446 * @crossplatform 3447 * @since 20 3448 */ 3449 clipPath(path: Path, clipOp?: ClipOp, doAntiAlias?: boolean): void; 3450 3451 /** 3452 * Clips the drawable area of the canvas using a rectangle. 3453 * @param { common2D.Rect } rect - To combine with clipping area. 3454 * @param { ClipOp } clipOp - Clip mode. The default value is INTERSECT. 3455 * @param { boolean } doAntiAlias - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, 3456 * and false means the opposite. The default value is false. 3457 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3458 * <br>2. Incorrect parameter types. 3459 * @syscap SystemCapability.Graphics.Drawing 3460 * @since 12 3461 */ 3462 /** 3463 * Clips the drawable area of the canvas using a rectangle. 3464 * @param { common2D.Rect } rect - To combine with clipping area. 3465 * @param { ClipOp } clipOp - Clip mode. The default value is INTERSECT. 3466 * @param { boolean } doAntiAlias - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, 3467 * and false means the opposite. The default value is false. 3468 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3469 * <br>2. Incorrect parameter types. 3470 * @syscap SystemCapability.Graphics.Drawing 3471 * @crossplatform 3472 * @since 20 3473 */ 3474 clipRect(rect: common2D.Rect, clipOp?: ClipOp, doAntiAlias?: boolean): void; 3475 3476 /** 3477 * Multiplies the current canvas matrix by the incoming matrix on the left. This API does not affect previous drawing operations, 3478 * but subsequent drawing and clipping operations will be influenced by this matrix in terms of shape and position. 3479 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 3480 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3481 * <br>2. Incorrect parameter types. 3482 * @syscap SystemCapability.Graphics.Drawing 3483 * @since 12 3484 */ 3485 /** 3486 * Multiplies the current canvas matrix by the incoming matrix on the left. This API does not affect previous drawing operations, 3487 * but subsequent drawing and clipping operations will be influenced by this matrix in terms of shape and position. 3488 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 3489 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3490 * <br>2. Incorrect parameter types. 3491 * @syscap SystemCapability.Graphics.Drawing 3492 * @crossplatform 3493 * @since 20 3494 */ 3495 concatMatrix(matrix: Matrix): void; 3496 3497 /** 3498 * Clips a region on the canvas. 3499 * @param { Region } region - Region object, which indicates the range to clip. 3500 * @param { ClipOp } clipOp - Clipping mode. The default value is INTERSECT. 3501 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3502 * <br>2. Incorrect parameter types. 3503 * @syscap SystemCapability.Graphics.Drawing 3504 * @since 12 3505 */ 3506 /** 3507 * Clips a region on the canvas. 3508 * @param { Region } region - Region object, which indicates the range to clip. 3509 * @param { ClipOp } clipOp - Clipping mode. The default value is INTERSECT. 3510 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3511 * <br>2. Incorrect parameter types. 3512 * @syscap SystemCapability.Graphics.Drawing 3513 * @crossplatform 3514 * @since 20 3515 */ 3516 clipRegion(region: Region, clipOp?: ClipOp): void; 3517 3518 /** 3519 * Clips a rounded rectangle on the canvas. 3520 * @param { RoundRect } roundRect - To combine with clipping area. 3521 * @param { ClipOp } clipOp - Clipping mode. The default value is INTERSECT. 3522 * @param { boolean } doAntiAlias - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, 3523 * and false means the opposite. The default value is false. 3524 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3525 * <br>2. Incorrect parameter types. 3526 * @syscap SystemCapability.Graphics.Drawing 3527 * @since 12 3528 */ 3529 /** 3530 * Clips a rounded rectangle on the canvas. 3531 * @param { RoundRect } roundRect - To combine with clipping area. 3532 * @param { ClipOp } clipOp - Clipping mode. The default value is INTERSECT. 3533 * @param { boolean } doAntiAlias - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, 3534 * and false means the opposite. The default value is false. 3535 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3536 * <br>2. Incorrect parameter types. 3537 * @syscap SystemCapability.Graphics.Drawing 3538 * @crossplatform 3539 * @since 20 3540 */ 3541 clipRoundRect(roundRect: RoundRect, clipOp?: ClipOp, doAntiAlias?: boolean): void; 3542 3543 /** 3544 * Checks whether the region that can be drawn is empty after clipping. 3545 * @returns { boolean } Returns true if drawable area is empty. 3546 * @syscap SystemCapability.Graphics.Drawing 3547 * @since 12 3548 */ 3549 /** 3550 * Checks whether the region that can be drawn is empty after clipping. 3551 * @returns { boolean } Returns true if drawable area is empty. 3552 * @syscap SystemCapability.Graphics.Drawing 3553 * @crossplatform 3554 * @since 20 3555 */ 3556 isClipEmpty(): boolean; 3557 3558 /** 3559 * Sets a matrix for the canvas. Subsequent drawing and clipping operations will be affected by this matrix in terms of shape and position. 3560 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 3561 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3562 * <br>2. Incorrect parameter types. 3563 * @syscap SystemCapability.Graphics.Drawing 3564 * @since 12 3565 */ 3566 /** 3567 * Sets a matrix for the canvas. Subsequent drawing and clipping operations will be affected by this matrix in terms of shape and position. 3568 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 3569 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3570 * <br>2. Incorrect parameter types. 3571 * @syscap SystemCapability.Graphics.Drawing 3572 * @crossplatform 3573 * @since 20 3574 */ 3575 setMatrix(matrix: Matrix): void; 3576 3577 /** 3578 * Resets the matrix of this canvas to an identity matrix. 3579 * @syscap SystemCapability.Graphics.Drawing 3580 * @since 12 3581 */ 3582 /** 3583 * Resets the matrix of this canvas to an identity matrix. 3584 * @syscap SystemCapability.Graphics.Drawing 3585 * @crossplatform 3586 * @since 20 3587 */ 3588 resetMatrix(): void; 3589 3590 /** 3591 * Checks whether the path is not intersecting with the canvas area. The canvas area includes its boundaries. 3592 * @param { Path } path - Path to draw. 3593 * @returns { boolean } Returns true if path is not intersect; returns false otherwise. 3594 * @syscap SystemCapability.Graphics.Drawing 3595 * @since 18 3596 */ 3597 /** 3598 * Checks whether the path is not intersecting with the canvas area. The canvas area includes its boundaries. 3599 * @param { Path } path - Path to draw. 3600 * @returns { boolean } Returns true if path is not intersect; returns false otherwise. 3601 * @syscap SystemCapability.Graphics.Drawing 3602 * @crossplatform 3603 * @since 20 3604 */ 3605 quickRejectPath(path: Path): boolean; 3606 3607 /** 3608 * Checks whether the rectangle is not intersecting with the canvas area. The canvas area includes its boundaries. 3609 * @param { common2D.Rect } rect - Rectangle to determines. 3610 * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. 3611 * @syscap SystemCapability.Graphics.Drawing 3612 * @since 18 3613 */ 3614 /** 3615 * Checks whether the rectangle is not intersecting with the canvas area. The canvas area includes its boundaries. 3616 * @param { common2D.Rect } rect - Rectangle to determines. 3617 * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. 3618 * @syscap SystemCapability.Graphics.Drawing 3619 * @crossplatform 3620 * @since 20 3621 */ 3622 quickRejectRect(rect: common2D.Rect): boolean; 3623 } 3624 3625 /** 3626 * Enumerates the canvas clipping modes. 3627 * 3628 * @enum { number } 3629 * @syscap SystemCapability.Graphics.Drawing 3630 * @since 12 3631 */ 3632 /** 3633 * Enumerates the canvas clipping modes. 3634 * 3635 * @enum { number } 3636 * @syscap SystemCapability.Graphics.Drawing 3637 * @crossplatform 3638 * @since 20 3639 * @arkts 1.1&1.2 3640 */ 3641 enum ClipOp { 3642 /** 3643 * Clips a specified area. That is, the difference set is obtained. 3644 * @syscap SystemCapability.Graphics.Drawing 3645 * @since 12 3646 */ 3647 /** 3648 * Clips a specified area. That is, the difference set is obtained. 3649 * @syscap SystemCapability.Graphics.Drawing 3650 * @crossplatform 3651 * @since 20 3652 * @arkts 1.1&1.2 3653 */ 3654 DIFFERENCE = 0, 3655 /** 3656 * Retains a specified area. That is, the intersection is obtained. 3657 * @syscap SystemCapability.Graphics.Drawing 3658 * @since 12 3659 */ 3660 /** 3661 * Retains a specified area. That is, the intersection is obtained. 3662 * @syscap SystemCapability.Graphics.Drawing 3663 * @crossplatform 3664 * @since 20 3665 * @arkts 1.1&1.2 3666 */ 3667 INTERSECT = 1, 3668 } 3669 3670 /** 3671 * Describes a series of consecutive glyphs with the same attributes in a text blob. 3672 * @typedef TextBlobRunBuffer 3673 * @syscap SystemCapability.Graphics.Drawing 3674 * @since 11 3675 */ 3676 /** 3677 * Describes a series of consecutive glyphs with the same attributes in a text blob. 3678 * @typedef TextBlobRunBuffer 3679 * @syscap SystemCapability.Graphics.Drawing 3680 * @crossplatform 3681 * @since 20 3682 */ 3683 interface TextBlobRunBuffer { 3684 /** 3685 * Index of the glyph. The value is an integer. If a floating point number is passed in, the value is rounded down. 3686 * @type { number } 3687 * @syscap SystemCapability.Graphics.Drawing 3688 * @since 11 3689 */ 3690 /** 3691 * Index of the glyph. The value is an integer. If a floating point number is passed in, the value is rounded down. 3692 * @type { number } 3693 * @syscap SystemCapability.Graphics.Drawing 3694 * @crossplatform 3695 * @since 20 3696 */ 3697 glyph: number; 3698 /** 3699 * X coordinate of the start point of the text blob. The value is a floating point number. 3700 * @type { number } 3701 * @syscap SystemCapability.Graphics.Drawing 3702 * @since 11 3703 */ 3704 /** 3705 * X coordinate of the start point of the text blob. The value is a floating point number. 3706 * @type { number } 3707 * @syscap SystemCapability.Graphics.Drawing 3708 * @crossplatform 3709 * @since 20 3710 */ 3711 positionX: number; 3712 /** 3713 * Y coordinate of the start point of the text blob. The value is a floating point number. 3714 * @type { number } 3715 * @syscap SystemCapability.Graphics.Drawing 3716 * @since 11 3717 */ 3718 /** 3719 * Y coordinate of the start point of the text blob. The value is a floating point number. 3720 * @type { number } 3721 * @syscap SystemCapability.Graphics.Drawing 3722 * @crossplatform 3723 * @since 20 3724 */ 3725 positionY: number; 3726 } 3727 3728 /** 3729 * Enumerates the text encoding types. 3730 * 3731 * @enum { number } 3732 * @syscap SystemCapability.Graphics.Drawing 3733 * @since 11 3734 */ 3735 /** 3736 * Enumerates the text encoding types. 3737 * 3738 * @enum { number } 3739 * @syscap SystemCapability.Graphics.Drawing 3740 * @crossplatform 3741 * @since 20 3742 */ 3743 enum TextEncoding { 3744 /** 3745 * One byte is used to indicate UTF-8 or ASCII characters. 3746 * @syscap SystemCapability.Graphics.Drawing 3747 * @since 11 3748 */ 3749 /** 3750 * One byte is used to indicate UTF-8 or ASCII characters. 3751 * @syscap SystemCapability.Graphics.Drawing 3752 * @crossplatform 3753 * @since 20 3754 */ 3755 TEXT_ENCODING_UTF8 = 0, 3756 /** 3757 * Two bytes are used to indicate most Unicode characters. 3758 * @syscap SystemCapability.Graphics.Drawing 3759 * @since 11 3760 */ 3761 /** 3762 * Two bytes are used to indicate most Unicode characters. 3763 * @syscap SystemCapability.Graphics.Drawing 3764 * @crossplatform 3765 * @since 20 3766 */ 3767 TEXT_ENCODING_UTF16 = 1, 3768 /** 3769 * Four bytes are used to indicate all Unicode characters. 3770 * @syscap SystemCapability.Graphics.Drawing 3771 * @since 11 3772 */ 3773 /** 3774 * Four bytes are used to indicate all Unicode characters. 3775 * @syscap SystemCapability.Graphics.Drawing 3776 * @crossplatform 3777 * @since 20 3778 */ 3779 TEXT_ENCODING_UTF32 = 2, 3780 /** 3781 * Two bytes are used to indicate the glyph index. 3782 * @syscap SystemCapability.Graphics.Drawing 3783 * @since 11 3784 */ 3785 /** 3786 * Two bytes are used to indicate the glyph index. 3787 * @syscap SystemCapability.Graphics.Drawing 3788 * @crossplatform 3789 * @since 20 3790 */ 3791 TEXT_ENCODING_GLYPH_ID = 3, 3792 } 3793 3794 /** 3795 * Defines a block consisting of one or more characters with the same font. 3796 * 3797 * class TextBlob 3798 * @syscap SystemCapability.Graphics.Drawing 3799 * @since 11 3800 */ 3801 /** 3802 * Defines a block consisting of one or more characters with the same font. 3803 * 3804 * class TextBlob 3805 * @syscap SystemCapability.Graphics.Drawing 3806 * @crossplatform 3807 * @since 20 3808 */ 3809 class TextBlob { 3810 /** 3811 * Converts a value of the string type into a TextBlob object. 3812 * @param { string } text - Content to be used for drawing the text blob. 3813 * @param { Font } font - Specify text size, font, text scale, etc. 3814 * @param { TextEncoding } encoding - Encoding type. The default value is TEXT_ENCODING_UTF8. 3815 * Currently, only TEXT_ENCODING_UTF8 takes effect, and other encoding types are treated as TEXT_ENCODING_UTF8. 3816 * @returns { TextBlob } TextBlob object. 3817 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3818 * <br>2. Incorrect parameter types. 3819 * @static 3820 * @syscap SystemCapability.Graphics.Drawing 3821 * @since 11 3822 */ 3823 /** 3824 * Converts a value of the string type into a TextBlob object. 3825 * @param { string } text - Content to be used for drawing the text blob. 3826 * @param { Font } font - Specify text size, font, text scale, etc. 3827 * @param { TextEncoding } encoding - Encoding type. The default value is TEXT_ENCODING_UTF8. 3828 * Currently, only TEXT_ENCODING_UTF8 takes effect, and other encoding types are treated as TEXT_ENCODING_UTF8. 3829 * @returns { TextBlob } TextBlob object. 3830 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3831 * <br>2. Incorrect parameter types. 3832 * @static 3833 * @syscap SystemCapability.Graphics.Drawing 3834 * @crossplatform 3835 * @since 20 3836 */ 3837 static makeFromString(text: string, font: Font, encoding?: TextEncoding): TextBlob; 3838 3839 /** 3840 * Creates a TextBlob object from the text. 3841 * The coordinates of each font in the TextBlob object are determined by the coordinate information in the points array. 3842 * @param { string } text - Content to be used for drawing the text blob. 3843 * @param { number } len - Number of fonts. The value is an integer and is obtained from countText. 3844 * @param { common2D.Point[] } points - Array of points, which are used to specify the coordinates of each font. 3845 * The array length must be the same as the value of len. 3846 * @param { Font } font - Specify text size, font, text scale, etc. 3847 * @returns { TextBlob } TextBlob object. 3848 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3849 * <br>2. Incorrect parameter types. 3850 * @static 3851 * @syscap SystemCapability.Graphics.Drawing 3852 * @since 12 3853 */ 3854 /** 3855 * Creates a TextBlob object from the text. 3856 * The coordinates of each font in the TextBlob object are determined by the coordinate information in the points array. 3857 * @param { string } text - Content to be used for drawing the text blob. 3858 * @param { number } len - Number of fonts. The value is an integer and is obtained from countText. 3859 * @param { common2D.Point[] } points - Array of points, which are used to specify the coordinates of each font. 3860 * The array length must be the same as the value of len. 3861 * @param { Font } font - Specify text size, font, text scale, etc. 3862 * @returns { TextBlob } TextBlob object. 3863 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3864 * <br>2. Incorrect parameter types. 3865 * @static 3866 * @syscap SystemCapability.Graphics.Drawing 3867 * @crossplatform 3868 * @since 20 3869 */ 3870 static makeFromPosText(text: string, len: number, points: common2D.Point[], font: Font): TextBlob; 3871 3872 /** 3873 * Creates a Textblob object based on the RunBuffer information. 3874 * @param { Array<TextBlobRunBuffer> } pos - The array of TextBlobRunBuffer. 3875 * @param { Font } font - Font used for this run. 3876 * @param { common2D.Rect } bounds - Optional run bounding box. The default value is null; 3877 * @returns { TextBlob } TextBlob object. 3878 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3879 * <br>2. Incorrect parameter types. 3880 * @static 3881 * @syscap SystemCapability.Graphics.Drawing 3882 * @since 11 3883 */ 3884 /** 3885 * Creates a Textblob object based on the RunBuffer information. 3886 * @param { Array<TextBlobRunBuffer> } pos - The array of TextBlobRunBuffer. 3887 * @param { Font } font - Font used for this run. 3888 * @param { common2D.Rect } bounds - Optional run bounding box. The default value is null; 3889 * @returns { TextBlob } TextBlob object. 3890 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3891 * <br>2. Incorrect parameter types. 3892 * @static 3893 * @syscap SystemCapability.Graphics.Drawing 3894 * @crossplatform 3895 * @since 20 3896 */ 3897 static makeFromRunBuffer(pos: Array<TextBlobRunBuffer>, font: Font, bounds?: common2D.Rect): TextBlob; 3898 3899 /** 3900 * Obtains the rectangular bounding box of the text blob. 3901 * @returns { common2D.Rect } Rect object. 3902 * @syscap SystemCapability.Graphics.Drawing 3903 * @since 11 3904 */ 3905 /** 3906 * Obtains the rectangular bounding box of the text blob. 3907 * @returns { common2D.Rect } Rect object. 3908 * @syscap SystemCapability.Graphics.Drawing 3909 * @crossplatform 3910 * @since 20 3911 */ 3912 bounds(): common2D.Rect; 3913 3914 /** 3915 * Obtains the unique, non-zero identifier of this TextBlob object. 3916 * @returns { number } Unique, non-zero identifier of this TextBlob object. 3917 * @syscap SystemCapability.Graphics.Drawing 3918 * @since 12 3919 */ 3920 /** 3921 * Obtains the unique, non-zero identifier of this TextBlob object. 3922 * @returns { number } Unique, non-zero identifier of this TextBlob object. 3923 * @syscap SystemCapability.Graphics.Drawing 3924 * @crossplatform 3925 * @since 20 3926 */ 3927 uniqueID(): number; 3928 } 3929 3930 /** 3931 * Provides an interface to the drawing, and describe the arguments for a font. 3932 * @syscap SystemCapability.Graphics.Drawing 3933 * @crossplatform 3934 * @since 20 3935 * @arkts 1.1&1.2 3936 */ 3937 class TypefaceArguments { 3938 /** 3939 * Constructor for the TypefaceArguments. 3940 * @syscap SystemCapability.Graphics.Drawing 3941 * @crossplatform 3942 * @since 20 3943 * @arkts 1.1&1.2 3944 */ 3945 constructor(); 3946 /** 3947 * Adds variation axis for the TypefaceArguments. 3948 * @param { string } axis - Indicates the axis tag, which must contain four ASCII characters. 3949 * @param { number } value - Indicates the value of the axis field. 3950 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 3951 * @syscap SystemCapability.Graphics.Drawing 3952 * @crossplatform 3953 * @since 20 3954 */ 3955 addVariation(axis: string, value: number); 3956 } 3957 3958 /** 3959 * Describes the style of a typeface, such as SimSun or KaiTi. 3960 * 3961 * @syscap SystemCapability.Graphics.Drawing 3962 * @since 11 3963 */ 3964 /** 3965 * Describes the style of a typeface, such as SimSun or KaiTi. 3966 * 3967 * @syscap SystemCapability.Graphics.Drawing 3968 * @crossplatform 3969 * @since 20 3970 * @arkts 1.1&1.2 3971 */ 3972 class Typeface { 3973 /** 3974 * Get the family name for this typeface. 3975 * @returns { string } Family name. 3976 * @syscap SystemCapability.Graphics.Drawing 3977 * @since 11 3978 */ 3979 /** 3980 * Get the family name for this typeface. 3981 * @returns { string } Family name. 3982 * @syscap SystemCapability.Graphics.Drawing 3983 * @crossplatform 3984 * @since 20 3985 * @arkts 1.1&1.2 3986 */ 3987 getFamilyName(): string; 3988 3989 /** 3990 * Generate typeface from current typeface and TypefaceArguments. 3991 * @param { TypefaceArguments } typefaceArguments - TypefaceArguments for typeface. 3992 * @returns { Typeface } Typeface. 3993 * @syscap SystemCapability.Graphics.Drawing 3994 * @crossplatform 3995 * @since 20 3996 */ 3997 makeFromCurrent(typefaceArguments: TypefaceArguments): Typeface; 3998 3999 /** 4000 * Constructs a typeface from a file. 4001 * @param { string } filePath - file path for typeface. 4002 * @returns { Typeface } Typeface. 4003 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4004 * <br>2. Incorrect parameter types. 4005 * @syscap SystemCapability.Graphics.Drawing 4006 * @since 12 4007 */ 4008 /** 4009 * Constructs a typeface from a file. 4010 * @param { string } filePath - file path for typeface. 4011 * @returns { Typeface } Typeface. 4012 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4013 * <br>2. Incorrect parameter types. 4014 * @syscap SystemCapability.Graphics.Drawing 4015 * @crossplatform 4016 * @since 20 4017 * @arkts 1.1&1.2 4018 */ 4019 static makeFromFile(filePath: string): Typeface; 4020 4021 /** 4022 * Constructs a typeface from a file, which must be stored in the resources/rawfile directory of the application project. 4023 * @param { Resource } rawfile - Resource object corresponding to the file. 4024 * Currently, only resource objects referenced in rawfile format are supported. 4025 * The corresponding format is rawfile('filePath'), where filePath is the relative path of the file to the resources/rawfile directory in the project. 4026 * If the file is stored in resources/rawfile, the reference format is rawfile('HarmonyOS_Sans_Bold.ttf'). 4027 * If the file is stored in a subdirectory, for example, in resources/rawfile/ttf, the reference format is rawfile('ttf/HarmonyOS_Sans_Bold.ttf'). 4028 * @returns { Typeface } Typeface. 4029 * @syscap SystemCapability.Graphics.Drawing 4030 * @since 18 4031 */ 4032 /** 4033 * Constructs a typeface from a file, which must be stored in the resources/rawfile directory of the application project. 4034 * @param { Resource } rawfile - Resource object corresponding to the file. 4035 * Currently, only resource objects referenced in rawfile format are supported. 4036 * The corresponding format is rawfile('filePath'), where filePath is the relative path of the file to the resources/rawfile directory in the project. 4037 * If the file is stored in resources/rawfile, the reference format is rawfile('HarmonyOS_Sans_Bold.ttf'). 4038 * If the file is stored in a subdirectory, for example, in resources/rawfile/ttf, the reference format is rawfile('ttf/HarmonyOS_Sans_Bold.ttf'). 4039 * @returns { Typeface } Typeface. 4040 * @syscap SystemCapability.Graphics.Drawing 4041 * @crossplatform 4042 * @since 20 4043 */ 4044 static makeFromRawFile(rawfile: Resource): Typeface; 4045 4046 /** 4047 * Generate typeface from file and TypefaceArguments. 4048 * @param { string } filePath - file path for typeface. 4049 * @param { TypefaceArguments } typefaceArguments - TypefaceArguments for typeface. 4050 * @returns { Typeface } Typeface. 4051 * @static 4052 * @syscap SystemCapability.Graphics.Drawing 4053 * @crossplatform 4054 * @since 20 4055 * @arkts 1.1&1.2 4056 */ 4057 static makeFromFileWithArguments(filePath: string, typefaceArguments: TypefaceArguments): Typeface; 4058 4059 /** 4060 * Generate typeface from Rawfile and TypefaceArguments. 4061 * @param { Resource } rawfile - RawFile for typeface. 4062 * @param { TypefaceArguments } typefaceArguments - TypefaceArguments for typeface. 4063 * @returns { Typeface } Typeface. 4064 * @static 4065 * @syscap SystemCapability.Graphics.Drawing 4066 * @crossplatform 4067 * @since 20 4068 */ 4069 static makeFromRawFileWithArguments(rawfile: Resource, typefaceArguments: TypefaceArguments): Typeface; 4070 } 4071 4072 /** 4073 * Enumerates the font edging types. 4074 * 4075 * @enum { number } 4076 * @syscap SystemCapability.Graphics.Drawing 4077 * @since 12 4078 */ 4079 /** 4080 * Enumerates the font edging types. 4081 * 4082 * @enum { number } 4083 * @syscap SystemCapability.Graphics.Drawing 4084 * @crossplatform 4085 * @since 20 4086 */ 4087 enum FontEdging { 4088 /** 4089 * No anti-aliasing processing is used. 4090 * @syscap SystemCapability.Graphics.Drawing 4091 * @since 12 4092 */ 4093 /** 4094 * No anti-aliasing processing is used. 4095 * @syscap SystemCapability.Graphics.Drawing 4096 * @crossplatform 4097 * @since 20 4098 */ 4099 ALIAS = 0, 4100 4101 /** 4102 * Uses anti-aliasing to smooth the jagged edges. 4103 * @syscap SystemCapability.Graphics.Drawing 4104 * @since 12 4105 */ 4106 /** 4107 * Uses anti-aliasing to smooth the jagged edges. 4108 * @syscap SystemCapability.Graphics.Drawing 4109 * @crossplatform 4110 * @since 20 4111 */ 4112 ANTI_ALIAS = 1, 4113 4114 /** 4115 * Uses sub-pixel anti-aliasing to provide a smoother effect for jagged edges. 4116 * @syscap SystemCapability.Graphics.Drawing 4117 * @since 12 4118 */ 4119 /** 4120 * Uses sub-pixel anti-aliasing to provide a smoother effect for jagged edges. 4121 * @syscap SystemCapability.Graphics.Drawing 4122 * @crossplatform 4123 * @since 20 4124 */ 4125 SUBPIXEL_ANTI_ALIAS = 2, 4126 } 4127 4128 /** 4129 * Enumerates the font hinting types. 4130 * 4131 * @enum { number } 4132 * @syscap SystemCapability.Graphics.Drawing 4133 * @since 12 4134 */ 4135 /** 4136 * Enumerates the font hinting types. 4137 * 4138 * @enum { number } 4139 * @syscap SystemCapability.Graphics.Drawing 4140 * @crossplatform 4141 * @since 20 4142 */ 4143 enum FontHinting { 4144 /** 4145 * No font hinting is used. 4146 * @syscap SystemCapability.Graphics.Drawing 4147 * @since 12 4148 */ 4149 /** 4150 * No font hinting is used. 4151 * @syscap SystemCapability.Graphics.Drawing 4152 * @crossplatform 4153 * @since 20 4154 */ 4155 NONE = 0, 4156 4157 /** 4158 * Slight font hinting is used to improve contrast. 4159 * @syscap SystemCapability.Graphics.Drawing 4160 * @since 12 4161 */ 4162 /** 4163 * Slight font hinting is used to improve contrast. 4164 * @syscap SystemCapability.Graphics.Drawing 4165 * @crossplatform 4166 * @since 20 4167 */ 4168 SLIGHT = 1, 4169 4170 /** 4171 * Normal font hinting is used to improve contrast. 4172 * @syscap SystemCapability.Graphics.Drawing 4173 * @since 12 4174 */ 4175 /** 4176 * Normal font hinting is used to improve contrast. 4177 * @syscap SystemCapability.Graphics.Drawing 4178 * @crossplatform 4179 * @since 20 4180 */ 4181 NORMAL = 2, 4182 4183 /** 4184 * Full font hinting is used to improve contrast. 4185 * @syscap SystemCapability.Graphics.Drawing 4186 * @since 12 4187 */ 4188 /** 4189 * Full font hinting is used to improve contrast. 4190 * @syscap SystemCapability.Graphics.Drawing 4191 * @crossplatform 4192 * @since 20 4193 */ 4194 FULL = 3, 4195 } 4196 4197 /** 4198 * Describes the attributes used for text rendering, such as size and typeface. 4199 * 4200 * @syscap SystemCapability.Graphics.Drawing 4201 * @since 11 4202 */ 4203 /** 4204 * Describes the attributes used for text rendering, such as size and typeface. 4205 * 4206 * @syscap SystemCapability.Graphics.Drawing 4207 * @crossplatform 4208 * @since 20 4209 * @arkts 1.1&1.2 4210 */ 4211 class Font { 4212 /** 4213 * Enables subpixel font rendering. 4214 * @param { boolean } isSubpixel - Whether to enable subpixel font rendering. 4215 * The value true means to enable subpixel font rendering, and false means the opposite. 4216 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4217 * <br>2. Incorrect parameter types. 4218 * @syscap SystemCapability.Graphics.Drawing 4219 * @since 11 4220 */ 4221 /** 4222 * Enables subpixel font rendering. 4223 * @param { boolean } isSubpixel - Whether to enable subpixel font rendering. 4224 * The value true means to enable subpixel font rendering, and false means the opposite. 4225 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4226 * <br>2. Incorrect parameter types. 4227 * @syscap SystemCapability.Graphics.Drawing 4228 * @crossplatform 4229 * @since 20 4230 */ 4231 enableSubpixel(isSubpixel: boolean): void; 4232 4233 /** 4234 * Enables emboldened fonts. 4235 * @param { boolean } isEmbolden - Whether to enable emboldened fonts. 4236 * The value true means to enable emboldened fonts, and false means the opposite. 4237 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4238 * <br>2. Incorrect parameter types. 4239 * @syscap SystemCapability.Graphics.Drawing 4240 * @since 11 4241 */ 4242 /** 4243 * Enables emboldened fonts. 4244 * @param { boolean } isEmbolden - Whether to enable emboldened fonts. 4245 * The value true means to enable emboldened fonts, and false means the opposite. 4246 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4247 * <br>2. Incorrect parameter types. 4248 * @syscap SystemCapability.Graphics.Drawing 4249 * @crossplatform 4250 * @since 20 4251 */ 4252 enableEmbolden(isEmbolden: boolean): void; 4253 4254 /** 4255 * Enables linear font scaling. 4256 * @param { boolean } isLinearMetrics - Whether to enable linear font scaling. 4257 * The value true means to enable linear font scaling, and false means the opposite. 4258 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4259 * <br>2. Incorrect parameter types. 4260 * @syscap SystemCapability.Graphics.Drawing 4261 * @since 11 4262 */ 4263 /** 4264 * Enables linear font scaling. 4265 * @param { boolean } isLinearMetrics - Whether to enable linear font scaling. 4266 * The value true means to enable linear font scaling, and false means the opposite. 4267 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4268 * <br>2. Incorrect parameter types. 4269 * @syscap SystemCapability.Graphics.Drawing 4270 * @crossplatform 4271 * @since 20 4272 */ 4273 enableLinearMetrics(isLinearMetrics: boolean): void; 4274 4275 /** 4276 * Sets the font size. 4277 * @param { number } textSize - Font size. The value is a floating point number. 4278 * If a negative number is passed in, the size is set to 0. If the size is 0, the text drawn will not be displayed. 4279 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4280 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4281 * @syscap SystemCapability.Graphics.Drawing 4282 * @since 11 4283 */ 4284 /** 4285 * Sets the font size. 4286 * @param { number } textSize - Font size. The value is a floating point number. 4287 * If a negative number is passed in, the size is set to 0. If the size is 0, the text drawn will not be displayed. 4288 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4289 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4290 * @syscap SystemCapability.Graphics.Drawing 4291 * @crossplatform 4292 * @since 20 4293 * @arkts 1.1&1.2 4294 */ 4295 setSize(textSize: number): void; 4296 4297 /** 4298 * Obtains the font size. 4299 * @returns { number } Font size. The value is a floating point number. 4300 * @syscap SystemCapability.Graphics.Drawing 4301 * @since 11 4302 */ 4303 /** 4304 * Obtains the font size. 4305 * @returns { number } Font size. The value is a floating point number. 4306 * @syscap SystemCapability.Graphics.Drawing 4307 * @crossplatform 4308 * @since 20 4309 */ 4310 getSize(): number; 4311 4312 /** 4313 * Sets the typeface style (including attributes such as font name, weight, and italic) for the font. 4314 * @param { Typeface } typeface - Typeface style (including attributes such as font name, weight, and italic). 4315 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4316 * <br>2. Incorrect parameter types. 4317 * @syscap SystemCapability.Graphics.Drawing 4318 * @since 11 4319 */ 4320 /** 4321 * Sets the typeface style (including attributes such as font name, weight, and italic) for the font. 4322 * @param { Typeface } typeface - Typeface style (including attributes such as font name, weight, and italic). 4323 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4324 * <br>2. Incorrect parameter types. 4325 * @syscap SystemCapability.Graphics.Drawing 4326 * @crossplatform 4327 * @since 20 4328 * @arkts 1.1&1.2 4329 */ 4330 setTypeface(typeface: Typeface): void; 4331 4332 /** 4333 * Obtains the typeface. 4334 * @returns { Typeface } Typeface object. 4335 * @syscap SystemCapability.Graphics.Drawing 4336 * @since 11 4337 */ 4338 /** 4339 * Obtains the typeface. 4340 * @returns { Typeface } Typeface object. 4341 * @syscap SystemCapability.Graphics.Drawing 4342 * @crossplatform 4343 * @since 20 4344 * @arkts 1.1&1.2 4345 */ 4346 getTypeface(): Typeface; 4347 4348 /** 4349 * Obtains the font metrics of the typeface. 4350 * @returns { FontMetrics } The fontMetrics value returned to the caller. 4351 * @syscap SystemCapability.Graphics.Drawing 4352 * @since 11 4353 */ 4354 /** 4355 * Obtains the font metrics of the typeface. 4356 * @returns { FontMetrics } The fontMetrics value returned to the caller. 4357 * @syscap SystemCapability.Graphics.Drawing 4358 * @crossplatform 4359 * @since 20 4360 * @arkts 1.1&1.2 4361 */ 4362 getMetrics(): FontMetrics; 4363 4364 /** 4365 * Measures the width of a single character. 4366 * If the typeface of the current font does not support the character to measure, the system typeface is used to measure the character width. 4367 * @param { string } text - Single character to measure. The length of the string must be 1. 4368 * @returns { number } Width of the character. The value is a floating point number. 4369 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4370 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4371 * @syscap SystemCapability.Graphics.Drawing 4372 * @since 12 4373 */ 4374 /** 4375 * Measures the width of a single character. 4376 * If the typeface of the current font does not support the character to measure, the system typeface is used to measure the character width. 4377 * @param { string } text - Single character to measure. The length of the string must be 1. 4378 * @returns { number } Width of the character. The value is a floating point number. 4379 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4380 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4381 * @syscap SystemCapability.Graphics.Drawing 4382 * @crossplatform 4383 * @since 20 4384 */ 4385 measureSingleCharacter(text: string): number; 4386 4387 /** 4388 * Measure a single character with font feature. 4389 * @param { string } text - A string containing only a single character. 4390 * @param { Array<FontFeature> } features - Font Feature Array. 4391 * @returns { number } The width of the single character, in px. 4392 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 4393 * @syscap SystemCapability.Graphics.Drawing 4394 * @crossplatform 4395 * @since 20 4396 */ 4397 measureSingleCharacterWithFeatures(text: string, features: Array<FontFeature>): number; 4398 4399 /** 4400 * Measures the text width. 4401 * @param { string } text - Text Symbol Content. 4402 * @param { TextEncoding } encoding - Encoding format. 4403 * @returns { number } Width of the text. The value is a floating point number. 4404 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4405 * <br>2. Incorrect parameter types. 4406 * @syscap SystemCapability.Graphics.Drawing 4407 * @since 11 4408 */ 4409 /** 4410 * Measures the text width. 4411 * @param { string } text - Text Symbol Content. 4412 * @param { TextEncoding } encoding - Encoding format. 4413 * @returns { number } Width of the text. The value is a floating point number. 4414 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4415 * <br>2. Incorrect parameter types. 4416 * @syscap SystemCapability.Graphics.Drawing 4417 * @crossplatform 4418 * @since 20 4419 */ 4420 measureText(text: string, encoding: TextEncoding): number; 4421 4422 /** 4423 * Sets a horizontal scale factor for this font. 4424 * @param { number } scaleX - Horizontal scale factor. The value is a floating point number. 4425 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4426 * <br>2. Incorrect parameter types. 4427 * @syscap SystemCapability.Graphics.Drawing 4428 * @since 12 4429 */ 4430 /** 4431 * Sets a horizontal scale factor for this font. 4432 * @param { number } scaleX - Horizontal scale factor. The value is a floating point number. 4433 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4434 * <br>2. Incorrect parameter types. 4435 * @syscap SystemCapability.Graphics.Drawing 4436 * @crossplatform 4437 * @since 20 4438 */ 4439 setScaleX(scaleX: number): void; 4440 4441 /** 4442 * Sets a horizontal skew factor for this font. 4443 * @param { number } skewX - Horizontal skew factor. 4444 * A positive number means a skew to the left, and a negative number means a skew to the right. The value is a floating point number. 4445 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4446 * <br>2. Incorrect parameter types. 4447 * @syscap SystemCapability.Graphics.Drawing 4448 * @since 12 4449 */ 4450 /** 4451 * Sets a horizontal skew factor for this font. 4452 * @param { number } skewX - Horizontal skew factor. 4453 * A positive number means a skew to the left, and a negative number means a skew to the right. The value is a floating point number. 4454 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4455 * <br>2. Incorrect parameter types. 4456 * @syscap SystemCapability.Graphics.Drawing 4457 * @crossplatform 4458 * @since 20 4459 */ 4460 setSkewX(skewX: number): void; 4461 4462 /** 4463 * Sets a font edging effect. 4464 * @param { FontEdging } edging - Font edging effect. 4465 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4466 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4467 * @syscap SystemCapability.Graphics.Drawing 4468 * @since 12 4469 */ 4470 /** 4471 * Sets a font edging effect. 4472 * @param { FontEdging } edging - Font edging effect. 4473 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4474 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4475 * @syscap SystemCapability.Graphics.Drawing 4476 * @crossplatform 4477 * @since 20 4478 */ 4479 setEdging(edging: FontEdging): void; 4480 4481 /** 4482 * Sets a font hinting effect. 4483 * @param { FontHinting } hinting - Font hinting effect. 4484 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4485 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4486 * @syscap SystemCapability.Graphics.Drawing 4487 * @since 12 4488 */ 4489 /** 4490 * Sets a font hinting effect. 4491 * @param { FontHinting } hinting - Font hinting effect. 4492 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4493 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4494 * @syscap SystemCapability.Graphics.Drawing 4495 * @crossplatform 4496 * @since 20 4497 */ 4498 setHinting(hinting: FontHinting): void; 4499 4500 /** 4501 * Obtains the number of glyphs represented by text. 4502 * @param { string } text - Indicates the character storage encoded with text encoding. 4503 * @returns { number } Returns the count of text. 4504 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4505 * <br>2. Incorrect parameter types. 4506 * @syscap SystemCapability.Graphics.Drawing 4507 * @since 12 4508 */ 4509 /** 4510 * Obtains the number of glyphs represented by text. 4511 * @param { string } text - Indicates the character storage encoded with text encoding. 4512 * @returns { number } Returns the count of text. 4513 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4514 * <br>2. Incorrect parameter types. 4515 * @syscap SystemCapability.Graphics.Drawing 4516 * @crossplatform 4517 * @since 20 4518 */ 4519 countText(text: string): number; 4520 4521 /** 4522 * Sets whether to request that baselines be snapped to pixels when the current canvas matrix is axis aligned. 4523 * @param { boolean } isBaselineSnap - Whether to request that baselines be snapped to pixels. 4524 * The value true means to request that baselines be snapped to pixels, and false means the opposite. 4525 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4526 * <br>2. Incorrect parameter types. 4527 * @syscap SystemCapability.Graphics.Drawing 4528 * @since 12 4529 */ 4530 /** 4531 * Sets whether to request that baselines be snapped to pixels when the current canvas matrix is axis aligned. 4532 * @param { boolean } isBaselineSnap - Whether to request that baselines be snapped to pixels. 4533 * The value true means to request that baselines be snapped to pixels, and false means the opposite. 4534 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4535 * <br>2. Incorrect parameter types. 4536 * @syscap SystemCapability.Graphics.Drawing 4537 * @crossplatform 4538 * @since 20 4539 */ 4540 setBaselineSnap(isBaselineSnap: boolean): void; 4541 4542 /** 4543 * Checks whether baselines are requested to be snapped to pixels when the current canvas matrix is axis aligned. 4544 * @returns { boolean } Check result. The value true means that the baselines are requested to be snapped to pixels, 4545 * and false means the opposite. 4546 * @syscap SystemCapability.Graphics.Drawing 4547 * @since 12 4548 */ 4549 /** 4550 * Checks whether baselines are requested to be snapped to pixels when the current canvas matrix is axis aligned. 4551 * @returns { boolean } Check result. The value true means that the baselines are requested to be snapped to pixels, 4552 * and false means the opposite. 4553 * @syscap SystemCapability.Graphics.Drawing 4554 * @crossplatform 4555 * @since 20 4556 */ 4557 isBaselineSnap(): boolean; 4558 4559 /** 4560 * Sets whether to use bitmaps in this font. 4561 * @param { boolean } isEmbeddedBitmaps - Whether to use bitmaps in the font. The value true means to use bitmaps in the font, 4562 * and false means the opposite. 4563 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4564 * <br>2. Incorrect parameter types. 4565 * @syscap SystemCapability.Graphics.Drawing 4566 * @since 12 4567 */ 4568 /** 4569 * Sets whether to use bitmaps in this font. 4570 * @param { boolean } isEmbeddedBitmaps - Whether to use bitmaps in the font. The value true means to use bitmaps in the font, 4571 * and false means the opposite. 4572 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4573 * <br>2. Incorrect parameter types. 4574 * @syscap SystemCapability.Graphics.Drawing 4575 * @crossplatform 4576 * @since 20 4577 */ 4578 setEmbeddedBitmaps(isEmbeddedBitmaps: boolean): void; 4579 4580 /** 4581 * Checks whether bitmaps are used in this font. 4582 * @returns { boolean } Check result. The value true means that the bitmaps are used, and false means the opposite. 4583 * @syscap SystemCapability.Graphics.Drawing 4584 * @since 12 4585 */ 4586 /** 4587 * Checks whether bitmaps are used in this font. 4588 * @returns { boolean } Check result. The value true means that the bitmaps are used, and false means the opposite. 4589 * @syscap SystemCapability.Graphics.Drawing 4590 * @crossplatform 4591 * @since 20 4592 */ 4593 isEmbeddedBitmaps(): boolean; 4594 4595 /** 4596 * Sets whether to forcibly use auto hinting, that is, whether to always hint glyphs. 4597 * @param { boolean } isForceAutoHinting - Whether to forcibly use auto hinting. The value true means to forcibly use auto hinting, 4598 * and false means the opposite. 4599 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4600 * <br>2. Incorrect parameter types. 4601 * @syscap SystemCapability.Graphics.Drawing 4602 * @since 12 4603 */ 4604 /** 4605 * Sets whether to forcibly use auto hinting, that is, whether to always hint glyphs. 4606 * @param { boolean } isForceAutoHinting - Whether to forcibly use auto hinting. The value true means to forcibly use auto hinting, 4607 * and false means the opposite. 4608 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4609 * <br>2. Incorrect parameter types. 4610 * @syscap SystemCapability.Graphics.Drawing 4611 * @crossplatform 4612 * @since 20 4613 */ 4614 setForceAutoHinting(isForceAutoHinting: boolean): void; 4615 4616 /** 4617 * Checks whether auto hinting is forcibly used. 4618 * @returns { boolean } Check result. The value true means that auto hinting is forcibly used, and false means the opposite. 4619 * @syscap SystemCapability.Graphics.Drawing 4620 * @since 12 4621 */ 4622 /** 4623 * Checks whether auto hinting is forcibly used. 4624 * @returns { boolean } Check result. The value true means that auto hinting is forcibly used, and false means the opposite. 4625 * @syscap SystemCapability.Graphics.Drawing 4626 * @crossplatform 4627 * @since 20 4628 */ 4629 isForceAutoHinting(): boolean; 4630 4631 /** 4632 * Obtains the width of each glyph in an array. 4633 * @param { Array<number> } glyphs - Glyph array, which can be generated by textToGlyphs. 4634 * @returns { Array<number> } Glyph array, which can be generated by textToGlyphs. 4635 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4636 * <br>2. Incorrect parameter types. 4637 * @syscap SystemCapability.Graphics.Drawing 4638 * @since 12 4639 */ 4640 /** 4641 * Obtains the width of each glyph in an array. 4642 * @param { Array<number> } glyphs - Glyph array, which can be generated by textToGlyphs. 4643 * @returns { Array<number> } Glyph array, which can be generated by textToGlyphs. 4644 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4645 * <br>2. Incorrect parameter types. 4646 * @syscap SystemCapability.Graphics.Drawing 4647 * @crossplatform 4648 * @since 20 4649 */ 4650 getWidths(glyphs: Array<number>): Array<number>; 4651 4652 /** 4653 * Converts text into glyph indexes. 4654 * @param { string } text - Text string. 4655 * @param { number } glyphCount - Number of glyphs represented by the text. The value must be the same as the value obtained from countText. 4656 * The default value is the number of characters in the text string. The value is an integer. 4657 * @returns { Array<number> } Returns the storage for glyph indices. 4658 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4659 * <br>2. Incorrect parameter types. 4660 * @syscap SystemCapability.Graphics.Drawing 4661 * @since 12 4662 */ 4663 /** 4664 * Converts text into glyph indexes. 4665 * @param { string } text - Text string. 4666 * @param { number } glyphCount - Number of glyphs represented by the text. The value must be the same as the value obtained from countText. 4667 * The default value is the number of characters in the text string. The value is an integer. 4668 * @returns { Array<number> } Returns the storage for glyph indices. 4669 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4670 * <br>2. Incorrect parameter types. 4671 * @syscap SystemCapability.Graphics.Drawing 4672 * @crossplatform 4673 * @since 20 4674 */ 4675 textToGlyphs(text: string, glyphCount?: number): Array<number>; 4676 4677 /** 4678 * Checks whether sub-pixel rendering is used for this font. 4679 * @returns { boolean } Check result. The value true means that sub-pixel rendering is used, and false means the opposite. 4680 * @syscap SystemCapability.Graphics.Drawing 4681 * @since 12 4682 */ 4683 /** 4684 * Checks whether sub-pixel rendering is used for this font. 4685 * @returns { boolean } Check result. The value true means that sub-pixel rendering is used, and false means the opposite. 4686 * @syscap SystemCapability.Graphics.Drawing 4687 * @crossplatform 4688 * @since 20 4689 */ 4690 isSubpixel(): boolean; 4691 4692 /** 4693 * Checks whether linear scaling is used for this font. 4694 * @returns { boolean } Checks whether linear scaling is used for this font. 4695 * @syscap SystemCapability.Graphics.Drawing 4696 * @since 12 4697 */ 4698 /** 4699 * Checks whether linear scaling is used for this font. 4700 * @returns { boolean } Checks whether linear scaling is used for this font. 4701 * @syscap SystemCapability.Graphics.Drawing 4702 * @crossplatform 4703 * @since 20 4704 */ 4705 isLinearMetrics(): boolean; 4706 4707 /** 4708 * Obtains the horizontal skew factor of this font. 4709 * @returns { number } Horizontal skew factor. 4710 * @syscap SystemCapability.Graphics.Drawing 4711 * @since 12 4712 */ 4713 /** 4714 * Obtains the horizontal skew factor of this font. 4715 * @returns { number } Horizontal skew factor. 4716 * @syscap SystemCapability.Graphics.Drawing 4717 * @crossplatform 4718 * @since 20 4719 */ 4720 getSkewX(): number; 4721 4722 /** 4723 * Checks whether the bold effect is set for this font. 4724 * @returns { boolean } Check result. The value true means that the bold effect is set, and false means the opposite. 4725 * returns false otherwise. 4726 * @syscap SystemCapability.Graphics.Drawing 4727 * @since 12 4728 */ 4729 /** 4730 * Checks whether the bold effect is set for this font. 4731 * @returns { boolean } Check result. The value true means that the bold effect is set, and false means the opposite. 4732 * returns false otherwise. 4733 * @syscap SystemCapability.Graphics.Drawing 4734 * @crossplatform 4735 * @since 20 4736 */ 4737 isEmbolden(): boolean; 4738 4739 /** 4740 * Obtains the horizontal scale ratio of this font. 4741 * @returns { number } Horizontal scale ratio. 4742 * @syscap SystemCapability.Graphics.Drawing 4743 * @since 12 4744 */ 4745 /** 4746 * Obtains the horizontal scale ratio of this font. 4747 * @returns { number } Horizontal scale ratio. 4748 * @syscap SystemCapability.Graphics.Drawing 4749 * @crossplatform 4750 * @since 20 4751 */ 4752 getScaleX(): number; 4753 4754 /** 4755 * Obtains the font hinting effect. 4756 * @returns { FontHinting } Font hinting effect. 4757 * @syscap SystemCapability.Graphics.Drawing 4758 * @since 12 4759 */ 4760 /** 4761 * Obtains the font hinting effect. 4762 * @returns { FontHinting } Font hinting effect. 4763 * @syscap SystemCapability.Graphics.Drawing 4764 * @crossplatform 4765 * @since 20 4766 */ 4767 getHinting(): FontHinting; 4768 4769 /** 4770 * Obtains the font edging effect. 4771 * @returns { FontEdging } Font edging effect. 4772 * @syscap SystemCapability.Graphics.Drawing 4773 * @since 12 4774 */ 4775 /** 4776 * Obtains the font edging effect. 4777 * @returns { FontEdging } Font edging effect. 4778 * @syscap SystemCapability.Graphics.Drawing 4779 * @crossplatform 4780 * @since 20 4781 */ 4782 getEdging(): FontEdging; 4783 4784 /** 4785 * Obtains the outline path of a glyph. 4786 * @param { number } index - Index of the glyph. 4787 * @returns { Path } Outline path of the glyph. 4788 * Note: Path use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. 4789 * @syscap SystemCapability.Graphics.Drawing 4790 * @since 18 4791 */ 4792 /** 4793 * Obtains the outline path of a glyph. 4794 * @param { number } index - Index of the glyph. 4795 * @returns { Path } Outline path of the glyph. 4796 * Note: Path use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. 4797 * @syscap SystemCapability.Graphics.Drawing 4798 * @crossplatform 4799 * @since 20 4800 */ 4801 createPathForGlyph(index: number): Path; 4802 4803 /** 4804 * Obtains the rectangular bounding box of each glyph in an array. 4805 * @param { Array<number> } glyphs - Glyph array, which can be generated by textToGlyphs. 4806 * @returns { Array<common2D.Rect> } Array that holds the rectangular bounding boxes. 4807 * Note: 1. Rect use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. 4808 * <br>2. Rect use two points(left-bottom & right-top) to describe the bound. 4809 * <br>3. The bound rect will be snap to integral boundaries. 4810 * @syscap SystemCapability.Graphics.Drawing 4811 * @since 18 4812 */ 4813 /** 4814 * Obtains the rectangular bounding box of each glyph in an array. 4815 * @param { Array<number> } glyphs - Glyph array, which can be generated by textToGlyphs. 4816 * @returns { Array<common2D.Rect> } Array that holds the rectangular bounding boxes. 4817 * Note: 1. Rect use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. 4818 * <br>2. Rect use two points(left-bottom & right-top) to describe the bound. 4819 * <br>3. The bound rect will be snap to integral boundaries. 4820 * @syscap SystemCapability.Graphics.Drawing 4821 * @crossplatform 4822 * @since 20 4823 */ 4824 getBounds(glyphs: Array<number>): Array<common2D.Rect>; 4825 4826 /** 4827 * Obtains the outline path of a text. 4828 * @param { string } text - UTF-8 text-encoded characters. 4829 * @param { number } byteLength - Length of the outline path, 4830 * which is obtained based on the minimum value between the passed value of byteLength and the actual text byte size. 4831 * @param { number } x - X coordinate of the text in the drawing area, with the origin as the start point. 4832 * @param { number } y - Y coordinate of the text in the drawing area, with the origin as the start point. 4833 * @returns { Path } Outline path of the text. 4834 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4835 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4836 * @syscap SystemCapability.Graphics.Drawing 4837 * @since 18 4838 */ 4839 /** 4840 * Obtains the outline path of a text. 4841 * @param { string } text - UTF-8 text-encoded characters. 4842 * @param { number } byteLength - Length of the outline path, 4843 * which is obtained based on the minimum value between the passed value of byteLength and the actual text byte size. 4844 * @param { number } x - X coordinate of the text in the drawing area, with the origin as the start point. 4845 * @param { number } y - Y coordinate of the text in the drawing area, with the origin as the start point. 4846 * @returns { Path } Outline path of the text. 4847 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4848 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4849 * @syscap SystemCapability.Graphics.Drawing 4850 * @crossplatform 4851 * @since 20 4852 */ 4853 getTextPath(text: string, byteLength: number, x: number, y: number): Path; 4854 4855 /** 4856 * Sets whether to follow the theme font. When followed is set to true, 4857 * the theme font is used if it is enabled by the system and no typeface is set. 4858 * @param { boolean } followed - Whether to follow the theme font. 4859 * The value true means to follow the theme font, and false means the opposite. 4860 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4861 * <br>2. Incorrect parameter types. 4862 * @syscap SystemCapability.Graphics.Drawing 4863 * @since 15 4864 */ 4865 /** 4866 * Sets whether to follow the theme font. When followed is set to true, 4867 * the theme font is used if it is enabled by the system and no typeface is set. 4868 * @param { boolean } followed - Whether to follow the theme font. 4869 * The value true means to follow the theme font, and false means the opposite. 4870 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4871 * <br>2. Incorrect parameter types. 4872 * @syscap SystemCapability.Graphics.Drawing 4873 * @crossplatform 4874 * @since 20 4875 */ 4876 setThemeFontFollowed(followed: boolean): void; 4877 4878 /** 4879 * Checks whether the font follows the theme font. By default, the font follows the theme font. 4880 * @returns { boolean } Check result. The value true means that the theme font is followed, and false means the opposite. 4881 * @syscap SystemCapability.Graphics.Drawing 4882 * @since 15 4883 */ 4884 /** 4885 * Checks whether the font follows the theme font. By default, the font follows the theme font. 4886 * @returns { boolean } Check result. The value true means that the theme font is followed, and false means the opposite. 4887 * @syscap SystemCapability.Graphics.Drawing 4888 * @crossplatform 4889 * @since 20 4890 */ 4891 isThemeFontFollowed(): boolean; 4892 } 4893 4894 /** 4895 * Enumerates the font measurement flags, which is used to specify whether a field in the font measurement information is valid. 4896 * @enum { number } 4897 * @syscap SystemCapability.Graphics.Drawing 4898 * @since 12 4899 */ 4900 /** 4901 * Enumerates the font measurement flags, which is used to specify whether a field in the font measurement information is valid. 4902 * @enum { number } 4903 * @syscap SystemCapability.Graphics.Drawing 4904 * @crossplatform 4905 * @since 20 4906 */ 4907 enum FontMetricsFlags { 4908 /** 4909 * The underlineThickness field in the FontMetrics struct is valid. 4910 * @syscap SystemCapability.Graphics.Drawing 4911 * @since 12 4912 */ 4913 /** 4914 * The underlineThickness field in the FontMetrics struct is valid. 4915 * @syscap SystemCapability.Graphics.Drawing 4916 * @crossplatform 4917 * @since 20 4918 */ 4919 UNDERLINE_THICKNESS_VALID = 1 << 0, 4920 4921 /** 4922 * The underlinePosition field in the FontMetrics struct is valid. 4923 * @syscap SystemCapability.Graphics.Drawing 4924 * @since 12 4925 */ 4926 /** 4927 * The underlinePosition field in the FontMetrics struct is valid. 4928 * @syscap SystemCapability.Graphics.Drawing 4929 * @crossplatform 4930 * @since 20 4931 */ 4932 UNDERLINE_POSITION_VALID = 1 << 1, 4933 4934 /** 4935 * The strikethroughThickness field in the FontMetrics struct is valid. 4936 * @syscap SystemCapability.Graphics.Drawing 4937 * @since 12 4938 */ 4939 /** 4940 * The strikethroughThickness field in the FontMetrics struct is valid. 4941 * @syscap SystemCapability.Graphics.Drawing 4942 * @crossplatform 4943 * @since 20 4944 */ 4945 STRIKETHROUGH_THICKNESS_VALID = 1 << 2, 4946 4947 /** 4948 * The strikethroughPosition field in the FontMetrics struct is valid. 4949 * @syscap SystemCapability.Graphics.Drawing 4950 * @since 12 4951 */ 4952 /** 4953 * The strikethroughPosition field in the FontMetrics struct is valid. 4954 * @syscap SystemCapability.Graphics.Drawing 4955 * @crossplatform 4956 * @since 20 4957 */ 4958 STRIKETHROUGH_POSITION_VALID = 1 << 3, 4959 4960 /** 4961 * The boundary metrics (such as top, bottom, xMin, and xMax) in the FontMetrics struct are invalid. 4962 * @syscap SystemCapability.Graphics.Drawing 4963 * @since 12 4964 */ 4965 /** 4966 * The boundary metrics (such as top, bottom, xMin, and xMax) in the FontMetrics struct are invalid. 4967 * @syscap SystemCapability.Graphics.Drawing 4968 * @crossplatform 4969 * @since 20 4970 */ 4971 BOUNDS_INVALID = 1 << 4, 4972 } 4973 4974 /** 4975 * Describes the attributes that describe the font size and layout. A typeface has similar font metrics. 4976 * @typedef FontMetrics 4977 * @syscap SystemCapability.Graphics.Drawing 4978 * @since 11 4979 */ 4980 /** 4981 * Describes the attributes that describe the font size and layout. A typeface has similar font metrics. 4982 * @typedef FontMetrics 4983 * @syscap SystemCapability.Graphics.Drawing 4984 * @crossplatform 4985 * @since 20 4986 * @arkts 1.1&1.2 4987 */ 4988 interface FontMetrics { 4989 /** 4990 * Font measurement flags that are valid. 4991 * @type { ?FontMetricsFlags } 4992 * @syscap SystemCapability.Graphics.Drawing 4993 * @since 12 4994 */ 4995 /** 4996 * Font measurement flags that are valid. 4997 * @type { ?FontMetricsFlags } 4998 * @syscap SystemCapability.Graphics.Drawing 4999 * @crossplatform 5000 * @since 20 5001 */ 5002 flags?: FontMetricsFlags; 5003 5004 /** 5005 * Maximum distance from the baseline to the highest coordinate of the text. The value is a floating point number. 5006 * @type { number } 5007 * @syscap SystemCapability.Graphics.Drawing 5008 * @since 11 5009 */ 5010 /** 5011 * Maximum distance from the baseline to the highest coordinate of the text. The value is a floating point number. 5012 * @type { number } 5013 * @syscap SystemCapability.Graphics.Drawing 5014 * @crossplatform 5015 * @since 20 5016 * @arkts 1.1&1.2 5017 */ 5018 top: number; 5019 /** 5020 * Distance from the baseline to the highest coordinate of the text. The value is a floating point number. 5021 * @type { number } 5022 * @syscap SystemCapability.Graphics.Drawing 5023 * @since 11 5024 */ 5025 /** 5026 * Distance from the baseline to the highest coordinate of the text. The value is a floating point number. 5027 * @type { number } 5028 * @syscap SystemCapability.Graphics.Drawing 5029 * @crossplatform 5030 * @since 20 5031 * @arkts 1.1&1.2 5032 */ 5033 ascent: number; 5034 /** 5035 * Distance from the baseline to the lowest coordinate of the text. The value is a floating point number. 5036 * @type { number } 5037 * @syscap SystemCapability.Graphics.Drawing 5038 * @since 11 5039 */ 5040 /** 5041 * Distance from the baseline to the lowest coordinate of the text. The value is a floating point number. 5042 * @type { number } 5043 * @syscap SystemCapability.Graphics.Drawing 5044 * @crossplatform 5045 * @since 20 5046 * @arkts 1.1&1.2 5047 */ 5048 descent: number; 5049 /** 5050 * Maximum distance from the baseline to the lowest coordinate of the text. The value is a floating point number. 5051 * @type { number } 5052 * @syscap SystemCapability.Graphics.Drawing 5053 * @since 11 5054 */ 5055 /** 5056 * Maximum distance from the baseline to the lowest coordinate of the text. The value is a floating point number. 5057 * @type { number } 5058 * @syscap SystemCapability.Graphics.Drawing 5059 * @crossplatform 5060 * @since 20 5061 * @arkts 1.1&1.2 5062 */ 5063 bottom: number; 5064 /** 5065 * Interline spacing, that is, the distance from the descent of one line of text to the ascent of the next line. 5066 * The value is a floating point number. 5067 * @type { number } 5068 * @syscap SystemCapability.Graphics.Drawing 5069 * @since 11 5070 */ 5071 /** 5072 * Interline spacing, that is, the distance from the descent of one line of text to the ascent of the next line. 5073 * The value is a floating point number. 5074 * @type { number } 5075 * @syscap SystemCapability.Graphics.Drawing 5076 * @crossplatform 5077 * @since 20 5078 */ 5079 leading: number; 5080 /** 5081 * Average character width. 5082 * @type { ?number } 5083 * @syscap SystemCapability.Graphics.Drawing 5084 * @since 12 5085 */ 5086 /** 5087 * Average character width. 5088 * @type { ?number } 5089 * @syscap SystemCapability.Graphics.Drawing 5090 * @crossplatform 5091 * @since 20 5092 */ 5093 avgCharWidth?: number; 5094 5095 /** 5096 * Maximum character width. 5097 * @type { ?number } 5098 * @syscap SystemCapability.Graphics.Drawing 5099 * @since 12 5100 */ 5101 /** 5102 * Maximum character width. 5103 * @type { ?number } 5104 * @syscap SystemCapability.Graphics.Drawing 5105 * @crossplatform 5106 * @since 20 5107 */ 5108 maxCharWidth?: number; 5109 5110 /** 5111 * Horizontal distance from the leftmost edge of any glyph bounding box to the origin. 5112 * This value is usually less than 0, indicating the minimum horizontal coordinate across all glyph bounding boxes. 5113 * @type { ?number } 5114 * @syscap SystemCapability.Graphics.Drawing 5115 * @since 12 5116 */ 5117 /** 5118 * Horizontal distance from the leftmost edge of any glyph bounding box to the origin. 5119 * This value is usually less than 0, indicating the minimum horizontal coordinate across all glyph bounding boxes. 5120 * @type { ?number } 5121 * @syscap SystemCapability.Graphics.Drawing 5122 * @crossplatform 5123 * @since 20 5124 */ 5125 xMin?: number; 5126 5127 /** 5128 * Horizontal distance from the rightmost edge of any glyph bounding box to the origin. 5129 * The value is a positive number, indicating the maximum horizontal coordinate across all glyph bounding boxes. 5130 * @type { ?number } 5131 * @syscap SystemCapability.Graphics.Drawing 5132 * @since 12 5133 */ 5134 /** 5135 * Horizontal distance from the rightmost edge of any glyph bounding box to the origin. 5136 * The value is a positive number, indicating the maximum horizontal coordinate across all glyph bounding boxes. 5137 * @type { ?number } 5138 * @syscap SystemCapability.Graphics.Drawing 5139 * @crossplatform 5140 * @since 20 5141 */ 5142 xMax?: number; 5143 5144 /** 5145 * Height of the lowercase letter x. The value is usually a negative value. 5146 * @type { ?number } 5147 * @syscap SystemCapability.Graphics.Drawing 5148 * @since 12 5149 */ 5150 /** 5151 * Height of the lowercase letter x. The value is usually a negative value. 5152 * @type { ?number } 5153 * @syscap SystemCapability.Graphics.Drawing 5154 * @crossplatform 5155 * @since 20 5156 */ 5157 xHeight?: number; 5158 5159 /** 5160 * Height of a capital letter. The value is usually a negative value. 5161 * @type { ?number } 5162 * @syscap SystemCapability.Graphics.Drawing 5163 * @since 12 5164 */ 5165 /** 5166 * Height of a capital letter. The value is usually a negative value. 5167 * @type { ?number } 5168 * @syscap SystemCapability.Graphics.Drawing 5169 * @crossplatform 5170 * @since 20 5171 */ 5172 capHeight?: number; 5173 5174 /** 5175 * Thickness of the underline. 5176 * @type { ?number } 5177 * @syscap SystemCapability.Graphics.Drawing 5178 * @since 12 5179 */ 5180 /** 5181 * Thickness of the underline. 5182 * @type { ?number } 5183 * @syscap SystemCapability.Graphics.Drawing 5184 * @crossplatform 5185 * @since 20 5186 */ 5187 underlineThickness?: number; 5188 5189 /** 5190 * Vertical distance from the baseline to the top of the underline. The value is usually a positive number. 5191 * @type { ?number } 5192 * @syscap SystemCapability.Graphics.Drawing 5193 * @since 12 5194 */ 5195 /** 5196 * Vertical distance from the baseline to the top of the underline. The value is usually a positive number. 5197 * @type { ?number } 5198 * @syscap SystemCapability.Graphics.Drawing 5199 * @crossplatform 5200 * @since 20 5201 */ 5202 underlinePosition?: number; 5203 5204 /** 5205 * Thickness of the strikethrough. 5206 * @type { ?number } 5207 * @syscap SystemCapability.Graphics.Drawing 5208 * @since 12 5209 */ 5210 /** 5211 * Thickness of the strikethrough. 5212 * @type { ?number } 5213 * @syscap SystemCapability.Graphics.Drawing 5214 * @crossplatform 5215 * @since 20 5216 */ 5217 strikethroughThickness?: number; 5218 5219 /** 5220 * Vertical distance from the baseline to the bottom of the strikethrough. The value is usually a negative value. 5221 * @type { ?number } 5222 * @syscap SystemCapability.Graphics.Drawing 5223 * @since 12 5224 */ 5225 /** 5226 * Vertical distance from the baseline to the bottom of the strikethrough. The value is usually a negative value. 5227 * @type { ?number } 5228 * @syscap SystemCapability.Graphics.Drawing 5229 * @crossplatform 5230 * @since 20 5231 */ 5232 strikethroughPosition?: number; 5233 } 5234 5235 /** 5236 * Implements a lattice object, which is used to divide an image by lattice. 5237 * @syscap SystemCapability.Graphics.Drawing 5238 * @since 12 5239 */ 5240 /** 5241 * Implements a lattice object, which is used to divide an image by lattice. 5242 * @syscap SystemCapability.Graphics.Drawing 5243 * @crossplatform 5244 * @since 20 5245 * @arkts 1.1&1.2 5246 */ 5247 class Lattice { 5248 /** 5249 * Divides the image into lattices. The lattices on both even columns and even rows are fixed, 5250 * and they are drawn at their original size if the target is large enough. 5251 * If the target is too small to hold the fixed lattices, all the fixed lattices are scaled down to fit the target, 5252 * and the lattices that are not on even columns and even rows are scaled to accommodate the remaining space. 5253 * @param { Array<number> } xDivs - Array of X coordinates used to divide the image. The value is an integer. 5254 * @param { Array<number> } yDivs - Array of Y coordinates used to divide the image. The value is an integer. 5255 * @param { number } fXCount - Size of the array that holds the X coordinates. The value range is [0, 5]. 5256 * @param { number } fYCount - Size of the array that holds the Y coordinates. The value range is [0, 5]. 5257 * @param { common2D.Rect | null } fBounds - Source bounds to draw. The rectangle parameter must be an integer. 5258 * The default value is the rectangle size of the original image. If the rectangle parameter is a decimal, 5259 * the decimal part is discarded and converted into an integer. 5260 * @param { Array<RectType> | null } fRectTypes - Array that holds the rectangle types. The default value is null. 5261 * If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5262 * @param { Array<common2D.Color> | null } fColors - Array that holds the colors used to fill the lattices. The default value is null. 5263 * If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5264 * @returns { Lattice } Lattice object. 5265 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5266 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5267 * @static 5268 * @syscap SystemCapability.Graphics.Drawing 5269 * @since 12 5270 */ 5271 /** 5272 * Divides the image into lattices. The lattices on both even columns and even rows are fixed, 5273 * and they are drawn at their original size if the target is large enough. 5274 * If the target is too small to hold the fixed lattices, all the fixed lattices are scaled down to fit the target, 5275 * and the lattices that are not on even columns and even rows are scaled to accommodate the remaining space. 5276 * @param { Array<number> } xDivs - Array of X coordinates used to divide the image. The value is an integer. 5277 * @param { Array<number> } yDivs - Array of Y coordinates used to divide the image. The value is an integer. 5278 * @param { number } fXCount - Size of the array that holds the X coordinates. The value range is [0, 5]. 5279 * @param { number } fYCount - Size of the array that holds the Y coordinates. The value range is [0, 5]. 5280 * @param { common2D.Rect | null } fBounds - Source bounds to draw. The rectangle parameter must be an integer. 5281 * The default value is the rectangle size of the original image. If the rectangle parameter is a decimal, 5282 * the decimal part is discarded and converted into an integer. 5283 * @param { Array<RectType> | null } fRectTypes - Array that holds the rectangle types. The default value is null. 5284 * If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5285 * @param { Array<common2D.Color> | null } fColors - Array that holds the colors used to fill the lattices. The default value is null. 5286 * If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5287 * @returns { Lattice } Lattice object. 5288 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5289 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5290 * @static 5291 * @syscap SystemCapability.Graphics.Drawing 5292 * @crossplatform 5293 * @since 20 5294 * @arkts 1.1&1.2 5295 */ 5296 static createImageLattice(xDivs: Array<number>, yDivs: Array<number>, fXCount: number, fYCount: number, 5297 fBounds?: common2D.Rect | null, fRectTypes?: Array<RectType> | null, fColors?: Array<common2D.Color> | null): Lattice; 5298 5299 /** 5300 * Divides the image into lattices. The lattices on both even columns and even rows are fixed, 5301 * and they are drawn at their original size if the target is large enough. 5302 * If the target is too small to hold the fixed lattices, all the fixed lattices are scaled down to fit the target, 5303 * and the lattices that are not on even columns and even rows are scaled to accommodate the remaining space. 5304 * @param { Array<number> } xDivs - Array of X coordinates used to divide the image. The value is an integer. 5305 * @param { Array<number> } yDivs - Array of Y coordinates used to divide the image. The value is an integer. 5306 * @param { number } fXCount - Size of the array that holds the X coordinates. The value range is [0, 5]. 5307 * @param { number } fYCount - Size of the array that holds the Y coordinates. The value range is [0, 5]. 5308 * @param { common2D.Rect | null } fBounds - Source bounds to draw. The rectangle parameter must be an integer. 5309 * The default value is the rectangle size of the original image. If the rectangle parameter is a decimal, 5310 * the decimal part is discarded and converted into an integer. 5311 * @param { Array<RectType> | null } fRectTypes - Array that holds the rectangle types. The default value is null. 5312 * If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5313 * @param { Array<number> | null } fColors - Array that holds the colors used to fill the lattices. 5314 * Each color is represented by a 32-bit unsigned integer in hexadecimal ARGB format. 5315 * The default value is null. If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5316 * @returns { Lattice } Lattice object. 5317 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5318 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5319 * @static 5320 * @syscap SystemCapability.Graphics.Drawing 5321 * @since 18 5322 */ 5323 /** 5324 * Divides the image into lattices. The lattices on both even columns and even rows are fixed, 5325 * and they are drawn at their original size if the target is large enough. 5326 * If the target is too small to hold the fixed lattices, all the fixed lattices are scaled down to fit the target, 5327 * and the lattices that are not on even columns and even rows are scaled to accommodate the remaining space. 5328 * @param { Array<number> } xDivs - Array of X coordinates used to divide the image. The value is an integer. 5329 * @param { Array<number> } yDivs - Array of Y coordinates used to divide the image. The value is an integer. 5330 * @param { number } fXCount - Size of the array that holds the X coordinates. The value range is [0, 5]. 5331 * @param { number } fYCount - Size of the array that holds the Y coordinates. The value range is [0, 5]. 5332 * @param { common2D.Rect | null } fBounds - Source bounds to draw. The rectangle parameter must be an integer. 5333 * The default value is the rectangle size of the original image. If the rectangle parameter is a decimal, 5334 * the decimal part is discarded and converted into an integer. 5335 * @param { Array<RectType> | null } fRectTypes - Array that holds the rectangle types. The default value is null. 5336 * If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5337 * @param { Array<number> | null } fColors - Array that holds the colors used to fill the lattices. 5338 * Each color is represented by a 32-bit unsigned integer in hexadecimal ARGB format. 5339 * The default value is null. If this parameter is specified, the array size must be (fXCount + 1) * (fYCount + 1). 5340 * @returns { Lattice } Lattice object. 5341 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5342 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5343 * @static 5344 * @syscap SystemCapability.Graphics.Drawing 5345 * @crossplatform 5346 * @since 20 5347 */ 5348 static createImageLattice(xDivs: Array<number>, yDivs: Array<number>, fXCount: number, fYCount: number, 5349 fBounds?: common2D.Rect | null, fRectTypes?: Array<RectType> | null, fColors?: Array<number> | null): Lattice; 5350 } 5351 5352 /** 5353 * Enumerates the types of rectangles used to fill the lattices. This enum is used only in Lattice. 5354 * @enum { number } 5355 * @syscap SystemCapability.Graphics.Drawing 5356 * @since 12 5357 */ 5358 /** 5359 * Enumerates the types of rectangles used to fill the lattices. This enum is used only in Lattice. 5360 * @enum { number } 5361 * @syscap SystemCapability.Graphics.Drawing 5362 * @crossplatform 5363 * @since 20 5364 * @arkts 1.1&1.2 5365 */ 5366 enum RectType { 5367 /** 5368 * Draws an image into the lattice. 5369 * @syscap SystemCapability.Graphics.Drawing 5370 * @since 12 5371 */ 5372 /** 5373 * Draws an image into the lattice. 5374 * @syscap SystemCapability.Graphics.Drawing 5375 * @crossplatform 5376 * @since 20 5377 * @arkts 1.1&1.2 5378 */ 5379 DEFAULT = 0, 5380 5381 /** 5382 * Sets the lattice to transparent. 5383 * @syscap SystemCapability.Graphics.Drawing 5384 * @since 12 5385 */ 5386 /** 5387 * Sets the lattice to transparent. 5388 * @syscap SystemCapability.Graphics.Drawing 5389 * @crossplatform 5390 * @since 20 5391 * @arkts 1.1&1.2 5392 */ 5393 TRANSPARENT = 1, 5394 5395 /** 5396 * Draws the colors in the fColors array in Lattice into the lattice. 5397 * @syscap SystemCapability.Graphics.Drawing 5398 * @since 12 5399 */ 5400 /** 5401 * Draws the colors in the fColors array in Lattice into the lattice. 5402 * @syscap SystemCapability.Graphics.Drawing 5403 * @crossplatform 5404 * @since 20 5405 * @arkts 1.1&1.2 5406 */ 5407 FIXEDCOLOR = 2 5408 } 5409 5410 /** 5411 * Implements a mask filter. 5412 * @syscap SystemCapability.Graphics.Drawing 5413 * @since 12 5414 */ 5415 /** 5416 * Implements a mask filter. 5417 * @syscap SystemCapability.Graphics.Drawing 5418 * @crossplatform 5419 * @since 20 5420 */ 5421 class MaskFilter { 5422 /** 5423 * Creates a mask filter with a blur effect. 5424 * @param { BlurType } blurType - Blur type. 5425 * @param { number } sigma - Standard deviation of the Gaussian blur to apply. The value must be a floating point number greater than 0. 5426 * @returns { MaskFilter } MaskFilter object. 5427 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5428 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5429 * @static 5430 * @syscap SystemCapability.Graphics.Drawing 5431 * @since 12 5432 */ 5433 /** 5434 * Creates a mask filter with a blur effect. 5435 * @param { BlurType } blurType - Blur type. 5436 * @param { number } sigma - Standard deviation of the Gaussian blur to apply. The value must be a floating point number greater than 0. 5437 * @returns { MaskFilter } MaskFilter object. 5438 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5439 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5440 * @static 5441 * @syscap SystemCapability.Graphics.Drawing 5442 * @crossplatform 5443 * @since 20 5444 */ 5445 static createBlurMaskFilter(blurType: BlurType, sigma: number): MaskFilter; 5446 } 5447 5448 /** 5449 * Enumerates the styles of the dashed path effect. 5450 * @enum { number } 5451 * @syscap SystemCapability.Graphics.Drawing 5452 * @since 18 5453 */ 5454 /** 5455 * Enumerates the styles of the dashed path effect. 5456 * @enum { number } 5457 * @syscap SystemCapability.Graphics.Drawing 5458 * @crossplatform 5459 * @since 20 5460 */ 5461 enum PathDashStyle { 5462 /** 5463 * Translates only, not rotating with the path. 5464 * @syscap SystemCapability.Graphics.Drawing 5465 * @since 18 5466 */ 5467 /** 5468 * Translates only, not rotating with the path. 5469 * @syscap SystemCapability.Graphics.Drawing 5470 * @crossplatform 5471 * @since 20 5472 */ 5473 TRANSLATE = 0, 5474 /** 5475 * Rotates with the path. 5476 * @syscap SystemCapability.Graphics.Drawing 5477 * @since 18 5478 */ 5479 /** 5480 * Rotates with the path. 5481 * @syscap SystemCapability.Graphics.Drawing 5482 * @crossplatform 5483 * @since 20 5484 */ 5485 ROTATE = 1, 5486 /** 5487 * Rotates with the path and stretches or compresses at turns to enhance smoothness. 5488 * @syscap SystemCapability.Graphics.Drawing 5489 * @since 18 5490 */ 5491 /** 5492 * Rotates with the path and stretches or compresses at turns to enhance smoothness. 5493 * @syscap SystemCapability.Graphics.Drawing 5494 * @crossplatform 5495 * @since 20 5496 */ 5497 MORPH = 2, 5498 } 5499 5500 /** 5501 * Implements a path effect. 5502 * @syscap SystemCapability.Graphics.Drawing 5503 * @since 12 5504 */ 5505 /** 5506 * Implements a path effect. 5507 * @syscap SystemCapability.Graphics.Drawing 5508 * @crossplatform 5509 * @since 20 5510 */ 5511 class PathEffect { 5512 /** 5513 * Creates a PathEffect object that converts a path into a dotted line. 5514 * @param { Array<number> } intervals - Array of ON and OFF lengths of dotted lines. 5515 * The number of arrays must be an even number and be greater than or equal to 2. 5516 * @param { number } phase - Offset used during drawing. The value is a floating point number. 5517 * @returns { PathEffect } PathEffect object. 5518 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5519 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5520 * @static 5521 * @syscap SystemCapability.Graphics.Drawing 5522 * @since 12 5523 */ 5524 /** 5525 * Creates a PathEffect object that converts a path into a dotted line. 5526 * @param { Array<number> } intervals - Array of ON and OFF lengths of dotted lines. 5527 * The number of arrays must be an even number and be greater than or equal to 2. 5528 * @param { number } phase - Offset used during drawing. The value is a floating point number. 5529 * @returns { PathEffect } PathEffect object. 5530 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5531 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5532 * @static 5533 * @syscap SystemCapability.Graphics.Drawing 5534 * @crossplatform 5535 * @since 20 5536 */ 5537 static createDashPathEffect(intervals: Array<number>, phase: number): PathEffect; 5538 5539 /** 5540 * Creates a path effect that transforms the sharp angle between line segments into a rounded corner with the specified radius. 5541 * @param { number } radius - Radius of the rounded corner. The value must be greater than 0. The value is a floating point number. 5542 * @returns { PathEffect } PathEffect object. 5543 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5544 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5545 * @static 5546 * @syscap SystemCapability.Graphics.Drawing 5547 * @since 12 5548 */ 5549 /** 5550 * Creates a path effect that transforms the sharp angle between line segments into a rounded corner with the specified radius. 5551 * @param { number } radius - Radius of the rounded corner. The value must be greater than 0. The value is a floating point number. 5552 * @returns { PathEffect } PathEffect object. 5553 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5554 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5555 * @static 5556 * @syscap SystemCapability.Graphics.Drawing 5557 * @crossplatform 5558 * @since 20 5559 */ 5560 static createCornerPathEffect(radius: number): PathEffect; 5561 5562 /** 5563 * Creates an effect that segments the path and scatters the segments in an irregular pattern along the path. 5564 * @param { number } segLength - Distance along the path at which each segment is fragmented. The value is a floating point number. 5565 * If a negative number or the value 0 is passed in, no effect is created. 5566 * @param { number } dev - Maximum amount by which the end points of the segments can be randomly displaced during rendering. 5567 * The value is a floating-point number. 5568 * @param { number } seedAssist - Optional parameter to assist in generating a pseudo-random seed for the effect. 5569 * The default value is 0, and the value is a 32-bit unsigned integer. 5570 * @returns { PathEffect } PathEffect object. 5571 * @static 5572 * @syscap SystemCapability.Graphics.Drawing 5573 * @since 18 5574 */ 5575 /** 5576 * Creates an effect that segments the path and scatters the segments in an irregular pattern along the path. 5577 * @param { number } segLength - Distance along the path at which each segment is fragmented. The value is a floating point number. 5578 * If a negative number or the value 0 is passed in, no effect is created. 5579 * @param { number } dev - Maximum amount by which the end points of the segments can be randomly displaced during rendering. 5580 * The value is a floating-point number. 5581 * @param { number } seedAssist - Optional parameter to assist in generating a pseudo-random seed for the effect. 5582 * The default value is 0, and the value is a 32-bit unsigned integer. 5583 * @returns { PathEffect } PathEffect object. 5584 * @static 5585 * @syscap SystemCapability.Graphics.Drawing 5586 * @crossplatform 5587 * @since 20 5588 */ 5589 static createDiscretePathEffect(segLength: number, dev: number, seedAssist?: number): PathEffect; 5590 5591 /** 5592 * Creates a path effect by sequentially applying the inner effect and then the outer effect. 5593 * @param { PathEffect } outer - Path effect that is applied second, overlaying the first effect. 5594 * @param { PathEffect } inner - Inner path effect that is applied first. 5595 * @returns { PathEffect } PathEffect object. 5596 * @static 5597 * @syscap SystemCapability.Graphics.Drawing 5598 * @since 18 5599 */ 5600 /** 5601 * Creates a path effect by sequentially applying the inner effect and then the outer effect. 5602 * @param { PathEffect } outer - Path effect that is applied second, overlaying the first effect. 5603 * @param { PathEffect } inner - Inner path effect that is applied first. 5604 * @returns { PathEffect } PathEffect object. 5605 * @static 5606 * @syscap SystemCapability.Graphics.Drawing 5607 * @crossplatform 5608 * @since 20 5609 */ 5610 static createComposePathEffect(outer: PathEffect, inner: PathEffect): PathEffect; 5611 5612 /** 5613 * Creates a dashed path effect based on the shape described by a path. 5614 * @param { Path } path - Path that defines the shape to be used for filling each dash in the pattern. 5615 * @param { number } advance - Distance between two consecutive dashes. The value is a floating point number greater than 0. 5616 * Otherwise, an error code is thrown. 5617 * @param { number } phase - Starting offset of the dash pattern. The value is a floating point number. 5618 * The actual offset used is the absolute value of this value modulo the value of advance. 5619 * @param { PathDashStyle } style - Style of the dashed path effect. 5620 * @returns { PathEffect } PathEffect object. 5621 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5622 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5623 * @static 5624 * @syscap SystemCapability.Graphics.Drawing 5625 * @since 18 5626 */ 5627 /** 5628 * Creates a dashed path effect based on the shape described by a path. 5629 * @param { Path } path - Path that defines the shape to be used for filling each dash in the pattern. 5630 * @param { number } advance - Distance between two consecutive dashes. The value is a floating point number greater than 0. 5631 * Otherwise, an error code is thrown. 5632 * @param { number } phase - Starting offset of the dash pattern. The value is a floating point number. 5633 * The actual offset used is the absolute value of this value modulo the value of advance. 5634 * @param { PathDashStyle } style - Style of the dashed path effect. 5635 * @returns { PathEffect } PathEffect object. 5636 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5637 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5638 * @static 5639 * @syscap SystemCapability.Graphics.Drawing 5640 * @crossplatform 5641 * @since 20 5642 */ 5643 static createPathDashEffect(path: Path, advance: number, phase: number, style: PathDashStyle): PathEffect; 5644 5645 /** 5646 * Creates an overlay path effect based on two distinct path effects. 5647 * Different from createComposePathEffect, this API applies each effect separately and then displays them as a simple overlay. 5648 * @param { PathEffect } firstPathEffect - First path effect. 5649 * @param { PathEffect } secondPathEffect - Second path effect. 5650 * @returns { PathEffect } PathEffect object. 5651 * @static 5652 * @syscap SystemCapability.Graphics.Drawing 5653 * @since 18 5654 */ 5655 /** 5656 * Creates an overlay path effect based on two distinct path effects. 5657 * Different from createComposePathEffect, this API applies each effect separately and then displays them as a simple overlay. 5658 * @param { PathEffect } firstPathEffect - First path effect. 5659 * @param { PathEffect } secondPathEffect - Second path effect. 5660 * @returns { PathEffect } PathEffect object. 5661 * @static 5662 * @syscap SystemCapability.Graphics.Drawing 5663 * @crossplatform 5664 * @since 20 5665 */ 5666 static createSumPathEffect(firstPathEffect: PathEffect, secondPathEffect: PathEffect): PathEffect; 5667 } 5668 5669 /** 5670 * Implements the shader effect. After a shader effect is set for a pen or brush, 5671 * the shader effect instead of the color attribute is used for drawing. In this case, 5672 * the alpha value set for the pen or brush still takes effect. 5673 * @syscap SystemCapability.Graphics.Drawing 5674 * @since 12 5675 */ 5676 /** 5677 * Implements the shader effect. After a shader effect is set for a pen or brush, 5678 * the shader effect instead of the color attribute is used for drawing. In this case, 5679 * the alpha value set for the pen or brush still takes effect. 5680 * @syscap SystemCapability.Graphics.Drawing 5681 * @crossplatform 5682 * @since 20 5683 */ 5684 class ShaderEffect { 5685 /** 5686 * Creates a ShaderEffect object with a single color. 5687 * @param { number } color - Color in the ARGB format. The value is a 32-bit unsigned integer. 5688 * @returns { ShaderEffect } Returns the shader with single color ShaderEffect object. 5689 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5690 * <br>2. Incorrect parameter types. 5691 * @syscap SystemCapability.Graphics.Drawing 5692 * @since 12 5693 */ 5694 /** 5695 * Creates a ShaderEffect object with a single color. 5696 * @param { number } color - Color in the ARGB format. The value is a 32-bit unsigned integer. 5697 * @returns { ShaderEffect } Returns the shader with single color ShaderEffect object. 5698 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5699 * <br>2. Incorrect parameter types. 5700 * @syscap SystemCapability.Graphics.Drawing 5701 * @crossplatform 5702 * @since 20 5703 */ 5704 static createColorShader(color: number): ShaderEffect; 5705 5706 /** 5707 * Creates a ShaderEffect object that generates a linear gradient between two points. 5708 * @param { common2D.Point } startPt - Start point. 5709 * @param { common2D.Point } endPt - End point. 5710 * @param { Array<number> } colors - Array of colors to distribute between the two points. 5711 * The values in the array are 32-bit (ARGB) unsigned integers. 5712 * @param { TileMode } mode - Tile mode of the shader effect. 5713 * @param { Array<number> | null } pos - Relative position of each color in the color array. 5714 * The array length must be the same as that of colors. The first element in the array must be 0.0, 5715 * the last element must be 1.0, and the middle elements must be between 0.0 and 1.0 and increase by index. 5716 * The default value is null, indicating that colors are evenly distributed between the two points. 5717 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5718 * The default value is null, indicating the identity matrix. 5719 * @returns { ShaderEffect } Returns a linear gradient ShaderEffect object. 5720 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5721 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5722 * @syscap SystemCapability.Graphics.Drawing 5723 * @since 12 5724 */ 5725 /** 5726 * Creates a ShaderEffect object that generates a linear gradient between two points. 5727 * @param { common2D.Point } startPt - Start point. 5728 * @param { common2D.Point } endPt - End point. 5729 * @param { Array<number> } colors - Array of colors to distribute between the two points. 5730 * The values in the array are 32-bit (ARGB) unsigned integers. 5731 * @param { TileMode } mode - Tile mode of the shader effect. 5732 * @param { Array<number> | null } pos - Relative position of each color in the color array. 5733 * The array length must be the same as that of colors. The first element in the array must be 0.0, 5734 * the last element must be 1.0, and the middle elements must be between 0.0 and 1.0 and increase by index. 5735 * The default value is null, indicating that colors are evenly distributed between the two points. 5736 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5737 * The default value is null, indicating the identity matrix. 5738 * @returns { ShaderEffect } Returns a linear gradient ShaderEffect object. 5739 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5740 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5741 * @syscap SystemCapability.Graphics.Drawing 5742 * @crossplatform 5743 * @since 20 5744 */ 5745 static createLinearGradient(startPt: common2D.Point, endPt: common2D.Point, colors: Array<number>, 5746 mode: TileMode, pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 5747 5748 /** 5749 * Creates a ShaderEffect object that generates a radial gradient based on the center and radius of a circle. 5750 * A radial gradient refers to the color transition that spreads out gradually from the center of a circle. 5751 * @param { common2D.Point } centerPt - Center of the circle. 5752 * @param { number } radius - Radius of the gradient. A negative number is invalid. The value is a floating point number. 5753 * @param { Array<number> } colors - Array of colors to distribute between the center and ending shape of the circle. 5754 * The values in the array are 32-bit (ARGB) unsigned integers. 5755 * @param { TileMode } mode - Tile mode of the shader effect. 5756 * @param { Array<number> | null } pos - Relative position of each color in the color array. 5757 * The array length must be the same as that of colors. The first element in the array must be 0.0, the last element must be 1.0, 5758 * and the middle elements must be between 0.0 and 1.0 and increase by index. 5759 * The default value is null, indicating that colors are evenly distributed between the center and ending shape of the circle. 5760 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5761 * The default value is null, indicating the identity matrix. 5762 * @returns { ShaderEffect } Returns a radial gradient ShaderEffect object. 5763 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5764 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5765 * @syscap SystemCapability.Graphics.Drawing 5766 * @since 12 5767 */ 5768 /** 5769 * Creates a ShaderEffect object that generates a radial gradient based on the center and radius of a circle. 5770 * A radial gradient refers to the color transition that spreads out gradually from the center of a circle. 5771 * @param { common2D.Point } centerPt - Center of the circle. 5772 * @param { number } radius - Radius of the gradient. A negative number is invalid. The value is a floating point number. 5773 * @param { Array<number> } colors - Array of colors to distribute between the center and ending shape of the circle. 5774 * The values in the array are 32-bit (ARGB) unsigned integers. 5775 * @param { TileMode } mode - Tile mode of the shader effect. 5776 * @param { Array<number> | null } pos - Relative position of each color in the color array. 5777 * The array length must be the same as that of colors. The first element in the array must be 0.0, the last element must be 1.0, 5778 * and the middle elements must be between 0.0 and 1.0 and increase by index. 5779 * The default value is null, indicating that colors are evenly distributed between the center and ending shape of the circle. 5780 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5781 * The default value is null, indicating the identity matrix. 5782 * @returns { ShaderEffect } Returns a radial gradient ShaderEffect object. 5783 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5784 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5785 * @syscap SystemCapability.Graphics.Drawing 5786 * @crossplatform 5787 * @since 20 5788 */ 5789 static createRadialGradient(centerPt: common2D.Point, radius: number, colors: Array<number>, 5790 mode: TileMode, pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 5791 5792 /** 5793 * Creates a ShaderEffect object that generates a color sweep gradient around a given center point, 5794 * either in a clockwise or counterclockwise direction. 5795 * @param { common2D.Point } centerPt - Center of the circle. 5796 * @param { Array<number> } colors - Array of colors to distribute between the start angle and end angle. 5797 * The values in the array are 32-bit (ARGB) unsigned integers. 5798 * @param { TileMode } mode - Tile mode of the shader effect. 5799 * @param { number } startAngle - Start angle of the sweep gradient, in degrees. 5800 * The value 0 indicates the positive direction of the X axis. A positive number indicates an offset towards the positive direction, 5801 * and a negative number indicates an offset towards the negative direction. The value is a floating point number. 5802 * @param { number } endAngle - End angle of the sweep gradient, in degrees. 5803 * The value 0 indicates the positive direction of the X axis. A positive number indicates an offset towards the positive direction, 5804 * and a negative number indicates an offset towards the negative direction. A value less than the start angle is invalid. 5805 * The value is a floating point number. 5806 * @param { Array<number> | null } pos - Relative position of each color in the color array. The array length must be the same as that of colors. 5807 * The first element in the array must be 0.0, the last element must be 1.0, and the middle elements must be between 0.0 and 1.0 and increase by index. 5808 * The default value is null, indicating that the colors are evenly distributed between the start angle and end angle. 5809 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5810 * The default value is null, indicating the identity matrix. 5811 * @returns { ShaderEffect } Returns a sweep gradient ShaderEffect object. 5812 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5813 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5814 * @syscap SystemCapability.Graphics.Drawing 5815 * @since 12 5816 */ 5817 /** 5818 * Creates a ShaderEffect object that generates a color sweep gradient around a given center point, 5819 * either in a clockwise or counterclockwise direction. 5820 * @param { common2D.Point } centerPt - Center of the circle. 5821 * @param { Array<number> } colors - Array of colors to distribute between the start angle and end angle. 5822 * The values in the array are 32-bit (ARGB) unsigned integers. 5823 * @param { TileMode } mode - Tile mode of the shader effect. 5824 * @param { number } startAngle - Start angle of the sweep gradient, in degrees. 5825 * The value 0 indicates the positive direction of the X axis. A positive number indicates an offset towards the positive direction, 5826 * and a negative number indicates an offset towards the negative direction. The value is a floating point number. 5827 * @param { number } endAngle - End angle of the sweep gradient, in degrees. 5828 * The value 0 indicates the positive direction of the X axis. A positive number indicates an offset towards the positive direction, 5829 * and a negative number indicates an offset towards the negative direction. A value less than the start angle is invalid. 5830 * The value is a floating point number. 5831 * @param { Array<number> | null } pos - Relative position of each color in the color array. The array length must be the same as that of colors. 5832 * The first element in the array must be 0.0, the last element must be 1.0, and the middle elements must be between 0.0 and 1.0 and increase by index. 5833 * The default value is null, indicating that the colors are evenly distributed between the start angle and end angle. 5834 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5835 * The default value is null, indicating the identity matrix. 5836 * @returns { ShaderEffect } Returns a sweep gradient ShaderEffect object. 5837 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5838 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5839 * @syscap SystemCapability.Graphics.Drawing 5840 * @crossplatform 5841 * @since 20 5842 */ 5843 static createSweepGradient(centerPt: common2D.Point, colors: Array<number>, 5844 mode: TileMode, startAngle: number, endAngle: number, pos?: Array<number> | null, 5845 matrix?: Matrix | null): ShaderEffect; 5846 5847 /** 5848 * Creates a ShaderEffect object that generates a conical gradient between two given circles. 5849 * @param { common2D.Point } startPt - Center of the start circle of the gradient. 5850 * @param { number } startRadius - Radius of the start circle of the gradient. A negative number is invalid. 5851 * The value is a floating point number. 5852 * @param { common2D.Point } endPt - Center of the end circle of the gradient. 5853 * @param { number } endRadius - Radius of the end circle of the gradient. A negative value is invalid. 5854 * The value is a floating point number. 5855 * @param { Array<number> } colors - Array of colors to distribute between the start circle and end circle. 5856 * The values in the array are 32-bit (ARGB) unsigned integers. 5857 * @param { TileMode } mode - Tile mode of the shader effect. 5858 * @param { Array<number> | null } pos - Relative position of each color in the color array. The array length must be the same as that of colors. 5859 * The first element in the array must be 0.0, the last element must be 1.0, and the middle elements must be between 0.0 and 1.0 and increase by index. 5860 * The default value is null, indicating that colors are evenly distributed between the two circles. 5861 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5862 * The default value is null, indicating the identity matrix. 5863 * @returns { ShaderEffect } Returns a conical gradient ShaderEffect object. 5864 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5865 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5866 * @syscap SystemCapability.Graphics.Drawing 5867 * @since 12 5868 */ 5869 /** 5870 * Creates a ShaderEffect object that generates a conical gradient between two given circles. 5871 * @param { common2D.Point } startPt - Center of the start circle of the gradient. 5872 * @param { number } startRadius - Radius of the start circle of the gradient. A negative number is invalid. 5873 * The value is a floating point number. 5874 * @param { common2D.Point } endPt - Center of the end circle of the gradient. 5875 * @param { number } endRadius - Radius of the end circle of the gradient. A negative value is invalid. 5876 * The value is a floating point number. 5877 * @param { Array<number> } colors - Array of colors to distribute between the start circle and end circle. 5878 * The values in the array are 32-bit (ARGB) unsigned integers. 5879 * @param { TileMode } mode - Tile mode of the shader effect. 5880 * @param { Array<number> | null } pos - Relative position of each color in the color array. The array length must be the same as that of colors. 5881 * The first element in the array must be 0.0, the last element must be 1.0, and the middle elements must be between 0.0 and 1.0 and increase by index. 5882 * The default value is null, indicating that colors are evenly distributed between the two circles. 5883 * @param { Matrix | null } matrix - Matrix object used to perform matrix transformation on the shader effect. 5884 * The default value is null, indicating the identity matrix. 5885 * @returns { ShaderEffect } Returns a conical gradient ShaderEffect object. 5886 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 5887 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5888 * @syscap SystemCapability.Graphics.Drawing 5889 * @crossplatform 5890 * @since 20 5891 */ 5892 static createConicalGradient(startPt: common2D.Point, startRadius: number, endPt: common2D.Point, 5893 endRadius: number, colors: Array<number>, mode: TileMode, 5894 pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 5895 5896 /** 5897 * Creates an ShaderEffect object that generates a shader with single image. 5898 * @param { image.PixelMap } pixelmap - PixelMap. 5899 * @param { TileMode } tileX - Indicates the type of tile mode for horizontal shader effect. 5900 * @param { TileMode } tileY - Indicates the type of tile mode for vertical shader effect. 5901 * @param { SamplingOptions } samplingOptions - SamplingOptions used to describe the sampling mode. 5902 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 5903 * @returns { ShaderEffect } Returns the shader with single image ShaderEffect object. 5904 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 5905 * @static 5906 * @syscap SystemCapability.Graphics.Drawing 5907 * @crossplatform 5908 * @since 20 5909 */ 5910 static createImageShader(pixelmap: image.PixelMap, tileX: TileMode, tileY: TileMode, 5911 samplingOptions: SamplingOptions, matrix?: Matrix | null): ShaderEffect; 5912 5913 /** 5914 * Creates an ShaderEffect object that generates a blend ShaderEffect object by two shaders. 5915 * @param { ShaderEffect } dstShaderEffect - Indicates a destination ShaderEffect pointer. 5916 * @param { ShaderEffect } srcShaderEffect - Indicates a source ShaderEffect pointer. 5917 * @param { BlendMode } blendMode - BlendMode. 5918 * @returns { ShaderEffect } Returns a blend ShaderEffect object. 5919 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 5920 * @static 5921 * @syscap SystemCapability.Graphics.Drawing 5922 * @crossplatform 5923 * @since 20 5924 */ 5925 static createComposeShader(dstShaderEffect: ShaderEffect, srcShaderEffect: ShaderEffect, 5926 blendMode: BlendMode): ShaderEffect; 5927 } 5928 5929 /** 5930 * Enumerates the tile modes of the shader effect. 5931 * @enum { number } 5932 * @syscap SystemCapability.Graphics.Drawing 5933 * @since 12 5934 */ 5935 /** 5936 * Enumerates the tile modes of the shader effect. 5937 * @enum { number } 5938 * @syscap SystemCapability.Graphics.Drawing 5939 * @crossplatform 5940 * @since 20 5941 */ 5942 enum TileMode { 5943 /** 5944 * Replicates the edge color if the shader effect draws outside of its original boundary. 5945 * @syscap SystemCapability.Graphics.Drawing 5946 * @since 12 5947 */ 5948 /** 5949 * Replicates the edge color if the shader effect draws outside of its original boundary. 5950 * @syscap SystemCapability.Graphics.Drawing 5951 * @crossplatform 5952 * @since 20 5953 */ 5954 CLAMP = 0, 5955 5956 /** 5957 * Repeats the shader effect in both horizontal and vertical directions. 5958 * @syscap SystemCapability.Graphics.Drawing 5959 * @since 12 5960 */ 5961 /** 5962 * Repeats the shader effect in both horizontal and vertical directions. 5963 * @syscap SystemCapability.Graphics.Drawing 5964 * @crossplatform 5965 * @since 20 5966 */ 5967 REPEAT = 1, 5968 5969 /** 5970 * Repeats the shader effect in both horizontal and vertical directions, alternating mirror images. 5971 * @syscap SystemCapability.Graphics.Drawing 5972 * @since 12 5973 */ 5974 /** 5975 * Repeats the shader effect in both horizontal and vertical directions, alternating mirror images. 5976 * @syscap SystemCapability.Graphics.Drawing 5977 * @crossplatform 5978 * @since 20 5979 */ 5980 MIRROR = 2, 5981 5982 /** 5983 * Renders the shader effect only within the original boundary. 5984 * @syscap SystemCapability.Graphics.Drawing 5985 * @since 12 5986 */ 5987 /** 5988 * Renders the shader effect only within the original boundary. 5989 * @syscap SystemCapability.Graphics.Drawing 5990 * @crossplatform 5991 * @since 20 5992 */ 5993 DECAL = 3, 5994 } 5995 5996 /** 5997 * Implements a shadow layer. 5998 * @syscap SystemCapability.Graphics.Drawing 5999 * @since 12 6000 */ 6001 /** 6002 * Implements a shadow layer. 6003 * @syscap SystemCapability.Graphics.Drawing 6004 * @crossplatform 6005 * @since 20 6006 */ 6007 class ShadowLayer { 6008 /** 6009 * Creates a ShadowLayer object. 6010 * 6011 * @param { number } blurRadius - Radius of the shadow layer. The value must be a floating point number greater than 0. 6012 * @param { number } x - Offset on the X axis. The value is a floating point number. 6013 * @param { number } y - Offset on the Y axis. The value is a floating point number. 6014 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 6015 * @returns { ShadowLayer } ShadowLayer object. 6016 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6017 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6018 * @static 6019 * @syscap SystemCapability.Graphics.Drawing 6020 * @since 12 6021 */ 6022 /** 6023 * Creates a ShadowLayer object. 6024 * 6025 * @param { number } blurRadius - Radius of the shadow layer. The value must be a floating point number greater than 0. 6026 * @param { number } x - Offset on the X axis. The value is a floating point number. 6027 * @param { number } y - Offset on the Y axis. The value is a floating point number. 6028 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 6029 * @returns { ShadowLayer } ShadowLayer object. 6030 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6031 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6032 * @static 6033 * @syscap SystemCapability.Graphics.Drawing 6034 * @crossplatform 6035 * @since 20 6036 */ 6037 static create(blurRadius: number, x: number, y: number, color: common2D.Color): ShadowLayer; 6038 6039 /** 6040 * Creates a ShadowLayer object. 6041 * 6042 * @param { number } blurRadius - Radius of the shadow layer. The value must be a floating point number greater than 0. 6043 * @param { number } x - Offset on the X axis. The value is a floating point number. 6044 * @param { number } y - Offset on the Y axis. The value is a floating point number. 6045 * @param { common2D.Color | number } color - Color, represented by an unsigned integer in hexadecimal ARGB format. 6046 * @returns { ShadowLayer } ShadowLayer object. 6047 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6048 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6049 * @static 6050 * @syscap SystemCapability.Graphics.Drawing 6051 * @since 18 6052 */ 6053 /** 6054 * Creates a ShadowLayer object. 6055 * 6056 * @param { number } blurRadius - Radius of the shadow layer. The value must be a floating point number greater than 0. 6057 * @param { number } x - Offset on the X axis. The value is a floating point number. 6058 * @param { number } y - Offset on the Y axis. The value is a floating point number. 6059 * @param { common2D.Color | number } color - Color, represented by an unsigned integer in hexadecimal ARGB format. 6060 * @returns { ShadowLayer } ShadowLayer object. 6061 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6062 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6063 * @static 6064 * @syscap SystemCapability.Graphics.Drawing 6065 * @crossplatform 6066 * @since 20 6067 */ 6068 static create(blurRadius: number, x: number, y: number, color: common2D.Color | number): ShadowLayer; 6069 } 6070 6071 /** 6072 * Defines a color filter. 6073 * 6074 * @syscap SystemCapability.Graphics.Drawing 6075 * @since 11 6076 */ 6077 /** 6078 * Defines a color filter. 6079 * 6080 * @syscap SystemCapability.Graphics.Drawing 6081 * @crossplatform 6082 * @since 20 6083 * @arkts 1.1&1.2 6084 */ 6085 class ColorFilter { 6086 /** 6087 * Creates a ColorFilter object with a given color and blend mode. 6088 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 6089 * @param { BlendMode } mode - Blend mode. 6090 * @returns { ColorFilter } Colorfilter object. 6091 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6092 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6093 * @static 6094 * @syscap SystemCapability.Graphics.Drawing 6095 * @since 11 6096 */ 6097 /** 6098 * Creates a ColorFilter object with a given color and blend mode. 6099 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 6100 * @param { BlendMode } mode - Blend mode. 6101 * @returns { ColorFilter } Colorfilter object. 6102 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6103 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6104 * @static 6105 * @syscap SystemCapability.Graphics.Drawing 6106 * @crossplatform 6107 * @since 20 6108 * @arkts 1.1&1.2 6109 */ 6110 static createBlendModeColorFilter(color: common2D.Color, mode: BlendMode): ColorFilter; 6111 6112 /** 6113 * Creates a ColorFilter object with a given color and blend mode. 6114 * @param { common2D.Color | number } color - Color, represented by an unsigned integer in hexadecimal ARGB format. 6115 * @param { BlendMode } mode - Blend mode. 6116 * @returns { ColorFilter } Colorfilter object. 6117 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6118 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6119 * @static 6120 * @syscap SystemCapability.Graphics.Drawing 6121 * @since 18 6122 */ 6123 /** 6124 * Creates a ColorFilter object with a given color and blend mode. 6125 * @param { common2D.Color | number } color - Color, represented by an unsigned integer in hexadecimal ARGB format. 6126 * @param { BlendMode } mode - Blend mode. 6127 * @returns { ColorFilter } Colorfilter object. 6128 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6129 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6130 * @static 6131 * @syscap SystemCapability.Graphics.Drawing 6132 * @crossplatform 6133 * @since 20 6134 * @arkts 1.1&1.2 6135 */ 6136 static createBlendModeColorFilter(color: common2D.Color | number, mode: BlendMode): ColorFilter; 6137 6138 /** 6139 * Creates a ColorFilter object by combining another two color filters. 6140 * @param { ColorFilter } outer - Color filter that takes effect later in the new filter. 6141 * @param { ColorFilter } inner - Color filter that takes effect first in the new filter. 6142 * @returns { ColorFilter } Colorfilter object. 6143 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6144 * <br>2. Incorrect parameter types. 6145 * @static 6146 * @syscap SystemCapability.Graphics.Drawing 6147 * @since 11 6148 */ 6149 /** 6150 * Creates a ColorFilter object by combining another two color filters. 6151 * @param { ColorFilter } outer - Color filter that takes effect later in the new filter. 6152 * @param { ColorFilter } inner - Color filter that takes effect first in the new filter. 6153 * @returns { ColorFilter } Colorfilter object. 6154 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6155 * <br>2. Incorrect parameter types. 6156 * @static 6157 * @syscap SystemCapability.Graphics.Drawing 6158 * @crossplatform 6159 * @since 20 6160 */ 6161 static createComposeColorFilter(outer: ColorFilter, inner: ColorFilter): ColorFilter; 6162 6163 /** 6164 * Creates a ColorFilter object that applies the sRGB gamma curve to the RGB channels. 6165 * @returns { ColorFilter } Colorfilter object. 6166 * @static 6167 * @syscap SystemCapability.Graphics.Drawing 6168 * @since 11 6169 */ 6170 /** 6171 * Creates a ColorFilter object that applies the sRGB gamma curve to the RGB channels. 6172 * @returns { ColorFilter } Colorfilter object. 6173 * @static 6174 * @syscap SystemCapability.Graphics.Drawing 6175 * @crossplatform 6176 * @since 20 6177 */ 6178 static createLinearToSRGBGamma(): ColorFilter; 6179 6180 /** 6181 * Creates a ColorFilter object that applies the RGB channels to the sRGB gamma curve. 6182 * @returns { ColorFilter } Colorfilter object. 6183 * @static 6184 * @syscap SystemCapability.Graphics.Drawing 6185 * @since 11 6186 */ 6187 /** 6188 * Creates a ColorFilter object that applies the RGB channels to the sRGB gamma curve. 6189 * @returns { ColorFilter } Colorfilter object. 6190 * @static 6191 * @syscap SystemCapability.Graphics.Drawing 6192 * @crossplatform 6193 * @since 20 6194 */ 6195 static createSRGBGammaToLinear(): ColorFilter; 6196 6197 /** 6198 * Creates a ColorFilter object that multiplies the luma into the alpha channel and sets the RGB channels to zero. 6199 * @returns { ColorFilter } Colorfilter. 6200 * @static 6201 * @syscap SystemCapability.Graphics.Drawing 6202 * @since 11 6203 */ 6204 /** 6205 * Creates a ColorFilter object that multiplies the luma into the alpha channel and sets the RGB channels to zero. 6206 * @returns { ColorFilter } Colorfilter. 6207 * @static 6208 * @syscap SystemCapability.Graphics.Drawing 6209 * @crossplatform 6210 * @since 20 6211 */ 6212 static createLumaColorFilter(): ColorFilter; 6213 /** 6214 * Creates a color filter object with a 4*5 color matrix. 6215 * @param { Array<number> } matrix - An array of 20 numbers, indicating the 4*5 matrix. 6216 * @returns { ColorFilter } Colorfilter object. 6217 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6218 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6219 * @static 6220 * @syscap SystemCapability.Graphics.Drawing 6221 * @since 12 6222 */ 6223 /** 6224 * Creates a color filter object with a 4*5 color matrix. 6225 * @param { Array<number> } matrix - An array of 20 numbers, indicating the 4*5 matrix. 6226 * @returns { ColorFilter } Colorfilter object. 6227 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6228 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6229 * @static 6230 * @syscap SystemCapability.Graphics.Drawing 6231 * @crossplatform 6232 * @since 20 6233 */ 6234 static createMatrixColorFilter(matrix: Array<number>): ColorFilter; 6235 6236 /** 6237 * Makes a color filter with the given mutColor and addColor. 6238 * @param { common2D.Color | number } mutColor - The range of color channels must be [0, 255], used to multiply source color. 6239 * @param { common2D.Color | number } addColor - The range of color channels must be [0, 255], used to add to source color. 6240 * @returns { ColorFilter } Colorfilter object. 6241 * @static 6242 * @syscap SystemCapability.Graphics.Drawing 6243 * @crossplatform 6244 * @since 20 6245 */ 6246 static createLightingColorFilter(mutColor: common2D.Color | number, addColor: common2D.Color | number): ColorFilter; 6247 6248 } 6249 6250 /** 6251 * Implements an image filter. 6252 * 6253 * @syscap SystemCapability.Graphics.Drawing 6254 * @since 12 6255 */ 6256 /** 6257 * Implements an image filter. 6258 * 6259 * @syscap SystemCapability.Graphics.Drawing 6260 * @crossplatform 6261 * @since 20 6262 */ 6263 class ImageFilter { 6264 /** 6265 * Creates an image filter with a given blur effect. 6266 * @param { number } sigmaX - Standard deviation of the Gaussian blur along the X axis. The value must be a floating point number greater than 0. 6267 * @param { number } sigmaY - Standard deviation of the Gaussian blur along the Y axis. The value must be a floating point number greater than 0. 6268 * @param { TileMode } tileMode - Tile mode to apply to the edges. 6269 * @param { ImageFilter | null } imageFilter - Filter to which the image filter will be applied. 6270 * The default value is null, indicating that the image filter is directly applied to the original image. 6271 * @returns { ImageFilter } ImageFilter object. 6272 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6273 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6274 * @static 6275 * @syscap SystemCapability.Graphics.Drawing 6276 * @since 12 6277 */ 6278 /** 6279 * Creates an image filter with a given blur effect. 6280 * @param { number } sigmaX - Standard deviation of the Gaussian blur along the X axis. The value must be a floating point number greater than 0. 6281 * @param { number } sigmaY - Standard deviation of the Gaussian blur along the Y axis. The value must be a floating point number greater than 0. 6282 * @param { TileMode } tileMode - Tile mode to apply to the edges. 6283 * @param { ImageFilter | null } imageFilter - Filter to which the image filter will be applied. 6284 * The default value is null, indicating that the image filter is directly applied to the original image. 6285 * @returns { ImageFilter } ImageFilter object. 6286 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6287 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6288 * @static 6289 * @syscap SystemCapability.Graphics.Drawing 6290 * @crossplatform 6291 * @since 20 6292 */ 6293 static createBlurImageFilter(sigmaX: number, sigmaY: number, 6294 tileMode: TileMode, imageFilter?: ImageFilter | null): ImageFilter; 6295 /** 6296 * Creates an image filter object with a given color filter effect. 6297 * @param { ColorFilter } colorFilter - Color filter. 6298 * @param { ImageFilter | null } imageFilter - Filter to which the image filter will be applied. The default value is null, 6299 * indicating that the image filter is directly applied to the original image. 6300 * @returns { ImageFilter } ImageFilter object. 6301 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6302 * <br>2. Incorrect parameter types. 6303 * @static 6304 * @syscap SystemCapability.Graphics.Drawing 6305 * @since 12 6306 */ 6307 /** 6308 * Creates an image filter object with a given color filter effect. 6309 * @param { ColorFilter } colorFilter - Color filter. 6310 * @param { ImageFilter | null } imageFilter - Filter to which the image filter will be applied. The default value is null, 6311 * indicating that the image filter is directly applied to the original image. 6312 * @returns { ImageFilter } ImageFilter object. 6313 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6314 * <br>2. Incorrect parameter types. 6315 * @static 6316 * @syscap SystemCapability.Graphics.Drawing 6317 * @crossplatform 6318 * @since 20 6319 */ 6320 static createFromColorFilter(colorFilter: ColorFilter, imageFilter?: ImageFilter | null): ImageFilter; 6321 6322 /** 6323 * Makes an ImageFilter object that instance with the provided x and y offset. 6324 * @param { number } dx - Indicates the offset in the X direction. 6325 * @param { number } dy - Indicates the offset in the Y direction. 6326 * @param { ImageFilter | null } input - Indicates the input image filter used to generate offset effects, or uses 6327 * the source bitmap if this is null. 6328 * @returns { ImageFilter } ImageFilter object. 6329 * @static 6330 * @syscap SystemCapability.Graphics.Drawing 6331 * @crossplatform 6332 * @since 20 6333 */ 6334 static createOffsetImageFilter(dx: number, dy: number, input?: ImageFilter | null): ImageFilter; 6335 6336 /** 6337 * Makes an ImageFilter object that applies the bitmap to the input. 6338 * @param { image.PixelMap } pixelmap - The source input image. 6339 * @param { common2D.Rect | null } srcRect - Indicates the input srcRect, or uses the source bitmap if this is null. 6340 * @param { common2D.Rect | null } dstRect - Indicates the input dstRect, or uses the source bitmap if this is null. 6341 * @returns { ImageFilter } ImageFilter object. 6342 * @static 6343 * @syscap SystemCapability.Graphics.Drawing 6344 * @crossplatform 6345 * @since 20 6346 */ 6347 static createFromImage(pixelmap: image.PixelMap, srcRect?: common2D.Rect | null, dstRect?: common2D.Rect | null): ImageFilter; 6348 6349 /** 6350 * Makes an ImageFilter object that applies the blend to the input. 6351 * @param { BlendMode } mode - Blendmode. 6352 * @param { ImageFilter } background - Indicates the input background filter. 6353 * @param { ImageFilter } foreground - Indicates the input foreground filter. 6354 * @returns { ImageFilter } ImageFilter object. 6355 * @throws { BusinessError } 25900001 - Parameter error. Possible causes: Incorrect parameter range. 6356 * @static 6357 * @syscap SystemCapability.Graphics.Drawing 6358 * @crossplatform 6359 * @since 20 6360 */ 6361 static createBlendImageFilter(mode: BlendMode, background: ImageFilter, foreground: ImageFilter): ImageFilter; 6362 6363 /** 6364 * Makes an ImageFilter object that combines the "inner" and "outer" filters, allowing the output of the "inner" 6365 * filter to serve as the input source bitmap for the "outer" filter. 6366 * @param { ImageFilter } cOuter - Indicates the instance to apply its effects to the output of the 'inner' 6367 * filter. 6368 * @param { ImageFilter } cInner - Indicates the output as input for "outer" filters. 6369 * @returns { ImageFilter } ImageFilter object. 6370 * @static 6371 * @syscap SystemCapability.Graphics.Drawing 6372 * @crossplatform 6373 * @since 20 6374 */ 6375 static createComposeImageFilter(cOuter: ImageFilter, cInner: ImageFilter): ImageFilter; 6376 6377 /** 6378 * Makes an ImageFilter object that renders the contents of the input Shader. 6379 * 6380 * @param { ShaderEffect } shader - Indicates the shader effect to be applied to the image. 6381 * @returns { ImageFilter } ImageFilter object. 6382 * @static 6383 * @syscap SystemCapability.Graphics.Drawing 6384 * @crossplatform 6385 * @since 20 6386 */ 6387 static createFromShaderEffect(shader: ShaderEffect): ImageFilter; 6388 } 6389 /** 6390 * Enumerates the join styles of a pen. The join style defines the shape of the joints of a polyline segment drawn by the pen. 6391 * @enum { number } 6392 * @syscap SystemCapability.Graphics.Drawing 6393 * @since 12 6394 */ 6395 /** 6396 * Enumerates the join styles of a pen. The join style defines the shape of the joints of a polyline segment drawn by the pen. 6397 * @enum { number } 6398 * @syscap SystemCapability.Graphics.Drawing 6399 * @crossplatform 6400 * @since 20 6401 */ 6402 enum JoinStyle { 6403 /** 6404 * Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate. 6405 * In this case, you need to use the miter limit to limit the miter length. 6406 * @syscap SystemCapability.Graphics.Drawing 6407 * @since 12 6408 */ 6409 /** 6410 * Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate. 6411 * In this case, you need to use the miter limit to limit the miter length. 6412 * @syscap SystemCapability.Graphics.Drawing 6413 * @crossplatform 6414 * @since 20 6415 */ 6416 MITER_JOIN = 0, 6417 6418 /** 6419 * Round corner. 6420 * @syscap SystemCapability.Graphics.Drawing 6421 * @since 12 6422 */ 6423 /** 6424 * Round corner. 6425 * @syscap SystemCapability.Graphics.Drawing 6426 * @crossplatform 6427 * @since 20 6428 */ 6429 ROUND_JOIN = 1, 6430 6431 /** 6432 * Bevel corner. 6433 * @syscap SystemCapability.Graphics.Drawing 6434 * @since 12 6435 */ 6436 /** 6437 * Bevel corner. 6438 * @syscap SystemCapability.Graphics.Drawing 6439 * @crossplatform 6440 * @since 20 6441 */ 6442 BEVEL_JOIN = 2 6443 } 6444 6445 /** 6446 * Enumerates the cap styles of a pen. The cap style defines the style of both ends of a line segment drawn by the pen. 6447 * @enum { number } 6448 * @syscap SystemCapability.Graphics.Drawing 6449 * @since 12 6450 */ 6451 /** 6452 * Enumerates the cap styles of a pen. The cap style defines the style of both ends of a line segment drawn by the pen. 6453 * @enum { number } 6454 * @syscap SystemCapability.Graphics.Drawing 6455 * @crossplatform 6456 * @since 20 6457 */ 6458 enum CapStyle { 6459 /** 6460 * There is no cap style. Both ends of the line segment are cut off square. 6461 * @syscap SystemCapability.Graphics.Drawing 6462 * @since 12 6463 */ 6464 /** 6465 * There is no cap style. Both ends of the line segment are cut off square. 6466 * @syscap SystemCapability.Graphics.Drawing 6467 * @crossplatform 6468 * @since 20 6469 */ 6470 FLAT_CAP = 0, 6471 6472 /** 6473 * Square cap style. Both ends have a square, the height of which is half of the width of the line segment, with the same width. 6474 * @syscap SystemCapability.Graphics.Drawing 6475 * @since 12 6476 */ 6477 /** 6478 * Square cap style. Both ends have a square, the height of which is half of the width of the line segment, with the same width. 6479 * @syscap SystemCapability.Graphics.Drawing 6480 * @crossplatform 6481 * @since 20 6482 */ 6483 SQUARE_CAP = 1, 6484 6485 /** 6486 * Round cap style. Both ends have a semicircle centered, the diameter of which is the same as the width of the line segment. 6487 * @syscap SystemCapability.Graphics.Drawing 6488 * @since 12 6489 */ 6490 /** 6491 * Round cap style. Both ends have a semicircle centered, the diameter of which is the same as the width of the line segment. 6492 * @syscap SystemCapability.Graphics.Drawing 6493 * @crossplatform 6494 * @since 20 6495 */ 6496 ROUND_CAP = 2 6497 } 6498 6499 /** 6500 * Enumerates the blur types of a mask filter. 6501 * @enum { number } 6502 * @syscap SystemCapability.Graphics.Drawing 6503 * @since 12 6504 */ 6505 /** 6506 * Enumerates the blur types of a mask filter. 6507 * @enum { number } 6508 * @syscap SystemCapability.Graphics.Drawing 6509 * @crossplatform 6510 * @since 20 6511 */ 6512 enum BlurType { 6513 /** 6514 * Both the outer edges and the inner solid parts are blurred. 6515 * @syscap SystemCapability.Graphics.Drawing 6516 * @since 12 6517 */ 6518 /** 6519 * Both the outer edges and the inner solid parts are blurred. 6520 * @syscap SystemCapability.Graphics.Drawing 6521 * @crossplatform 6522 * @since 20 6523 */ 6524 NORMAL = 0, 6525 6526 /** 6527 * The inner solid part remains unchanged, while only the outer edges are blurred. 6528 * @syscap SystemCapability.Graphics.Drawing 6529 * @since 12 6530 */ 6531 /** 6532 * The inner solid part remains unchanged, while only the outer edges are blurred. 6533 * @syscap SystemCapability.Graphics.Drawing 6534 * @crossplatform 6535 * @since 20 6536 */ 6537 SOLID = 1, 6538 6539 /** 6540 * Only the outer edges are blurred, with the inner solid part being fully transparent. 6541 * @syscap SystemCapability.Graphics.Drawing 6542 * @since 12 6543 */ 6544 /** 6545 * Only the outer edges are blurred, with the inner solid part being fully transparent. 6546 * @syscap SystemCapability.Graphics.Drawing 6547 * @crossplatform 6548 * @since 20 6549 */ 6550 OUTER = 2, 6551 6552 /** 6553 * Only the inner solid part is blurred, while the outer edges remain sharp. 6554 * @syscap SystemCapability.Graphics.Drawing 6555 * @since 12 6556 */ 6557 /** 6558 * Only the inner solid part is blurred, while the outer edges remain sharp. 6559 * @syscap SystemCapability.Graphics.Drawing 6560 * @crossplatform 6561 * @since 20 6562 */ 6563 INNER = 3 6564 } 6565 6566 /** 6567 * Defines a pen, which is used to describe the style and color to outline a shape. 6568 * @syscap SystemCapability.Graphics.Drawing 6569 * @since 11 6570 */ 6571 /** 6572 * Defines a pen, which is used to describe the style and color to outline a shape. 6573 * @syscap SystemCapability.Graphics.Drawing 6574 * @crossplatform 6575 * @since 20 6576 * @arkts 1.1&1.2 6577 */ 6578 class Pen { 6579 /** 6580 * A constructor used to create a Pen object. 6581 * @syscap SystemCapability.Graphics.Drawing 6582 * @since 12 6583 */ 6584 /** 6585 * A constructor used to create a Pen object. 6586 * @syscap SystemCapability.Graphics.Drawing 6587 * @crossplatform 6588 * @since 20 6589 * @arkts 1.1&1.2 6590 */ 6591 constructor(); 6592 6593 /** 6594 * Copies a Pen object to create a new one. 6595 * @param { Pen } pen - Pen object to copy. 6596 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6597 * <br>2. Incorrect parameter types. 6598 * @syscap SystemCapability.Graphics.Drawing 6599 * @since 12 6600 */ 6601 /** 6602 * Copies a Pen object to create a new one. 6603 * @param { Pen } pen - Pen object to copy. 6604 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6605 * <br>2. Incorrect parameter types. 6606 * @syscap SystemCapability.Graphics.Drawing 6607 * @crossplatform 6608 * @since 20 6609 * @arkts 1.1&1.2 6610 */ 6611 constructor(pen: Pen); 6612 6613 /** 6614 * Sets the maximum ratio allowed between the sharp corner length of a polyline and its line width. 6615 * When drawing a polyline with the pen, if JoinStyle is set to MITER_JOIN and this maximum ratio is exceeded, 6616 * the corner will be displayed as beveled instead of mitered. 6617 * @param { number } miter - Maximum ratio of the sharp corner length of the polyline to the line width. 6618 * A negative number is processed as 4.0 during drawing. Non-negative numbers take effect normally. The value is a floating point number. 6619 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6620 * <br>2. Incorrect parameter types. 6621 * @syscap SystemCapability.Graphics.Drawing 6622 * @since 12 6623 */ 6624 /** 6625 * Sets the maximum ratio allowed between the sharp corner length of a polyline and its line width. 6626 * When drawing a polyline with the pen, if JoinStyle is set to MITER_JOIN and this maximum ratio is exceeded, 6627 * the corner will be displayed as beveled instead of mitered. 6628 * @param { number } miter - Maximum ratio of the sharp corner length of the polyline to the line width. 6629 * A negative number is processed as 4.0 during drawing. Non-negative numbers take effect normally. The value is a floating point number. 6630 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6631 * <br>2. Incorrect parameter types. 6632 * @syscap SystemCapability.Graphics.Drawing 6633 * @crossplatform 6634 * @since 20 6635 */ 6636 setMiterLimit(miter: number): void; 6637 6638 /** 6639 * Obtains the maximum ratio allowed between the sharp corner length of a polyline and its line width. 6640 * @returns { number } Returns the miter limit. 6641 * @syscap SystemCapability.Graphics.Drawing 6642 * @since 12 6643 */ 6644 /** 6645 * Obtains the maximum ratio allowed between the sharp corner length of a polyline and its line width. 6646 * @returns { number } Returns the miter limit. 6647 * @syscap SystemCapability.Graphics.Drawing 6648 * @crossplatform 6649 * @since 20 6650 */ 6651 getMiterLimit(): number; 6652 6653 /** 6654 * Sets the shader effect for this pen. 6655 * @param { ShaderEffect } shaderEffect - ShaderEffect object. If null is passed in, the shader effect will be cleared. 6656 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6657 * <br>2. Incorrect parameter types. 6658 * @syscap SystemCapability.Graphics.Drawing 6659 * @since 12 6660 */ 6661 /** 6662 * Sets the shader effect for this pen. 6663 * @param { ShaderEffect } shaderEffect - ShaderEffect object. If null is passed in, the shader effect will be cleared. 6664 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6665 * <br>2. Incorrect parameter types. 6666 * @syscap SystemCapability.Graphics.Drawing 6667 * @crossplatform 6668 * @since 20 6669 */ 6670 setShaderEffect(shaderEffect: ShaderEffect): void; 6671 6672 /** 6673 * Sets a color for this pen. 6674 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 6675 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6676 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6677 * @syscap SystemCapability.Graphics.Drawing 6678 * @since 11 6679 */ 6680 /** 6681 * Sets a color for this pen. 6682 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 6683 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6684 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6685 * @syscap SystemCapability.Graphics.Drawing 6686 * @crossplatform 6687 * @since 20 6688 */ 6689 setColor(color: common2D.Color): void; 6690 6691 /** 6692 * Sets a color for this pen. This API provides better performance than setColor and is recommended. 6693 * @param { number } alpha - Alpha channel value of the color in ARGB format. The value is an integer ranging from 0 to 255 6694 * Any passed-in floating point number is rounded down. 6695 * @param { number } red - Red channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 6696 * Any passed-in floating point number is rounded down. 6697 * @param { number } green - Green channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 6698 * Any passed-in floating point number is rounded down. 6699 * @param { number } blue - Blue channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 6700 * Any passed-in floating point number is rounded down. 6701 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6702 * <br>2. Incorrect parameter types. 6703 * @syscap SystemCapability.Graphics.Drawing 6704 * @since 12 6705 */ 6706 /** 6707 * Sets a color for this pen. This API provides better performance than setColor and is recommended. 6708 * @param { number } alpha - Alpha channel value of the color in ARGB format. The value is an integer ranging from 0 to 255 6709 * Any passed-in floating point number is rounded down. 6710 * @param { number } red - Red channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 6711 * Any passed-in floating point number is rounded down. 6712 * @param { number } green - Green channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 6713 * Any passed-in floating point number is rounded down. 6714 * @param { number } blue - Blue channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 6715 * Any passed-in floating point number is rounded down. 6716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6717 * <br>2. Incorrect parameter types. 6718 * @syscap SystemCapability.Graphics.Drawing 6719 * @crossplatform 6720 * @since 20 6721 */ 6722 setColor(alpha: number, red: number, green: number, blue: number): void; 6723 6724 /** 6725 * Sets a color for this pen. 6726 * @param { number } color - Color in hexadecimal ARGB format. 6727 * @syscap SystemCapability.Graphics.Drawing 6728 * @since 18 6729 */ 6730 /** 6731 * Sets a color for this pen. 6732 * @param { number } color - Color in hexadecimal ARGB format. 6733 * @syscap SystemCapability.Graphics.Drawing 6734 * @crossplatform 6735 * @since 20 6736 */ 6737 setColor(color: number): void; 6738 6739 /** 6740 * Set the color by four floating point values, unpremultiplied. The color values are interpreted as being in 6741 * the colorSpace. If colorSpace is nullptr, then color is assumed to be in the sRGB color space. 6742 * 6743 * @param { common2D.Color4f } color4f - Indicates four floating point values that describes the color. 6744 * @param { colorSpaceManager.ColorSpaceManager | null } colorSpace - Indicates colorSpaceManager. 6745 * @syscap SystemCapability.Graphics.Drawing 6746 * @crossplatform 6747 * @since 20 6748 */ 6749 setColor4f(color4f: common2D.Color4f, colorSpace: colorSpaceManager.ColorSpaceManager | null): void; 6750 6751 /** 6752 * Obtains the color of this pen. 6753 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 6754 * @syscap SystemCapability.Graphics.Drawing 6755 * @since 12 6756 */ 6757 /** 6758 * Obtains the color of this pen. 6759 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 6760 * @syscap SystemCapability.Graphics.Drawing 6761 * @crossplatform 6762 * @since 20 6763 */ 6764 getColor(): common2D.Color; 6765 6766 /** 6767 * Obtains the color of a pen. The color is used by the pen to outline a shape. 6768 * @returns { common2D.Color4f } Returns four floating point values that describes the color. 6769 * @syscap SystemCapability.Graphics.Drawing 6770 * @crossplatform 6771 * @since 20 6772 */ 6773 getColor4f(): common2D.Color4f; 6774 6775 /** 6776 * Obtains the color of this pen. 6777 * @returns { number } Returns a 32-bit (ARGB) variable that describes the color of hexadecimal format. 6778 * @syscap SystemCapability.Graphics.Drawing 6779 * @since 18 6780 */ 6781 /** 6782 * Obtains the color of this pen. 6783 * @returns { number } Returns a 32-bit (ARGB) variable that describes the color of hexadecimal format. 6784 * @syscap SystemCapability.Graphics.Drawing 6785 * @crossplatform 6786 * @since 20 6787 */ 6788 getHexColor(): number; 6789 6790 /** 6791 * Sets the stroke width for this pen. The value 0 is treated as an unusually thin width. During drawing, 6792 * the width of 0 is always drawn as 1 pixel wide, regardless of any scaling applied to the canvas. 6793 * Negative values are also regarded as the value 0 during the drawing process. 6794 * 6795 * @param { number } width - Stroke width. The value is a floating point number. 6796 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6797 * <br>2. Incorrect parameter types. 6798 * @syscap SystemCapability.Graphics.Drawing 6799 * @since 11 6800 */ 6801 /** 6802 * Sets the stroke width for this pen. The value 0 is treated as an unusually thin width. During drawing, 6803 * the width of 0 is always drawn as 1 pixel wide, regardless of any scaling applied to the canvas. 6804 * Negative values are also regarded as the value 0 during the drawing process. 6805 * 6806 * @param { number } width - Stroke width. The value is a floating point number. 6807 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6808 * <br>2. Incorrect parameter types. 6809 * @syscap SystemCapability.Graphics.Drawing 6810 * @crossplatform 6811 * @since 20 6812 */ 6813 setStrokeWidth(width: number): void; 6814 6815 /** 6816 * Obtains the stroke width of this pen. The width describes the thickness of the outline of a shape. 6817 * @returns { number } Stroke width for the pen, in px. 6818 * @syscap SystemCapability.Graphics.Drawing 6819 * @since 12 6820 */ 6821 /** 6822 * Obtains the stroke width of this pen. The width describes the thickness of the outline of a shape. 6823 * @returns { number } Stroke width for the pen, in px. 6824 * @syscap SystemCapability.Graphics.Drawing 6825 * @crossplatform 6826 * @since 20 6827 */ 6828 getWidth(): number; 6829 6830 /** 6831 * Enables anti-aliasing for this pen. Anti-aliasing makes the edges of the content smoother. 6832 * If this API is not called, anti-aliasing is disabled by default. 6833 * 6834 * @param { boolean } aa - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite. 6835 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6836 * <br>2. Incorrect parameter types. 6837 * @syscap SystemCapability.Graphics.Drawing 6838 * @since 11 6839 */ 6840 /** 6841 * Enables anti-aliasing for this pen. Anti-aliasing makes the edges of the content smoother. 6842 * If this API is not called, anti-aliasing is disabled by default. 6843 * 6844 * @param { boolean } aa - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite. 6845 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6846 * <br>2. Incorrect parameter types. 6847 * @syscap SystemCapability.Graphics.Drawing 6848 * @crossplatform 6849 * @since 20 6850 */ 6851 setAntiAlias(aa: boolean): void; 6852 6853 /** 6854 * Checks whether anti-aliasing is enabled for this pen. 6855 * @returns { boolean } Returns true if the anti-aliasing is enabled; returns false otherwise. 6856 * @syscap SystemCapability.Graphics.Drawing 6857 * @since 12 6858 */ 6859 /** 6860 * Checks whether anti-aliasing is enabled for this pen. 6861 * @returns { boolean } Returns true if the anti-aliasing is enabled; returns false otherwise. 6862 * @syscap SystemCapability.Graphics.Drawing 6863 * @crossplatform 6864 * @since 20 6865 */ 6866 isAntiAlias(): boolean; 6867 6868 /** 6869 * Sets an alpha value for this pen. 6870 * 6871 * @param { number } alpha - Alpha value. The value is an integer in the range [0, 255]. If a floating point number is passed in, the value is rounded down. 6872 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6873 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6874 * @syscap SystemCapability.Graphics.Drawing 6875 * @since 11 6876 */ 6877 /** 6878 * Sets an alpha value for this pen. 6879 * 6880 * @param { number } alpha - Alpha value. The value is an integer in the range [0, 255]. If a floating point number is passed in, the value is rounded down. 6881 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6882 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 6883 * @syscap SystemCapability.Graphics.Drawing 6884 * @crossplatform 6885 * @since 20 6886 * @arkts 1.1&1.2 6887 */ 6888 setAlpha(alpha: number): void; 6889 6890 /** 6891 * Obtains the alpha value of this pen. 6892 * @returns { number } Returns a 8-bit variable that describes the alpha. 6893 * @syscap SystemCapability.Graphics.Drawing 6894 * @since 12 6895 */ 6896 /** 6897 * Obtains the alpha value of this pen. 6898 * @returns { number } Returns a 8-bit variable that describes the alpha. 6899 * @syscap SystemCapability.Graphics.Drawing 6900 * @crossplatform 6901 * @since 20 6902 * @arkts 1.1&1.2 6903 */ 6904 getAlpha(): number; 6905 6906 /** 6907 * Sets a color filter for this pen. 6908 * 6909 * @param { ColorFilter } filter - Color filter. If null is passed in, the color filter is cleared. 6910 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6911 * <br>2. Incorrect parameter types. 6912 * @syscap SystemCapability.Graphics.Drawing 6913 * @since 11 6914 */ 6915 /** 6916 * Sets a color filter for this pen. 6917 * 6918 * @param { ColorFilter } filter - Color filter. If null is passed in, the color filter is cleared. 6919 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6920 * <br>2. Incorrect parameter types. 6921 * @syscap SystemCapability.Graphics.Drawing 6922 * @crossplatform 6923 * @since 20 6924 * @arkts 1.1&1.2 6925 */ 6926 setColorFilter(filter: ColorFilter): void; 6927 /** 6928 * Obtains the color filter of this pen. 6929 * @returns { ColorFilter } ColorFilter. 6930 * @syscap SystemCapability.Graphics.Drawing 6931 * @since 12 6932 */ 6933 /** 6934 * Obtains the color filter of this pen. 6935 * @returns { ColorFilter } ColorFilter. 6936 * @syscap SystemCapability.Graphics.Drawing 6937 * @crossplatform 6938 * @since 20 6939 */ 6940 getColorFilter(): ColorFilter; 6941 /** 6942 * Sets an image filter for this pen. 6943 * @param { ImageFilter | null } filter - Image filter. If null is passed in, the image filter effect of the pen will be cleared. 6944 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6945 * <br>2. Incorrect parameter types. 6946 * @syscap SystemCapability.Graphics.Drawing 6947 * @since 12 6948 */ 6949 /** 6950 * Sets an image filter for this pen. 6951 * @param { ImageFilter | null } filter - Image filter. If null is passed in, the image filter effect of the pen will be cleared. 6952 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6953 * <br>2. Incorrect parameter types. 6954 * @syscap SystemCapability.Graphics.Drawing 6955 * @crossplatform 6956 * @since 20 6957 */ 6958 setImageFilter(filter: ImageFilter | null): void; 6959 /** 6960 * Adds a mask filter for this pen. 6961 * 6962 * @param { MaskFilter } filter - Mask filter. If null is passed in, the mask filter is cleared. 6963 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6964 * <br>2. Incorrect parameter types. 6965 * @syscap SystemCapability.Graphics.Drawing 6966 * @since 12 6967 */ 6968 /** 6969 * Adds a mask filter for this pen. 6970 * 6971 * @param { MaskFilter } filter - Mask filter. If null is passed in, the mask filter is cleared. 6972 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6973 * <br>2. Incorrect parameter types. 6974 * @syscap SystemCapability.Graphics.Drawing 6975 * @crossplatform 6976 * @since 20 6977 */ 6978 setMaskFilter(filter: MaskFilter): void; 6979 6980 /** 6981 * Sets the path effect for this pen. 6982 * 6983 * @param { PathEffect } effect - Path effect. If null is passed in, the path filter is cleared. 6984 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6985 * <br>2. Incorrect parameter types. 6986 * @syscap SystemCapability.Graphics.Drawing 6987 * @since 12 6988 */ 6989 /** 6990 * Sets the path effect for this pen. 6991 * 6992 * @param { PathEffect } effect - Path effect. If null is passed in, the path filter is cleared. 6993 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 6994 * <br>2. Incorrect parameter types. 6995 * @syscap SystemCapability.Graphics.Drawing 6996 * @crossplatform 6997 * @since 20 6998 */ 6999 setPathEffect(effect: PathEffect): void; 7000 7001 /** 7002 * Sets a shadow layer for this pen. The shadow layer effect takes effect only when text is drawn. 7003 * 7004 * @param { ShadowLayer } shadowLayer - Shadow layer. If null is passed in, the shadow layer is cleared. 7005 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7006 * <br>2. Incorrect parameter types. 7007 * @syscap SystemCapability.Graphics.Drawing 7008 * @since 12 7009 */ 7010 /** 7011 * Sets a shadow layer for this pen. The shadow layer effect takes effect only when text is drawn. 7012 * 7013 * @param { ShadowLayer } shadowLayer - Shadow layer. If null is passed in, the shadow layer is cleared. 7014 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7015 * <br>2. Incorrect parameter types. 7016 * @syscap SystemCapability.Graphics.Drawing 7017 * @crossplatform 7018 * @since 20 7019 */ 7020 setShadowLayer(shadowLayer: ShadowLayer): void; 7021 7022 /** 7023 * Sets a blend mode for this pen. 7024 * 7025 * @param { BlendMode } mode - Blend mode. 7026 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7027 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7028 * @syscap SystemCapability.Graphics.Drawing 7029 * @since 11 7030 */ 7031 /** 7032 * Sets a blend mode for this pen. 7033 * 7034 * @param { BlendMode } mode - Blend mode. 7035 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7036 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7037 * @syscap SystemCapability.Graphics.Drawing 7038 * @crossplatform 7039 * @since 20 7040 * @arkts 1.1&1.2 7041 */ 7042 setBlendMode(mode: BlendMode): void; 7043 7044 /** 7045 * Enables dithering for this pen. Dithering make the drawn color more realistic. 7046 * 7047 * @param { boolean } dither - Whether to enable dithering. The value true means to enable dithering, and false means the opposite. 7048 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7049 * <br>2. Incorrect parameter types. 7050 * @syscap SystemCapability.Graphics.Drawing 7051 * @since 11 7052 */ 7053 /** 7054 * Enables dithering for this pen. Dithering make the drawn color more realistic. 7055 * 7056 * @param { boolean } dither - Whether to enable dithering. The value true means to enable dithering, and false means the opposite. 7057 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7058 * <br>2. Incorrect parameter types. 7059 * @syscap SystemCapability.Graphics.Drawing 7060 * @crossplatform 7061 * @since 20 7062 */ 7063 setDither(dither: boolean): void; 7064 7065 /** 7066 * Sets the join style for this pen. If this API is not called, the default join style is MITER_JOIN. 7067 * 7068 * @param { JoinStyle } style - Join style. 7069 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7070 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7071 * @syscap SystemCapability.Graphics.Drawing 7072 * @since 12 7073 */ 7074 /** 7075 * Sets the join style for this pen. If this API is not called, the default join style is MITER_JOIN. 7076 * 7077 * @param { JoinStyle } style - Join style. 7078 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7079 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7080 * @syscap SystemCapability.Graphics.Drawing 7081 * @crossplatform 7082 * @since 20 7083 */ 7084 setJoinStyle(style: JoinStyle): void; 7085 7086 /** 7087 * Obtains the join style of this pen. 7088 * 7089 * @returns { JoinStyle } The JoinStyle. 7090 * @syscap SystemCapability.Graphics.Drawing 7091 * @since 12 7092 */ 7093 /** 7094 * Obtains the join style of this pen. 7095 * 7096 * @returns { JoinStyle } The JoinStyle. 7097 * @syscap SystemCapability.Graphics.Drawing 7098 * @crossplatform 7099 * @since 20 7100 */ 7101 getJoinStyle(): JoinStyle; 7102 7103 /** 7104 * Sets the cap style for this pen. If this API is not called, the default cap style is FLAT_CAP. 7105 * 7106 * @param { CapStyle } style - Cap style. 7107 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7108 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7109 * @syscap SystemCapability.Graphics.Drawing 7110 * @since 12 7111 */ 7112 /** 7113 * Sets the cap style for this pen. If this API is not called, the default cap style is FLAT_CAP. 7114 * 7115 * @param { CapStyle } style - Cap style. 7116 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7117 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7118 * @syscap SystemCapability.Graphics.Drawing 7119 * @crossplatform 7120 * @since 20 7121 */ 7122 setCapStyle(style: CapStyle): void; 7123 7124 /** 7125 * Obtains the cap style of this pen. 7126 * 7127 * @returns { CapStyle } The CapStyle. 7128 * @syscap SystemCapability.Graphics.Drawing 7129 * @since 12 7130 */ 7131 /** 7132 * Obtains the cap style of this pen. 7133 * 7134 * @returns { CapStyle } The CapStyle. 7135 * @syscap SystemCapability.Graphics.Drawing 7136 * @crossplatform 7137 * @since 20 7138 */ 7139 getCapStyle(): CapStyle; 7140 7141 /** 7142 * Resets this pen to the initial state. 7143 * @syscap SystemCapability.Graphics.Drawing 7144 * @since 12 7145 */ 7146 /** 7147 * Resets this pen to the initial state. 7148 * @syscap SystemCapability.Graphics.Drawing 7149 * @crossplatform 7150 * @since 20 7151 * @arkts 1.1&1.2 7152 */ 7153 reset(): void; 7154 /** 7155 * Obtains the source path outline drawn using this pen and represents it using a destination path. 7156 * 7157 * @param { Path } src - Source path. 7158 * @param { Path } dst - Destination path. 7159 * @returns { boolean } true if the path should be filled, or false if it should be drawn with a hairline (width == 0) 7160 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7161 * <br>2. Incorrect parameter types. 7162 * @syscap SystemCapability.Graphics.Drawing 7163 * @since 12 7164 */ 7165 /** 7166 * Obtains the source path outline drawn using this pen and represents it using a destination path. 7167 * 7168 * @param { Path } src - Source path. 7169 * @param { Path } dst - Destination path. 7170 * @returns { boolean } true if the path should be filled, or false if it should be drawn with a hairline (width == 0) 7171 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7172 * <br>2. Incorrect parameter types. 7173 * @syscap SystemCapability.Graphics.Drawing 7174 * @crossplatform 7175 * @since 20 7176 */ 7177 getFillPath(src: Path, dst: Path): boolean; 7178 } 7179 7180 /** 7181 * Defines a brush, which is used to describe the style and color to fill in a shape. 7182 * @syscap SystemCapability.Graphics.Drawing 7183 * @since 11 7184 */ 7185 /** 7186 * Defines a brush, which is used to describe the style and color to fill in a shape. 7187 * @syscap SystemCapability.Graphics.Drawing 7188 * @crossplatform 7189 * @since 20 7190 * @arkts 1.1&1.2 7191 */ 7192 class Brush { 7193 /** 7194 * A constructor used to create a Brush object. 7195 * @syscap SystemCapability.Graphics.Drawing 7196 * @since 12 7197 */ 7198 /** 7199 * A constructor used to create a Brush object. 7200 * @syscap SystemCapability.Graphics.Drawing 7201 * @crossplatform 7202 * @since 20 7203 * @arkts 1.1&1.2 7204 */ 7205 constructor(); 7206 7207 /** 7208 * Copies a Brush object to create a new one. 7209 * @param { Brush } brush - Indicates the Brush object. 7210 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7211 * <br>2. Incorrect parameter types. 7212 * @syscap SystemCapability.Graphics.Drawing 7213 * @since 12 7214 */ 7215 /** 7216 * Copies a Brush object to create a new one. 7217 * @param { Brush } brush - Indicates the Brush object. 7218 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7219 * <br>2. Incorrect parameter types. 7220 * @syscap SystemCapability.Graphics.Drawing 7221 * @crossplatform 7222 * @since 20 7223 * @arkts 1.1&1.2 7224 */ 7225 constructor(brush: Brush); 7226 7227 /** 7228 * Sets a color for this brush. 7229 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 7230 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7231 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7232 * @syscap SystemCapability.Graphics.Drawing 7233 * @since 11 7234 */ 7235 /** 7236 * Sets a color for this brush. 7237 * @param { common2D.Color } color - Color in ARGB format. The value of each color channel is an integer ranging from 0 to 255. 7238 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7239 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7240 * @syscap SystemCapability.Graphics.Drawing 7241 * @crossplatform 7242 * @since 20 7243 */ 7244 setColor(color: common2D.Color): void; 7245 7246 /** 7247 * Sets a color for this brush. This API provides better performance than setColor and is recommended. 7248 * @param { number } alpha - Alpha channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7249 * Any passed-in floating point number is rounded down. 7250 * @param { number } red - Red channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7251 * Any passed-in floating point number is rounded down. 7252 * @param { number } green - Green channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7253 * Any passed-in floating point number is rounded down. 7254 * @param { number } blue - Blue channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7255 * Any passed-in floating point number is rounded down. 7256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7257 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7258 * @syscap SystemCapability.Graphics.Drawing 7259 * @since 12 7260 */ 7261 /** 7262 * Sets a color for this brush. This API provides better performance than setColor and is recommended. 7263 * @param { number } alpha - Alpha channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7264 * Any passed-in floating point number is rounded down. 7265 * @param { number } red - Red channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7266 * Any passed-in floating point number is rounded down. 7267 * @param { number } green - Green channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7268 * Any passed-in floating point number is rounded down. 7269 * @param { number } blue - Blue channel value of the color in ARGB format. The value is an integer ranging from 0 to 255. 7270 * Any passed-in floating point number is rounded down. 7271 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7272 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7273 * @syscap SystemCapability.Graphics.Drawing 7274 * @crossplatform 7275 * @since 20 7276 */ 7277 setColor(alpha: number, red: number, green: number, blue: number): void; 7278 7279 /** 7280 * Sets a color for this brush. 7281 * @param { number } color - Color in hexadecimal ARGB format. 7282 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7283 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7284 * @syscap SystemCapability.Graphics.Drawing 7285 * @since 18 7286 */ 7287 /** 7288 * Sets a color for this brush. 7289 * @param { number } color - Color in hexadecimal ARGB format. 7290 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7291 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7292 * @syscap SystemCapability.Graphics.Drawing 7293 * @crossplatform 7294 * @since 20 7295 */ 7296 setColor(color: number): void; 7297 7298 /** 7299 * Sets the color by four floating point values, unpremultiplied. The color values are interpreted as being in 7300 * the colorSpace. If colorSpace is nullptr, then color is assumed to be in the sRGB color space. 7301 * 7302 * @param { common2D.Color4f } color4f - Indicates four floating point values that describes the color. 7303 * @param { colorSpaceManager.ColorSpaceManager | null } colorSpace - Indicates colorSpaceManager. 7304 * @syscap SystemCapability.Graphics.Drawing 7305 * @crossplatform 7306 * @since 20 7307 */ 7308 setColor4f(color4f: common2D.Color4f, colorSpace: colorSpaceManager.ColorSpaceManager | null): void; 7309 7310 /** 7311 * Obtains the color of this brush. 7312 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 7313 * @syscap SystemCapability.Graphics.Drawing 7314 * @since 12 7315 */ 7316 /** 7317 * Obtains the color of this brush. 7318 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 7319 * @syscap SystemCapability.Graphics.Drawing 7320 * @crossplatform 7321 * @since 20 7322 */ 7323 getColor(): common2D.Color; 7324 7325 /** 7326 * Obtains the color of a brush. The color is used by the brush to outline a shape. 7327 * @returns { common2D.Color4f } Returns four floating point values that describes the color. 7328 * @syscap SystemCapability.Graphics.Drawing 7329 * @crossplatform 7330 * @since 20 7331 */ 7332 getColor4f(): common2D.Color4f; 7333 7334 /** 7335 * Obtains the color of this brush. 7336 * @returns { number } Returns a 32-bit (ARGB) variable that describes the color of hexadecimal format. 7337 * @syscap SystemCapability.Graphics.Drawing 7338 * @since 18 7339 */ 7340 /** 7341 * Obtains the color of this brush. 7342 * @returns { number } Returns a 32-bit (ARGB) variable that describes the color of hexadecimal format. 7343 * @syscap SystemCapability.Graphics.Drawing 7344 * @crossplatform 7345 * @since 20 7346 */ 7347 getHexColor(): number; 7348 7349 /** 7350 * Enables anti-aliasing for this brush. Anti-aliasing makes the edges of the content smoother. 7351 * If this API is not called, anti-aliasing is disabled by default. 7352 * @param { boolean } aa - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite. 7353 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7354 * <br>2. Incorrect parameter types. 7355 * @syscap SystemCapability.Graphics.Drawing 7356 * @since 11 7357 */ 7358 /** 7359 * Enables anti-aliasing for this brush. Anti-aliasing makes the edges of the content smoother. 7360 * If this API is not called, anti-aliasing is disabled by default. 7361 * @param { boolean } aa - Whether to enable anti-aliasing. The value true means to enable anti-aliasing, and false means the opposite. 7362 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7363 * <br>2. Incorrect parameter types. 7364 * @syscap SystemCapability.Graphics.Drawing 7365 * @crossplatform 7366 * @since 20 7367 */ 7368 setAntiAlias(aa: boolean): void; 7369 7370 /** 7371 * Checks whether anti-aliasing is enabled for this brush. 7372 * @returns { boolean } Returns true if anti-aliasing is enabled; returns false otherwise. 7373 * @syscap SystemCapability.Graphics.Drawing 7374 * @since 12 7375 */ 7376 /** 7377 * Checks whether anti-aliasing is enabled for this brush. 7378 * @returns { boolean } Returns true if anti-aliasing is enabled; returns false otherwise. 7379 * @syscap SystemCapability.Graphics.Drawing 7380 * @crossplatform 7381 * @since 20 7382 */ 7383 isAntiAlias(): boolean; 7384 7385 /** 7386 * Sets an alpha value for this brush. 7387 * @param { number } alpha - Alpha value. The value is an integer in the range [0, 255]. If a floating point number is passed in, the value is rounded down. 7388 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7389 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7390 * @syscap SystemCapability.Graphics.Drawing 7391 * @since 11 7392 */ 7393 /** 7394 * Sets an alpha value for this brush. 7395 * @param { number } alpha - Alpha value. The value is an integer in the range [0, 255]. If a floating point number is passed in, the value is rounded down. 7396 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7397 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7398 * @syscap SystemCapability.Graphics.Drawing 7399 * @crossplatform 7400 * @since 20 7401 * @arkts 1.1&1.2 7402 */ 7403 setAlpha(alpha: number): void; 7404 7405 /** 7406 * Obtains the alpha value of this brush. 7407 * @returns { number } Returns a 8-bit variable that describes the alpha. 7408 * @syscap SystemCapability.Graphics.Drawing 7409 * @since 12 7410 */ 7411 /** 7412 * Obtains the alpha value of this brush. 7413 * @returns { number } Returns a 8-bit variable that describes the alpha. 7414 * @syscap SystemCapability.Graphics.Drawing 7415 * @crossplatform 7416 * @since 20 7417 * @arkts 1.1&1.2 7418 */ 7419 getAlpha(): number; 7420 7421 /** 7422 * Sets a color filter for this brush. 7423 * @param { ColorFilter } filter - Color filter. If null is passed in, the color filter is cleared. 7424 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7425 * <br>2. Incorrect parameter types. 7426 * @syscap SystemCapability.Graphics.Drawing 7427 * @since 11 7428 */ 7429 /** 7430 * Sets a color filter for this brush. 7431 * @param { ColorFilter } filter - Color filter. If null is passed in, the color filter is cleared. 7432 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7433 * <br>2. Incorrect parameter types. 7434 * @syscap SystemCapability.Graphics.Drawing 7435 * @crossplatform 7436 * @since 20 7437 * @arkts 1.1&1.2 7438 */ 7439 setColorFilter(filter: ColorFilter): void; 7440 7441 /** 7442 * Obtains the color filter of this brush. 7443 * @returns { ColorFilter } ColorFilter. 7444 * @syscap SystemCapability.Graphics.Drawing 7445 * @since 12 7446 */ 7447 /** 7448 * Obtains the color filter of this brush. 7449 * @returns { ColorFilter } ColorFilter. 7450 * @syscap SystemCapability.Graphics.Drawing 7451 * @crossplatform 7452 * @since 20 7453 */ 7454 getColorFilter(): ColorFilter; 7455 /** 7456 * Sets an image filter for this brush. 7457 * @param { ImageFilter | null } filter - Image filter. If null is passed in, the image filter effect of the brush will be cleared. 7458 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7459 * <br>2. Incorrect parameter types. 7460 * @syscap SystemCapability.Graphics.Drawing 7461 * @since 12 7462 */ 7463 /** 7464 * Sets an image filter for this brush. 7465 * @param { ImageFilter | null } filter - Image filter. If null is passed in, the image filter effect of the brush will be cleared. 7466 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7467 * <br>2. Incorrect parameter types. 7468 * @syscap SystemCapability.Graphics.Drawing 7469 * @crossplatform 7470 * @since 20 7471 */ 7472 setImageFilter(filter: ImageFilter | null): void; 7473 /** 7474 * Adds a mask filter for this brush. 7475 * @param { MaskFilter } filter - Mask filter. If null is passed in, the mask filter is cleared. 7476 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7477 * <br>2. Incorrect parameter types. 7478 * @syscap SystemCapability.Graphics.Drawing 7479 * @since 12 7480 */ 7481 /** 7482 * Adds a mask filter for this brush. 7483 * @param { MaskFilter } filter - Mask filter. If null is passed in, the mask filter is cleared. 7484 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7485 * <br>2. Incorrect parameter types. 7486 * @syscap SystemCapability.Graphics.Drawing 7487 * @crossplatform 7488 * @since 20 7489 */ 7490 setMaskFilter(filter: MaskFilter): void; 7491 7492 /** 7493 * Sets a shadow layer for this brush. The shadow layer effect takes effect only when text is drawn. 7494 * 7495 * @param { ShadowLayer } shadowLayer - Shadow layer. If null is passed in, the shadow layer is cleared. 7496 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7497 * <br>2. Incorrect parameter types. 7498 * @syscap SystemCapability.Graphics.Drawing 7499 * @since 12 7500 */ 7501 /** 7502 * Sets a shadow layer for this brush. The shadow layer effect takes effect only when text is drawn. 7503 * 7504 * @param { ShadowLayer } shadowLayer - Shadow layer. If null is passed in, the shadow layer is cleared. 7505 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7506 * <br>2. Incorrect parameter types. 7507 * @syscap SystemCapability.Graphics.Drawing 7508 * @crossplatform 7509 * @since 20 7510 */ 7511 setShadowLayer(shadowLayer: ShadowLayer): void; 7512 7513 /** 7514 * Sets the shader effect for this brush. 7515 * @param { ShaderEffect } shaderEffect - ShaderEffect object. If null is passed in, the shader effect will be cleared. 7516 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7517 * <br>2. Incorrect parameter types. 7518 * @syscap SystemCapability.Graphics.Drawing 7519 * @since 12 7520 */ 7521 /** 7522 * Sets the shader effect for this brush. 7523 * @param { ShaderEffect } shaderEffect - ShaderEffect object. If null is passed in, the shader effect will be cleared. 7524 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7525 * <br>2. Incorrect parameter types. 7526 * @syscap SystemCapability.Graphics.Drawing 7527 * @crossplatform 7528 * @since 20 7529 */ 7530 setShaderEffect(shaderEffect: ShaderEffect): void; 7531 7532 /** 7533 * Sets a blend mode for this brush. If this API is not called, the default blend mode is SRC_OVER. 7534 * @param { BlendMode } mode - Blend mode. 7535 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7536 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7537 * @syscap SystemCapability.Graphics.Drawing 7538 * @since 11 7539 */ 7540 /** 7541 * Sets a blend mode for this brush. If this API is not called, the default blend mode is SRC_OVER. 7542 * @param { BlendMode } mode - Blend mode. 7543 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7544 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7545 * @syscap SystemCapability.Graphics.Drawing 7546 * @crossplatform 7547 * @since 20 7548 * @arkts 1.1&1.2 7549 */ 7550 setBlendMode(mode: BlendMode): void; 7551 7552 /** 7553 * Resets this brush to the initial state. 7554 * @syscap SystemCapability.Graphics.Drawing 7555 * @since 12 7556 */ 7557 /** 7558 * Resets this brush to the initial state. 7559 * @syscap SystemCapability.Graphics.Drawing 7560 * @crossplatform 7561 * @since 20 7562 * @arkts 1.1&1.2 7563 */ 7564 reset(): void; 7565 } 7566 7567 /** 7568 * Implements a matrix. 7569 * 7570 * @syscap SystemCapability.Graphics.Drawing 7571 * @since 12 7572 */ 7573 /** 7574 * Implements a matrix. 7575 * 7576 * @syscap SystemCapability.Graphics.Drawing 7577 * @crossplatform 7578 * @since 20 7579 * @arkts 1.1&1.2 7580 */ 7581 class Matrix { 7582 /** 7583 * Creates a Matrix object. 7584 * @syscap SystemCapability.Graphics.Drawing 7585 * @since 12 7586 */ 7587 /** 7588 * Creates a Matrix object. 7589 * @syscap SystemCapability.Graphics.Drawing 7590 * @crossplatform 7591 * @since 20 7592 * @arkts 1.1&1.2 7593 */ 7594 constructor(); 7595 7596 /** 7597 * Creates a deep copy of the specified matrix object. 7598 * @param { Matrix } matrix - The matrix object to copy. 7599 * @syscap SystemCapability.Graphics.Drawing 7600 * @crossplatform 7601 * @since 20 7602 * @arkts 1.1&1.2 7603 */ 7604 constructor(matrix: Matrix); 7605 7606 /** 7607 * Query whether the current matrix is affine or not. 7608 * @returns { boolean } Returns true if the matrix is affine; returns false otherwise. 7609 * @syscap SystemCapability.Graphics.Drawing 7610 * @crossplatform 7611 * @since 20 7612 */ 7613 isAffine(): boolean; 7614 7615 /** 7616 * Query whether a rectangle will map to another rectangle after applying this matrix. 7617 * @returns { boolean } Returns true if the transformation keeps rectangles as rectangles; returns false otherwise. 7618 * @syscap SystemCapability.Graphics.Drawing 7619 * @crossplatform 7620 * @since 20 7621 */ 7622 rectStaysRect(): boolean; 7623 7624 /** 7625 * Sets this matrix as an identity matrix and rotates it by a given degree around the rotation point (px, py). 7626 * @param { number } degree - Angle to rotate, in degrees. A positive number indicates a clockwise rotation, 7627 * and a negative number indicates a counterclockwise rotation. The value is a floating point number. 7628 * @param { number } px - X coordinate of the rotation point. The value is a floating point number. 7629 * @param { number } py - Y coordinate of the rotation point. The value is a floating point number. 7630 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7631 * <br>2. Incorrect parameter types. 7632 * @syscap SystemCapability.Graphics.Drawing 7633 * @since 12 7634 */ 7635 /** 7636 * Sets this matrix as an identity matrix and rotates it by a given degree around the rotation point (px, py). 7637 * @param { number } degree - Angle to rotate, in degrees. A positive number indicates a clockwise rotation, 7638 * and a negative number indicates a counterclockwise rotation. The value is a floating point number. 7639 * @param { number } px - X coordinate of the rotation point. The value is a floating point number. 7640 * @param { number } py - Y coordinate of the rotation point. The value is a floating point number. 7641 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7642 * <br>2. Incorrect parameter types. 7643 * @syscap SystemCapability.Graphics.Drawing 7644 * @crossplatform 7645 * @since 20 7646 */ 7647 setRotation(degree: number, px: number, py: number): void; 7648 7649 /** 7650 * Sets this matrix as an identity matrix and scales it with the coefficients (sx, sy) at the scale point (px, py). 7651 * @param { number } sx - Scale coefficient along the X axis. If a negative number is passed in, 7652 * the matrix is mirrored around y = px before being scaled. The value is a floating point number. 7653 * @param { number } sy - Scale coefficient along the Y axis. If a negative number is passed in, 7654 * the matrix is mirrored around x = py before being scaled. The value is a floating point number. 7655 * @param { number } px - X coordinate of the scale point. The value is a floating point number. 7656 * @param { number } py - Y coordinate of the scale point. The value is a floating point number. 7657 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7658 * <br>2. Incorrect parameter types. 7659 * @syscap SystemCapability.Graphics.Drawing 7660 * @since 12 7661 */ 7662 /** 7663 * Sets this matrix as an identity matrix and scales it with the coefficients (sx, sy) at the scale point (px, py). 7664 * @param { number } sx - Scale coefficient along the X axis. If a negative number is passed in, 7665 * the matrix is mirrored around y = px before being scaled. The value is a floating point number. 7666 * @param { number } sy - Scale coefficient along the Y axis. If a negative number is passed in, 7667 * the matrix is mirrored around x = py before being scaled. The value is a floating point number. 7668 * @param { number } px - X coordinate of the scale point. The value is a floating point number. 7669 * @param { number } py - Y coordinate of the scale point. The value is a floating point number. 7670 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7671 * <br>2. Incorrect parameter types. 7672 * @syscap SystemCapability.Graphics.Drawing 7673 * @crossplatform 7674 * @since 20 7675 */ 7676 setScale(sx: number, sy: number, px: number, py: number): void; 7677 7678 /** 7679 * Sets this matrix as an identity matrix and translates it by a given distance (dx, dy). 7680 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 7681 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 7682 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 7683 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 7684 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7685 * <br>2. Incorrect parameter types. 7686 * @syscap SystemCapability.Graphics.Drawing 7687 * @since 12 7688 */ 7689 /** 7690 * Sets this matrix as an identity matrix and translates it by a given distance (dx, dy). 7691 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 7692 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 7693 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 7694 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 7695 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7696 * <br>2. Incorrect parameter types. 7697 * @syscap SystemCapability.Graphics.Drawing 7698 * @crossplatform 7699 * @since 20 7700 * @arkts 1.1&1.2 7701 */ 7702 setTranslation(dx: number, dy: number): void; 7703 7704 /** 7705 * Sets the skew transformation with a pivot point. 7706 * @param { number } kx - The skew factor along the x-axis. 7707 * @param { number } ky - The skew factor along the y-axis. 7708 * @param { number } px - The x-coordinate of the point around which to apply the skew. 7709 * @param { number } py - The y-coordinate of the point around which to apply the skew. 7710 * @syscap SystemCapability.Graphics.Drawing 7711 * @crossplatform 7712 * @since 20 7713 */ 7714 setSkew(kx: number, ky: number, px: number, py: number): void; 7715 7716 /** 7717 * Sets the sine and cosine values for a rotation transformation around a point. 7718 * @param { number } sinValue - The sine of the angle of rotation. 7719 * @param { number } cosValue - The cosine of the angle of rotation. 7720 * @param { number } px - The x-coordinate of the point around which to rotate. 7721 * @param { number } py - The y-coordinate of the point around which to rotate. 7722 * @syscap SystemCapability.Graphics.Drawing 7723 * @crossplatform 7724 * @since 20 7725 */ 7726 setSinCos(sinValue: number, cosValue: number, px: number, py: number): void; 7727 7728 /** 7729 * Sets parameters for this matrix. 7730 * @param { Array<number> } values - Each value in the array represents the following parameters: 7731 * values[0] - horizontal scale factor to store. 7732 * values[1] - horizontal skew factor to store. 7733 * values[2] - horizontal translation to store. 7734 * values[3] - vertical skew factor to store. 7735 * values[4] - vertical scale factor to store. 7736 * values[5] - vertical translation to store. 7737 * values[6] - input x-axis values perspective factor to store. 7738 * values[7] - input y-axis values perspective factor to store. 7739 * values[8] - perspective scale factor to store. 7740 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7741 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7742 * @syscap SystemCapability.Graphics.Drawing 7743 * @since 12 7744 */ 7745 /** 7746 * Sets parameters for this matrix. 7747 * @param { Array<number> } values - Each value in the array represents the following parameters: 7748 * values[0] - horizontal scale factor to store. 7749 * values[1] - horizontal skew factor to store. 7750 * values[2] - horizontal translation to store. 7751 * values[3] - vertical skew factor to store. 7752 * values[4] - vertical scale factor to store. 7753 * values[5] - vertical translation to store. 7754 * values[6] - input x-axis values perspective factor to store. 7755 * values[7] - input y-axis values perspective factor to store. 7756 * values[8] - perspective scale factor to store. 7757 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7758 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7759 * @syscap SystemCapability.Graphics.Drawing 7760 * @crossplatform 7761 * @since 20 7762 */ 7763 setMatrix(values: Array<number>): void; 7764 7765 /** 7766 * Sets matrix to the copy of anther matrix object. 7767 * @param { Array<number> | Matrix } matrix - Indicates the Matrix object to copy. 7768 * @syscap SystemCapability.Graphics.Drawing 7769 * @crossplatform 7770 * @since 20 7771 */ 7772 setMatrix(matrix: Array<number> | Matrix): void; 7773 7774 /** 7775 * Sets matrix to the product of matrix A and matrix B. 7776 * @param { Matrix } matrixA - Indicates the MatrixA object. 7777 * @param { Matrix } matrixB - Indicates the MatrixB object. 7778 * @syscap SystemCapability.Graphics.Drawing 7779 * @crossplatform 7780 * @since 20 7781 */ 7782 setConcat(matrixA: Matrix, matrixB: Matrix): void; 7783 7784 /** 7785 * Sets matrix to the product of 'this' and another. 7786 * @param { Matrix } matrix - Indicates the other Matrix object. 7787 * @syscap SystemCapability.Graphics.Drawing 7788 * @crossplatform 7789 * @since 20 7790 */ 7791 postConcat(matrix: Matrix): void; 7792 7793 /** 7794 * Preconcats the existing matrix with the passed-in matrix. 7795 * @param { Matrix } matrix - Matrix object, which is on the right of a multiplication expression. 7796 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7797 * <br>2. Incorrect parameter types. 7798 * @syscap SystemCapability.Graphics.Drawing 7799 * @since 12 7800 */ 7801 /** 7802 * Preconcats the existing matrix with the passed-in matrix. 7803 * @param { Matrix } matrix - Matrix object, which is on the right of a multiplication expression. 7804 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7805 * <br>2. Incorrect parameter types. 7806 * @syscap SystemCapability.Graphics.Drawing 7807 * @crossplatform 7808 * @since 20 7809 */ 7810 preConcat(matrix: Matrix): void; 7811 7812 /** 7813 * Checks whether this matrix is equal to another matrix. 7814 * @param { Matrix } matrix - Matrix to compare. 7815 * @returns { Boolean } Returns true if the two matrices are equal; returns false otherwise. 7816 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7817 * <br>2. Incorrect parameter types. 7818 * @syscap SystemCapability.Graphics.Drawing 7819 * @since 12 7820 */ 7821 /** 7822 * Checks whether this matrix is equal to another matrix. 7823 * @param { Matrix } matrix - Matrix to compare. 7824 * @returns { Boolean } Returns true if the two matrices are equal; returns false otherwise. 7825 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7826 * <br>2. Incorrect parameter types. 7827 * @syscap SystemCapability.Graphics.Drawing 7828 * @crossplatform 7829 * @since 20 7830 */ 7831 isEqual(matrix: Matrix): Boolean; 7832 7833 /** 7834 * Inverts this matrix and returns the result. 7835 * @param { Matrix } matrix - Matrix object used to store the inverted matrix. 7836 * @returns { Boolean } Check result. The value true means that the matrix is revertible and the matrix object is set to its inverse, 7837 * and false means that the matrix is not revertible and the matrix object remains unchanged. 7838 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7839 * <br>2. Incorrect parameter types. 7840 * @syscap SystemCapability.Graphics.Drawing 7841 * @since 12 7842 */ 7843 /** 7844 * Inverts this matrix and returns the result. 7845 * @param { Matrix } matrix - Matrix object used to store the inverted matrix. 7846 * @returns { Boolean } Check result. The value true means that the matrix is revertible and the matrix object is set to its inverse, 7847 * and false means that the matrix is not revertible and the matrix object remains unchanged. 7848 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7849 * <br>2. Incorrect parameter types. 7850 * @syscap SystemCapability.Graphics.Drawing 7851 * @crossplatform 7852 * @since 20 7853 */ 7854 invert(matrix: Matrix): Boolean; 7855 7856 /** 7857 * Checks whether this matrix is an identity matrix. 7858 * @returns { Boolean } Returns true if matrix is identity; returns false otherwise. 7859 * @syscap SystemCapability.Graphics.Drawing 7860 * @since 12 7861 */ 7862 /** 7863 * Checks whether this matrix is an identity matrix. 7864 * @returns { Boolean } Returns true if matrix is identity; returns false otherwise. 7865 * @syscap SystemCapability.Graphics.Drawing 7866 * @crossplatform 7867 * @since 20 7868 */ 7869 isIdentity(): Boolean; 7870 7871 /** 7872 * Obtains the value of a given index in this matrix. The index ranges from 0 to 8. 7873 * @param { number } index - Index. The value is an integer ranging from 0 to 8. 7874 * @returns { number } Returns value corresponding to index.Returns 0 if out of range. 7875 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7876 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7877 * @syscap SystemCapability.Graphics.Drawing 7878 * @since 12 7879 */ 7880 /** 7881 * Obtains the value of a given index in this matrix. The index ranges from 0 to 8. 7882 * @param { number } index - Index. The value is an integer ranging from 0 to 8. 7883 * @returns { number } Returns value corresponding to index.Returns 0 if out of range. 7884 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7885 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7886 * @syscap SystemCapability.Graphics.Drawing 7887 * @crossplatform 7888 * @since 20 7889 * @arkts 1.1&1.2 7890 */ 7891 getValue(index: number): number; 7892 /** 7893 * Post multiplies this matrix by a matrix that is derived from an identity matrix after it has been rotated by a 7894 * given degree around the rotation point (px, py). 7895 * @param { number } degree - Angle to rotate, in degrees. A positive number indicates a clockwise rotation, 7896 * and a negative number indicates a counterclockwise rotation. The value is a floating point number. 7897 * @param { number } px - X coordinate of the rotation point. The value is a floating point number. 7898 * @param { number } py - Y coordinate of the rotation point. The value is a floating point number. 7899 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7900 * <br>2. Incorrect parameter types. 7901 * @syscap SystemCapability.Graphics.Drawing 7902 * @since 12 7903 */ 7904 /** 7905 * Post multiplies this matrix by a matrix that is derived from an identity matrix after it has been rotated by a 7906 * given degree around the rotation point (px, py). 7907 * @param { number } degree - Angle to rotate, in degrees. A positive number indicates a clockwise rotation, 7908 * and a negative number indicates a counterclockwise rotation. The value is a floating point number. 7909 * @param { number } px - X coordinate of the rotation point. The value is a floating point number. 7910 * @param { number } py - Y coordinate of the rotation point. The value is a floating point number. 7911 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7912 * <br>2. Incorrect parameter types. 7913 * @syscap SystemCapability.Graphics.Drawing 7914 * @crossplatform 7915 * @since 20 7916 */ 7917 postRotate(degree: number, px: number, py: number): void; 7918 /** 7919 * Post multiplies this matrix by a matrix that is derived from an identity matrix after it has been 7920 * scaled with the coefficient (sx, sy) at the scale point (px, py). 7921 * @param { number } sx - Scale coefficient along the X axis. If a negative number is passed in, 7922 * the matrix is mirrored around y = px before being scaled. The value is a floating point number. 7923 * @param { number } sy - Scale coefficient along the Y axis. If a negative number is passed in, 7924 * the matrix is mirrored around x = py before being scaled. The value is a floating point number. 7925 * @param { number } px - X coordinate of the scale point. The value is a floating point number. 7926 * @param { number } py - Y coordinate of the scale point. The value is a floating point number. 7927 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7928 * <br>2. Incorrect parameter types. 7929 * @syscap SystemCapability.Graphics.Drawing 7930 * @since 12 7931 */ 7932 /** 7933 * Post multiplies this matrix by a matrix that is derived from an identity matrix after it has been 7934 * scaled with the coefficient (sx, sy) at the scale point (px, py). 7935 * @param { number } sx - Scale coefficient along the X axis. If a negative number is passed in, 7936 * the matrix is mirrored around y = px before being scaled. The value is a floating point number. 7937 * @param { number } sy - Scale coefficient along the Y axis. If a negative number is passed in, 7938 * the matrix is mirrored around x = py before being scaled. The value is a floating point number. 7939 * @param { number } px - X coordinate of the scale point. The value is a floating point number. 7940 * @param { number } py - Y coordinate of the scale point. The value is a floating point number. 7941 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7942 * <br>2. Incorrect parameter types. 7943 * @syscap SystemCapability.Graphics.Drawing 7944 * @crossplatform 7945 * @since 20 7946 */ 7947 postScale(sx: number, sy: number, px: number, py: number): void; 7948 /** 7949 * Post multiplies this matrix by a matrix that is derived from an identity matrix after it has been translated by a given distance (dx, dy). 7950 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 7951 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 7952 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 7953 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 7954 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7955 * <br>2. Incorrect parameter types. 7956 * @syscap SystemCapability.Graphics.Drawing 7957 * @since 12 7958 */ 7959 /** 7960 * Post multiplies this matrix by a matrix that is derived from an identity matrix after it has been translated by a given distance (dx, dy). 7961 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 7962 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 7963 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 7964 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 7965 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7966 * <br>2. Incorrect parameter types. 7967 * @syscap SystemCapability.Graphics.Drawing 7968 * @crossplatform 7969 * @since 20 7970 */ 7971 postTranslate(dx: number, dy: number): void; 7972 7973 /** 7974 * Premultiplies this matrix by a matrix that is derived from an identity matrix after it has been rotated by a 7975 * given degree around the rotation point (px, py). 7976 * @param { number } degree - Angle to rotate, in degrees. A positive number indicates a clockwise rotation, 7977 * and a negative number indicates a counterclockwise rotation. The value is a floating point number. 7978 * @param { number } px - X coordinate of the rotation point. The value is a floating point number. 7979 * @param { number } py - Y coordinate of the rotation point. The value is a floating point number. 7980 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7981 * <br>2. Incorrect parameter types. 7982 * @syscap SystemCapability.Graphics.Drawing 7983 * @since 12 7984 */ 7985 /** 7986 * Premultiplies this matrix by a matrix that is derived from an identity matrix after it has been rotated by a 7987 * given degree around the rotation point (px, py). 7988 * @param { number } degree - Angle to rotate, in degrees. A positive number indicates a clockwise rotation, 7989 * and a negative number indicates a counterclockwise rotation. The value is a floating point number. 7990 * @param { number } px - X coordinate of the rotation point. The value is a floating point number. 7991 * @param { number } py - Y coordinate of the rotation point. The value is a floating point number. 7992 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 7993 * <br>2. Incorrect parameter types. 7994 * @syscap SystemCapability.Graphics.Drawing 7995 * @crossplatform 7996 * @since 20 7997 */ 7998 preRotate(degree: number, px: number, py: number): void; 7999 8000 /** 8001 * Sets matrix to matrix constructed from skewing by (kx, ky) about pivot point (px, py), multiplied by matrix. 8002 * This can be thought of as skewing relative to a pivot point after applying matrix. 8003 * @param { number } kx - Indicates the horizontal skew factor. 8004 * @param { number } ky - Indicates the vertical skew factor. 8005 * @param { number } px - Indicates the pivot on x-axis. 8006 * @param { number } py - Indicates the pivot on y-axis. 8007 * @syscap SystemCapability.Graphics.Drawing 8008 * @crossplatform 8009 * @since 20 8010 */ 8011 postSkew(kx: number, ky: number, px: number, py: number): void; 8012 8013 /** 8014 * Premultiplies this matrix by a matrix that is derived from an identity matrix after it has been scaled with the 8015 * coefficient (sx, sy) at the scale point (px, py). 8016 * @param { number } sx - Scale coefficient along the X axis. If a negative number is passed in, 8017 * the matrix is mirrored around y = px before being scaled. The value is a floating point number. 8018 * @param { number } sy - Scale coefficient along the Y axis. If a negative number is passed in, 8019 * the matrix is mirrored around x = py before being scaled. The value is a floating point number. 8020 * @param { number } px - X coordinate of the scale point. The value is a floating point number. 8021 * @param { number } py - Y coordinate of the scale point. The value is a floating point number. 8022 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8023 * <br>2. Incorrect parameter types. 8024 * @syscap SystemCapability.Graphics.Drawing 8025 * @since 12 8026 */ 8027 /** 8028 * Premultiplies this matrix by a matrix that is derived from an identity matrix after it has been scaled with the 8029 * coefficient (sx, sy) at the scale point (px, py). 8030 * @param { number } sx - Scale coefficient along the X axis. If a negative number is passed in, 8031 * the matrix is mirrored around y = px before being scaled. The value is a floating point number. 8032 * @param { number } sy - Scale coefficient along the Y axis. If a negative number is passed in, 8033 * the matrix is mirrored around x = py before being scaled. The value is a floating point number. 8034 * @param { number } px - X coordinate of the scale point. The value is a floating point number. 8035 * @param { number } py - Y coordinate of the scale point. The value is a floating point number. 8036 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8037 * <br>2. Incorrect parameter types. 8038 * @syscap SystemCapability.Graphics.Drawing 8039 * @crossplatform 8040 * @since 20 8041 */ 8042 preScale(sx: number, sy: number, px: number, py: number): void; 8043 /** 8044 * Premultiplies this matrix by a matrix that is derived from an identity matrix after it has been translated by a given distance (dx, dy). 8045 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 8046 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 8047 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 8048 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 8049 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8050 * <br>2. Incorrect parameter types. 8051 * @syscap SystemCapability.Graphics.Drawing 8052 * @since 12 8053 */ 8054 /** 8055 * Premultiplies this matrix by a matrix that is derived from an identity matrix after it has been translated by a given distance (dx, dy). 8056 * @param { number } dx - Horizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, 8057 * and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. 8058 * @param { number } dy - Vertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, 8059 * and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. 8060 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8061 * <br>2. Incorrect parameter types. 8062 * @syscap SystemCapability.Graphics.Drawing 8063 * @crossplatform 8064 * @since 20 8065 */ 8066 preTranslate(dx: number, dy: number): void; 8067 8068 /** 8069 * Sets matrix to matrix multiplied by matrix constructed from skewing by (kx, ky) about pivot point (px, py). 8070 * This can be thought of as scaling relative to a pivot point before applying matrix. 8071 * @param { number } kx - Indicates the horizontal skew factor. 8072 * @param { number } ky - Indicates the vertical skew factor. 8073 * @param { number } px - Indicates the pivot on x-axis. 8074 * @param { number } py - Indicates the pivot on y-axis. 8075 * @syscap SystemCapability.Graphics.Drawing 8076 * @crossplatform 8077 * @since 20 8078 */ 8079 preSkew(kx: number, ky: number, px: number, py: number): void; 8080 /** 8081 * Resets this matrix to an identity matrix. 8082 * @syscap SystemCapability.Graphics.Drawing 8083 * @since 12 8084 */ 8085 /** 8086 * Resets this matrix to an identity matrix. 8087 * @syscap SystemCapability.Graphics.Drawing 8088 * @crossplatform 8089 * @since 20 8090 * @arkts 1.1&1.2 8091 */ 8092 reset(): void; 8093 /** 8094 * Maps a source point array to a destination point array by means of matrix transformation. 8095 * @param { Array<common2D.Point> } src - Array of source points. 8096 * @returns { Array<common2D.Point> } Return mapped points array. 8097 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8098 * <br>2. Incorrect parameter types. 8099 * @syscap SystemCapability.Graphics.Drawing 8100 * @since 12 8101 */ 8102 /** 8103 * Maps a source point array to a destination point array by means of matrix transformation. 8104 * @param { Array<common2D.Point> } src - Array of source points. 8105 * @returns { Array<common2D.Point> } Return mapped points array. 8106 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8107 * <br>2. Incorrect parameter types. 8108 * @syscap SystemCapability.Graphics.Drawing 8109 * @crossplatform 8110 * @since 20 8111 */ 8112 mapPoints(src: Array<common2D.Point>): Array<common2D.Point>; 8113 8114 /** 8115 * Forms a circle by radius and maps it to a ellipse, returns the average radius of the ellipse. 8116 * The average radius is equal to the square root of the product of the major axis length and the minor axis length. 8117 * @param { number } radius - circle size to map. 8118 * @returns { number } Return average mapped radius. 8119 * @syscap SystemCapability.Graphics.Drawing 8120 * @crossplatform 8121 * @since 20 8122 */ 8123 mapRadius(radius: number): number; 8124 8125 /** 8126 * Obtains all element values of this matrix. 8127 * @returns { Array<number> } nine scalar values contained by Matrix. 8128 * @syscap SystemCapability.Graphics.Drawing 8129 * @since 12 8130 */ 8131 /** 8132 * Obtains all element values of this matrix. 8133 * @returns { Array<number> } nine scalar values contained by Matrix. 8134 * @syscap SystemCapability.Graphics.Drawing 8135 * @crossplatform 8136 * @since 20 8137 */ 8138 getAll(): Array<number>; 8139 /** 8140 * Sets the destination rectangle to the bounding rectangle of the shape obtained after transforming the source rectangle 8141 * with a matrix transformation. As shown in the figure below, the blue rectangle represents the source rectangle, 8142 * and the yellow rectangle is the shape obtained after a matrix transformation is applied to the source rectangle. 8143 * Since the edges of the yellow rectangle are not aligned with the coordinate axes, it cannot be represented by a rectangle object. 8144 * To address this issue, a destination rectangle (black rectangle) is defined as the bounding rectangle. 8145 * @param { common2D.Rect } dst - Rectangle object, which is used to store the bounding rectangle. 8146 * @param { common2D.Rect } src - Source rectangle. 8147 * @returns { boolean } Returns true if the mapped src is equal to the dst; returns false is not equal. 8148 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8149 * <br>2. Incorrect parameter types. 8150 * @syscap SystemCapability.Graphics.Drawing 8151 * @since 12 8152 */ 8153 /** 8154 * ets the destination rectangle to the bounding rectangle of the shape obtained after transforming the source rectangle 8155 * with a matrix transformation. As shown in the figure below, the blue rectangle represents the source rectangle, 8156 * and the yellow rectangle is the shape obtained after a matrix transformation is applied to the source rectangle. 8157 * Since the edges of the yellow rectangle are not aligned with the coordinate axes, it cannot be represented by a rectangle object. 8158 * To address this issue, a destination rectangle (black rectangle) is defined as the bounding rectangle. 8159 * @param { common2D.Rect } dst - Rectangle object, which is used to store the bounding rectangle. 8160 * @param { common2D.Rect } src - Source rectangle. 8161 * @returns { boolean } Returns true if the mapped src is equal to the dst; returns false is not equal. 8162 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8163 * <br>2. Incorrect parameter types. 8164 * @syscap SystemCapability.Graphics.Drawing 8165 * @crossplatform 8166 * @since 20 8167 */ 8168 mapRect(dst: common2D.Rect, src: common2D.Rect): boolean; 8169 /** 8170 * Sets this matrix to a transformation matrix that maps a source rectangle to a destination rectangle. 8171 * @param { common2D.Rect } src - Source rectangle. 8172 * @param { common2D.Rect } dst - Destination rectangle. 8173 * @param { ScaleToFit } scaleToFit - Mapping mode from the source rectangle to the target rectangle. 8174 * @returns { boolean } Check result. The value true means that the matrix can represent the mapping, and false means the opposite. 8175 * If either the width or the height of the source rectangle is less than or equal to 0, the API returns false 8176 * and sets the matrix to an identity matrix. If either the width or height of the destination rectangle is less than or equal to 0, 8177 * the API returns true and sets the matrix to a matrix with all values 0, except for a perspective scaling coefficient of 1. 8178 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8179 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8180 * @syscap SystemCapability.Graphics.Drawing 8181 * @since 12 8182 */ 8183 /** 8184 * Sets this matrix to a transformation matrix that maps a source rectangle to a destination rectangle. 8185 * @param { common2D.Rect } src - Source rectangle. 8186 * @param { common2D.Rect } dst - Destination rectangle. 8187 * @param { ScaleToFit } scaleToFit - Mapping mode from the source rectangle to the target rectangle. 8188 * @returns { boolean } Check result. The value true means that the matrix can represent the mapping, and false means the opposite. 8189 * If either the width or the height of the source rectangle is less than or equal to 0, the API returns false 8190 * and sets the matrix to an identity matrix. If either the width or height of the destination rectangle is less than or equal to 0, 8191 * the API returns true and sets the matrix to a matrix with all values 0, except for a perspective scaling coefficient of 1. 8192 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8193 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8194 * @syscap SystemCapability.Graphics.Drawing 8195 * @crossplatform 8196 * @since 20 8197 */ 8198 setRectToRect(src: common2D.Rect, dst: common2D.Rect, scaleToFit: ScaleToFit): boolean; 8199 /** 8200 * Sets this matrix to a transformation matrix that maps the source point array to the destination point array. 8201 * Both the number of source points and that of destination points must be in the range [0, 4]. 8202 * @param { Array<common2D.Point> } src - Array of source points. The array length must be the same as the value of count. 8203 * @param { Array<common2D.Point> } dst - Array of destination points. The array length must be the same as the value of count. 8204 * @param { number } count - Number of points in each array. The value is an integer. 8205 * @returns { boolean } Returns true if Matrix was constructed successfully 8206 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8207 * <br>2. Incorrect parameter types. 8208 * @syscap SystemCapability.Graphics.Drawing 8209 * @since 12 8210 */ 8211 /** 8212 * Sets this matrix to a transformation matrix that maps the source point array to the destination point array. 8213 * Both the number of source points and that of destination points must be in the range [0, 4]. 8214 * @param { Array<common2D.Point> } src - Array of source points. The array length must be the same as the value of count. 8215 * @param { Array<common2D.Point> } dst - Array of destination points. The array length must be the same as the value of count. 8216 * @param { number } count - Number of points in each array. The value is an integer. 8217 * @returns { boolean } Returns true if Matrix was constructed successfully 8218 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8219 * <br>2. Incorrect parameter types. 8220 * @syscap SystemCapability.Graphics.Drawing 8221 * @crossplatform 8222 * @since 20 8223 */ 8224 setPolyToPoly(src: Array<common2D.Point>, dst: Array<common2D.Point>, count: number): boolean; 8225 } 8226 8227 /** 8228 * Enumerates the modes of scaling a source rectangle into a destination rectangle. 8229 * @enum { number } 8230 * @syscap SystemCapability.Graphics.Drawing 8231 * @since 12 8232 */ 8233 /** 8234 * Enumerates the modes of scaling a source rectangle into a destination rectangle. 8235 * @enum { number } 8236 * @syscap SystemCapability.Graphics.Drawing 8237 * @crossplatform 8238 * @since 20 8239 */ 8240 enum ScaleToFit { 8241 /** 8242 * Scales the source rectangle to completely fill the destination rectangle, potentially changing the aspect ratio of the source rectangle. 8243 * @syscap SystemCapability.Graphics.Drawing 8244 * @since 12 8245 */ 8246 /** 8247 * Scales the source rectangle to completely fill the destination rectangle, potentially changing the aspect ratio of the source rectangle. 8248 * @syscap SystemCapability.Graphics.Drawing 8249 * @crossplatform 8250 * @since 20 8251 */ 8252 FILL_SCALE_TO_FIT = 0, 8253 8254 /** 8255 * Scales the source rectangle, preserving its aspect ratio, to align it to the upper left corner of the destination rectangle. 8256 * @syscap SystemCapability.Graphics.Drawing 8257 * @since 12 8258 */ 8259 /** 8260 * Scales the source rectangle, preserving its aspect ratio, to align it to the upper left corner of the destination rectangle. 8261 * @syscap SystemCapability.Graphics.Drawing 8262 * @crossplatform 8263 * @since 20 8264 */ 8265 START_SCALE_TO_FIT = 1, 8266 8267 /** 8268 * Scales the source rectangle, preserving its aspect ratio, to align it to the center of the destination rectangle. 8269 * @syscap SystemCapability.Graphics.Drawing 8270 * @since 12 8271 */ 8272 /** 8273 * Scales the source rectangle, preserving its aspect ratio, to align it to the center of the destination rectangle. 8274 * @syscap SystemCapability.Graphics.Drawing 8275 * @crossplatform 8276 * @since 20 8277 */ 8278 CENTER_SCALE_TO_FIT = 2, 8279 8280 /** 8281 * Scales the source rectangle, preserving its aspect ratio, to align it to the lower right corner of the destination rectangle. 8282 * @syscap SystemCapability.Graphics.Drawing 8283 * @since 12 8284 */ 8285 /** 8286 * Scales the source rectangle, preserving its aspect ratio, to align it to the lower right corner of the destination rectangle. 8287 * @syscap SystemCapability.Graphics.Drawing 8288 * @crossplatform 8289 * @since 20 8290 */ 8291 END_SCALE_TO_FIT = 3 8292 } 8293 8294 /** 8295 * Describes a region, which is used to describe the region where the shape can be drawn. 8296 * @syscap SystemCapability.Graphics.Drawing 8297 * @since 12 8298 */ 8299 /** 8300 * Describes a region, which is used to describe the region where the shape can be drawn. 8301 * @syscap SystemCapability.Graphics.Drawing 8302 * @crossplatform 8303 * @since 20 8304 * @arkts 1.1&1.2 8305 */ 8306 class Region { 8307 /** 8308 * Creates an empty region. 8309 * @syscap SystemCapability.Graphics.Drawing 8310 * @crossplatform 8311 * @since 20 8312 * @arkts 1.1&1.2 8313 */ 8314 constructor(); 8315 8316 /** 8317 * Creates a deep copy of the specified region object. 8318 * @param { Region } region - The region object to copy. 8319 * @syscap SystemCapability.Graphics.Drawing 8320 * @crossplatform 8321 * @since 20 8322 * @arkts 1.1&1.2 8323 */ 8324 constructor(region: Region); 8325 8326 /** 8327 * Creates a region with a rectangle. 8328 * @param { number } left - Indicates the left edge of the rectangle. 8329 * @param { number } top - Indicates the top edge of the rectangle. 8330 * @param { number } right - Indicates the right edge of the rectangle. 8331 * @param { number } bottom - Indicates the bottom edge of the rectangle. 8332 * @syscap SystemCapability.Graphics.Drawing 8333 * @crossplatform 8334 * @since 20 8335 * @arkts 1.1&1.2 8336 */ 8337 constructor(left: number, top: number, right: number, bottom: number); 8338 8339 /** 8340 * Query whether this region is equal to the other region. 8341 * @param { Region } other - Indicates the region object for comparasion. 8342 * @returns { boolean } Returns compare result. 8343 * @syscap SystemCapability.Graphics.Drawing 8344 * @crossplatform 8345 * @since 20 8346 */ 8347 isEqual(other: Region): boolean; 8348 8349 /** 8350 * Query whether the region contains multiple rectangles. 8351 * @returns { boolean } Returns true if the region contains more than one rectangle; 8352 * <br>returns false otherwise. 8353 * @syscap SystemCapability.Graphics.Drawing 8354 * @crossplatform 8355 * @since 20 8356 */ 8357 isComplex(): boolean; 8358 8359 /** 8360 * Query whether the region is empty . 8361 * @returns { boolean } Returns true if the region is empty; returns false otherwise. 8362 * @syscap SystemCapability.Graphics.Drawing 8363 * @crossplatform 8364 * @since 20 8365 */ 8366 isEmpty(): boolean; 8367 8368 /** 8369 * Gets the bounds of the region. 8370 * @returns { common2D.Rect } Returns Rect object. 8371 * @syscap SystemCapability.Graphics.Drawing 8372 * @crossplatform 8373 * @since 20 8374 */ 8375 getBounds(): common2D.Rect; 8376 8377 /** Gets the boundary of the region, which represents by a path. 8378 * Gets the bounds of the region. 8379 * @returns { Path } Returns Path object. 8380 * @syscap SystemCapability.Graphics.Drawing 8381 * @crossplatform 8382 * @since 20 8383 */ 8384 getBoundaryPath(): Path; 8385 8386 /** 8387 * Checks whether a point is contained in this region. 8388 * @param { number } x - X coordinate of the point. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8389 * @param { number } y - Y coordinate of the point. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8390 * @returns { boolean } Returns true if (x, y) is inside region; returns false otherwise. 8391 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8392 * <br>2. Incorrect parameter types. 8393 * @syscap SystemCapability.Graphics.Drawing 8394 * @since 12 8395 */ 8396 /** 8397 * Checks whether a point is contained in this region. 8398 * @param { number } x - X coordinate of the point. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8399 * @param { number } y - Y coordinate of the point. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8400 * @returns { boolean } Returns true if (x, y) is inside region; returns false otherwise. 8401 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8402 * <br>2. Incorrect parameter types. 8403 * @syscap SystemCapability.Graphics.Drawing 8404 * @crossplatform 8405 * @since 20 8406 */ 8407 isPointContained(x: number, y:number): boolean; 8408 8409 /** 8410 * Checks whether another region is contained in this region. 8411 * @param { Region } other - Region object. 8412 * @returns { boolean } Returns true if other region is completely inside the region object; 8413 * <br>returns false otherwise. 8414 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8415 * <br>2. Incorrect parameter types. 8416 * @syscap SystemCapability.Graphics.Drawing 8417 * @since 12 8418 */ 8419 /** 8420 * Checks whether another region is contained in this region. 8421 * @param { Region } other - Region object. 8422 * @returns { boolean } Returns true if other region is completely inside the region object; 8423 * <br>returns false otherwise. 8424 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8425 * <br>2. Incorrect parameter types. 8426 * @syscap SystemCapability.Graphics.Drawing 8427 * @crossplatform 8428 * @since 20 8429 */ 8430 isRegionContained(other: Region): boolean; 8431 8432 /** 8433 * Performs an operation on this region and another region, and stores the resulting region in this Region object. 8434 * @param { Region } region - Region object. 8435 * @param { RegionOp } regionOp - Operation mode of the region. 8436 * @returns { boolean } Returns true if replaced region is not empty; returns false otherwise. 8437 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8438 * <br>2. Incorrect parameter types. 8439 * @syscap SystemCapability.Graphics.Drawing 8440 * @since 12 8441 */ 8442 /** 8443 * Performs an operation on this region and another region, and stores the resulting region in this Region object. 8444 * @param { Region } region - Region object. 8445 * @param { RegionOp } regionOp - Operation mode of the region. 8446 * @returns { boolean } Returns true if replaced region is not empty; returns false otherwise. 8447 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8448 * <br>2. Incorrect parameter types. 8449 * @syscap SystemCapability.Graphics.Drawing 8450 * @crossplatform 8451 * @since 20 8452 */ 8453 op(region: Region, regionOp: RegionOp): boolean; 8454 8455 /** 8456 * Offsets the region by adding dx along the x-axis and dy along the y-axis. 8457 * @param { number } dx - Indicates the x coordinate of the point. The parameter must be an integer. 8458 * @param { number } dy - Indicates the y coordinate of the point. The parameter must be an integer. 8459 * @syscap SystemCapability.Graphics.Drawing 8460 * @crossplatform 8461 * @since 20 8462 */ 8463 offset(dx: number, dy: number): void; 8464 8465 /** 8466 * Checks whether a rectangle do not intersect with this region. Actually, 8467 * this API determines whether the rectangle does not intersect with the bounding rectangle of the region, and therefore the result may not be accurate. 8468 * @param { number } left - Left position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8469 * @param { number } top - Top position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8470 * @param { number } right - Right position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8471 * @param { number } bottom - Bottom position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8472 * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. 8473 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8474 * <br>2. Incorrect parameter types. 8475 * @syscap SystemCapability.Graphics.Drawing 8476 * @since 12 8477 */ 8478 /** 8479 * Checks whether a rectangle do not intersect with this region. Actually, 8480 * this API determines whether the rectangle does not intersect with the bounding rectangle of the region, and therefore the result may not be accurate. 8481 * @param { number } left - Left position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8482 * @param { number } top - Top position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8483 * @param { number } right - Right position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8484 * @param { number } bottom - Bottom position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8485 * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. 8486 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8487 * <br>2. Incorrect parameter types. 8488 * @syscap SystemCapability.Graphics.Drawing 8489 * @crossplatform 8490 * @since 20 8491 */ 8492 quickReject(left: number, top: number, right: number, bottom: number): boolean; 8493 8494 /** 8495 * Determines whether region is intersect with another. 8496 * @param { Region } region - Indicates the other region for comparasion. 8497 * @returns { boolean } Returns true if the region dose not intersect the other, or the region is empty; 8498 * <br>returns false otherwise. 8499 * @syscap SystemCapability.Graphics.Drawing 8500 * @crossplatform 8501 * @since 20 8502 */ 8503 quickRejectRegion(region: Region): boolean; 8504 8505 /** 8506 * Sets a region that matches the outline of a path within the cropping area. 8507 * @param { Path } path - Path object. 8508 * @param { Region } clip - Region object. 8509 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 8510 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8511 * <br>2. Incorrect parameter types. 8512 * @syscap SystemCapability.Graphics.Drawing 8513 * @since 12 8514 */ 8515 /** 8516 * Sets a region that matches the outline of a path within the cropping area. 8517 * @param { Path } path - Path object. 8518 * @param { Region } clip - Region object. 8519 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 8520 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8521 * <br>2. Incorrect parameter types. 8522 * @syscap SystemCapability.Graphics.Drawing 8523 * @crossplatform 8524 * @since 20 8525 */ 8526 setPath(path: Path, clip: Region): boolean; 8527 8528 /** 8529 * Sets a rectangle. 8530 * @param { number } left - Left position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8531 * @param { number } top - Top position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8532 * @param { number } right - Right position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8533 * @param { number } bottom - Bottom position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8534 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 8535 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8536 * <br>2. Incorrect parameter types. 8537 * @syscap SystemCapability.Graphics.Drawing 8538 * @since 12 8539 */ 8540 /** 8541 * Sets a rectangle. 8542 * @param { number } left - Left position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8543 * @param { number } top - Top position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8544 * @param { number } right - Right position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8545 * @param { number } bottom - Bottom position of the rectangle. The value must be an integer. If a decimal is passed in, the decimal part is rounded off. 8546 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 8547 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8548 * <br>2. Incorrect parameter types. 8549 * @syscap SystemCapability.Graphics.Drawing 8550 * @crossplatform 8551 * @since 20 8552 */ 8553 setRect(left: number, top: number, right: number, bottom: number): boolean; 8554 8555 /** 8556 * Sets the region to the specified region. 8557 * @param { Region } region - Region object. 8558 * @syscap SystemCapability.Graphics.Drawing 8559 * @crossplatform 8560 * @since 20 8561 */ 8562 setRegion(region: Region): void; 8563 8564 /** 8565 * Sets the region to empty. 8566 * @syscap SystemCapability.Graphics.Drawing 8567 * @crossplatform 8568 * @since 20 8569 */ 8570 setEmpty(): void; 8571 } 8572 8573 /** 8574 * Enumerates the operations for combining two regions. 8575 * @enum { number } 8576 * @syscap SystemCapability.Graphics.Drawing 8577 * @since 12 8578 */ 8579 /** 8580 * Enumerates the operations for combining two regions. 8581 * @enum { number } 8582 * @syscap SystemCapability.Graphics.Drawing 8583 * @crossplatform 8584 * @since 20 8585 * @arkts 1.1&1.2 8586 */ 8587 enum RegionOp { 8588 /** 8589 * Difference operation. 8590 * @syscap SystemCapability.Graphics.Drawing 8591 * @since 12 8592 */ 8593 /** 8594 * Difference operation. 8595 * @syscap SystemCapability.Graphics.Drawing 8596 * @crossplatform 8597 * @since 20 8598 * @arkts 1.1&1.2 8599 */ 8600 DIFFERENCE = 0, 8601 8602 /** 8603 * Intersect operation. 8604 * @syscap SystemCapability.Graphics.Drawing 8605 * @since 12 8606 */ 8607 /** 8608 * Intersect operation. 8609 * @syscap SystemCapability.Graphics.Drawing 8610 * @crossplatform 8611 * @since 20 8612 * @arkts 1.1&1.2 8613 */ 8614 INTERSECT = 1, 8615 8616 /** 8617 * Union operation. 8618 * @syscap SystemCapability.Graphics.Drawing 8619 * @since 12 8620 */ 8621 /** 8622 * Union operation. 8623 * @syscap SystemCapability.Graphics.Drawing 8624 * @crossplatform 8625 * @since 20 8626 * @arkts 1.1&1.2 8627 */ 8628 UNION = 2, 8629 8630 /** 8631 * Xor operation. 8632 * @syscap SystemCapability.Graphics.Drawing 8633 * @since 12 8634 */ 8635 /** 8636 * Xor operation. 8637 * @syscap SystemCapability.Graphics.Drawing 8638 * @crossplatform 8639 * @since 20 8640 * @arkts 1.1&1.2 8641 */ 8642 XOR = 3, 8643 8644 /** 8645 * Reverse difference operation. 8646 * @syscap SystemCapability.Graphics.Drawing 8647 * @since 12 8648 */ 8649 /** 8650 * Reverse difference operation. 8651 * @syscap SystemCapability.Graphics.Drawing 8652 * @crossplatform 8653 * @since 20 8654 * @arkts 1.1&1.2 8655 */ 8656 REVERSE_DIFFERENCE = 4, 8657 8658 /** 8659 * Replace operation. 8660 * @syscap SystemCapability.Graphics.Drawing 8661 * @since 12 8662 */ 8663 /** 8664 * Replace operation. 8665 * @syscap SystemCapability.Graphics.Drawing 8666 * @crossplatform 8667 * @since 20 8668 * @arkts 1.1&1.2 8669 */ 8670 REPLACE = 5 8671 } 8672 8673 /** 8674 * Enumerates the corner positions of a rounded rectangle. 8675 * 8676 * @enum { number } 8677 * @syscap SystemCapability.Graphics.Drawing 8678 * @since 12 8679 */ 8680 /** 8681 * Enumerates the corner positions of a rounded rectangle. 8682 * 8683 * @enum { number } 8684 * @syscap SystemCapability.Graphics.Drawing 8685 * @crossplatform 8686 * @since 20 8687 */ 8688 enum CornerPos { 8689 /** 8690 * Top left corner of the rounded rectangle. 8691 * @syscap SystemCapability.Graphics.Drawing 8692 * @since 12 8693 */ 8694 /** 8695 * Top left corner of the rounded rectangle. 8696 * @syscap SystemCapability.Graphics.Drawing 8697 * @crossplatform 8698 * @since 20 8699 */ 8700 TOP_LEFT_POS = 0, 8701 8702 /** 8703 * Top right corner of the rounded rectangle. 8704 * @syscap SystemCapability.Graphics.Drawing 8705 * @since 12 8706 */ 8707 /** 8708 * Top right corner of the rounded rectangle. 8709 * @syscap SystemCapability.Graphics.Drawing 8710 * @crossplatform 8711 * @since 20 8712 */ 8713 TOP_RIGHT_POS = 1, 8714 8715 /** 8716 * Bottom right corner of the rounded rectangle. 8717 * @syscap SystemCapability.Graphics.Drawing 8718 * @since 12 8719 */ 8720 /** 8721 * Bottom right corner of the rounded rectangle. 8722 * @syscap SystemCapability.Graphics.Drawing 8723 * @crossplatform 8724 * @since 20 8725 */ 8726 BOTTOM_RIGHT_POS = 2, 8727 8728 /** 8729 * Bottom left corner of the rounded rectangle. 8730 * @syscap SystemCapability.Graphics.Drawing 8731 * @since 12 8732 */ 8733 /** 8734 * Bottom left corner of the rounded rectangle. 8735 * @syscap SystemCapability.Graphics.Drawing 8736 * @crossplatform 8737 * @since 20 8738 */ 8739 BOTTOM_LEFT_POS = 3 8740 } 8741 8742 /** 8743 * Enumerates the constraints on the source rectangle. 8744 * It is used to specify whether to limit the sampling range within the source rectangle when drawing an image on a canvas. 8745 * 8746 * @enum { number } 8747 * @syscap SystemCapability.Graphics.Drawing 8748 * @since 12 8749 */ 8750 /** 8751 * Enumerates the constraints on the source rectangle. 8752 * It is used to specify whether to limit the sampling range within the source rectangle when drawing an image on a canvas. 8753 * 8754 * @enum { number } 8755 * @syscap SystemCapability.Graphics.Drawing 8756 * @crossplatform 8757 * @since 20 8758 */ 8759 enum SrcRectConstraint { 8760 8761 /** 8762 * The sampling range is strictly confined to the source rectangle, resulting in a slow sampling speed. 8763 * 8764 * @syscap SystemCapability.Graphics.Drawing 8765 * @since 12 8766 */ 8767 /** 8768 * The sampling range is strictly confined to the source rectangle, resulting in a slow sampling speed. 8769 * 8770 * @syscap SystemCapability.Graphics.Drawing 8771 * @crossplatform 8772 * @since 20 8773 */ 8774 STRICT = 0, 8775 8776 /** 8777 * The sampling range is not limited to the source rectangle and can extend beyond it, allowing for a high sampling speed. 8778 * 8779 * @syscap SystemCapability.Graphics.Drawing 8780 * @since 12 8781 */ 8782 /** 8783 * The sampling range is not limited to the source rectangle and can extend beyond it, allowing for a high sampling speed. 8784 * 8785 * @syscap SystemCapability.Graphics.Drawing 8786 * @crossplatform 8787 * @since 20 8788 */ 8789 FAST = 1 8790 } 8791 8792 /** 8793 * A utility class that provides only static methods to convert data structs defined in other modules and common2D. 8794 * 8795 * @syscap SystemCapability.Graphics.Drawing 8796 * @since 15 8797 */ 8798 /** 8799 * A utility class that provides only static methods to convert data structs defined in other modules and common2D. 8800 * 8801 * @syscap SystemCapability.Graphics.Drawing 8802 * @crossplatform 8803 * @since 20 8804 */ 8805 class Tool { 8806 /** 8807 * Converts a color value of the ResourceColor type to a common2D.Color object. 8808 * @param { ResourceColor } resourceColor - Color value of the ResourceColor type. (All four types of inputs are supported. 8809 * The following provides 13 example inputs.) The fourth type of Resource supports only the construction method $r('belonging.type.name'). 8810 * Ensure that the resource has been defined in the main/resources/base/element directory. (The types color, string, 8811 * and integer are available for the belonging app, whereas only the type color is available for the belonging sys.) 8812 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 8813 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8814 * <br>2. Incorrect parameter types. 8815 * @syscap SystemCapability.Graphics.Drawing 8816 * @since 15 8817 */ 8818 /** 8819 * Converts a color value of the ResourceColor type to a common2D.Color object. 8820 * @param { ResourceColor } resourceColor - Color value of the ResourceColor type. (All four types of inputs are supported. 8821 * The following provides 13 example inputs.) The fourth type of Resource supports only the construction method $r('belonging.type.name'). 8822 * Ensure that the resource has been defined in the main/resources/base/element directory. (The types color, string, 8823 * and integer are available for the belonging app, whereas only the type color is available for the belonging sys.) 8824 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 8825 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 8826 * <br>2. Incorrect parameter types. 8827 * @syscap SystemCapability.Graphics.Drawing 8828 * @crossplatform 8829 * @since 20 8830 */ 8831 static makeColorFromResourceColor(resourceColor: ResourceColor): common2D.Color; 8832 } 8833 8834 /** 8835 * This class offers a comprehensive set of operations to handle for common2D Rect object. 8836 * 8837 * @syscap SystemCapability.Graphics.Drawing 8838 * @crossplatform 8839 * @since 20 8840 */ 8841 class RectUtils { 8842 /** 8843 * Makes an uninitialized 2D rectangular object with zero dimensions and origin at (0, 0). 8844 * 8845 * @returns { common2D.Rect } - Returns an empty Rect object with all coordinates (left, top, right, bottom) set to 0. 8846 * @static 8847 * @syscap SystemCapability.Graphics.Drawing 8848 * @crossplatform 8849 * @since 20 8850 */ 8851 static makeEmpty() : common2D.Rect; 8852 8853 /** 8854 * Makes a 2D rectangular object from boundary coordinates. 8855 * @param { number } left - Indicates the X-coordinate of the left edge. 8856 * @param { number } top - Indicates the Y-coordinate of the top edge. 8857 * @param { number } right - Indicates the X-coordinate of the right edge. 8858 * @param { number } bottom - Indicates the Y-coordinate of the bottom edge. 8859 * @returns { common2D.Rect } - Returns an Rect object with the specific coordinates (left, top, right, bottom). 8860 * @static 8861 * @syscap SystemCapability.Graphics.Drawing 8862 * @crossplatform 8863 * @since 20 8864 */ 8865 static makeLtrb(left: number, top: number, right: number, bottom: number) : common2D.Rect; 8866 8867 /** 8868 * Makes a deep copy of a 2D rectangular object. 8869 * @param { common2D.Rect } src - Indicates the source rectangle to copy. 8870 * @returns { common2D.Rect } - Returns an Rect object has the same boundary coordinates with the source. 8871 * @static 8872 * @syscap SystemCapability.Graphics.Drawing 8873 * @crossplatform 8874 * @since 20 8875 */ 8876 static makeCopy(src: common2D.Rect) : common2D.Rect; 8877 8878 /** 8879 * Gets the width of a 2D rectangular object. 8880 * 8881 * @param { common2D.Rect } rect - Indicates the Rect object to query. 8882 * @returns { number } - Returns the width. 8883 * @static 8884 * @syscap SystemCapability.Graphics.Drawing 8885 * @crossplatform 8886 * @since 20 8887 */ 8888 static getWidth(rect: common2D.Rect): number; 8889 8890 /** 8891 * Gets the height of a 2D rectangular object. 8892 * 8893 * @param { common2D.Rect } rect - Indicates the Rect object to query. 8894 * @returns { number } - Returns the height. 8895 * @static 8896 * @syscap SystemCapability.Graphics.Drawing 8897 * @crossplatform 8898 * @since 20 8899 */ 8900 static getHeight(rect: common2D.Rect): number; 8901 8902 /** 8903 * Calculates the x-coordinate of the center point of the 2D rectangular object. 8904 * 8905 * @param { common2D.Rect } rect - Indicates the Rect object to query. 8906 * @returns { number } - Returns the center X coordinate. 8907 * @static 8908 * @syscap SystemCapability.Graphics.Drawing 8909 * @crossplatform 8910 * @since 20 8911 */ 8912 static centerX(rect: common2D.Rect): number; 8913 8914 /** 8915 * Calculates the y-coordinate of the center point of the 2D rectangular object. 8916 * 8917 * @param { common2D.Rect } rect - Indicates the Rect object to query. 8918 * @returns { number } - Returns the center Y coordinate. 8919 * @static 8920 * @syscap SystemCapability.Graphics.Drawing 8921 * @crossplatform 8922 * @since 20 8923 */ 8924 static centerY(rect: common2D.Rect): number; 8925 8926 /** 8927 * Checks if one 2D rectangular object fully contains another. 8928 * 8929 * @param { common2D.Rect } rect - The container Rect object. 8930 * @param { common2D.Rect } other - The Rect object to check for containment. 8931 * @returns { boolean } - Returns true if 'rect' fully contains 'other'; returns false otherwise. 8932 * @static 8933 * @syscap SystemCapability.Graphics.Drawing 8934 * @crossplatform 8935 * @since 20 8936 */ 8937 static contains(rect: common2D.Rect, other: common2D.Rect): boolean; 8938 8939 /** 8940 * Checks if one 2D rectangular object fully contains the specified boundary coordinates. 8941 * 8942 * @param { common2D.Rect } rect - The container Rect object. 8943 * @param { number } left - Indicates the left boundary of the target region. 8944 * @param { number } top - Indicates the top boundary of the target region. 8945 * @param { number } right - Indicates the right boundary of the target region. 8946 * @param { number } bottom - Indicates the bottom boundary of the target region. 8947 * @returns { boolean } - Returns true if 'rect' fully contains the specified boundary coordinates; returns false otherwise. 8948 * @static 8949 * @syscap SystemCapability.Graphics.Drawing 8950 * @crossplatform 8951 * @since 20 8952 */ 8953 static contains(rect: common2D.Rect, left: number, top: number, right: number, bottom: number): boolean; 8954 8955 /** 8956 * Checks if one 2D rectangular object contains a specific point. 8957 * 8958 * @param { common2D.Rect } rect - The container Rect object. 8959 * @param { number } x - Indicates the X-coordinate of the point to check. 8960 * @param { number } y - Indicates the Y-coordinate of the point to check. 8961 * @returns { boolean } - Returns true if 'rect' contains the specified point; returns false otherwise. 8962 * @static 8963 * @syscap SystemCapability.Graphics.Drawing 8964 * @crossplatform 8965 * @since 20 8966 */ 8967 static contains(rect: common2D.Rect, x: number, y: number): boolean; 8968 8969 /** 8970 * Modifies a 2D rectangular's boundaries by inward offsets. 8971 * 8972 * @param { common2D.Rect } rect - The Rect object to adjust. 8973 * @param { number } left - Indicates the amount to add from the left boundary. 8974 * @param { number } top - Indicates the amount to add from the top boundary. 8975 * @param { number } right - Indicates the amount to substract from the right boundary. 8976 * @param { number } bottom - Indicates the amount to substract from the bottom boundary. 8977 * @static 8978 * @syscap SystemCapability.Graphics.Drawing 8979 * @crossplatform 8980 * @since 20 8981 */ 8982 static inset(rect: common2D.Rect, left: number, top: number, right: number, bottom: number): void; 8983 8984 /** 8985 * Relpace a 2D rectangular object by the intersection of itself and another. 8986 * If the intersection is empty, nothing is done. 8987 * 8988 * @param { common2D.Rect } rect - Indicates the Rect object. 8989 * @param { common2D.Rect } other - Indicates the other Rect object. 8990 * @returns { boolean } - Returns true if have area in common and 'rect' will be replaced by the intersection; 8991 * returns false if the intersection is empty and 'rect' will not be modified. 8992 * @static 8993 * @syscap SystemCapability.Graphics.Drawing 8994 * @crossplatform 8995 * @since 20 8996 */ 8997 static intersect(rect: common2D.Rect, other: common2D.Rect): boolean; 8998 8999 /** 9000 * Checks if two 2D rectangular objects intersect. 9001 * 9002 * @param { common2D.Rect } rect - Indicates the Rect object. 9003 * @param { common2D.Rect } other - Indicates the other Rect object. 9004 * @returns { boolean } - Returns true if have area in common, otherwise return false. 9005 * @static 9006 * @syscap SystemCapability.Graphics.Drawing 9007 * @crossplatform 9008 * @since 20 9009 */ 9010 static isIntersect(rect: common2D.Rect, other: common2D.Rect): boolean; 9011 9012 /** 9013 * Sets a 2D rectangular object to the union of itself and another. 9014 * 9015 * @param { common2D.Rect } rect - Indicates the Rect object. 9016 * @param { common2D.Rect } other - Indicates the other Rect object. 9017 * @static 9018 * @syscap SystemCapability.Graphics.Drawing 9019 * @crossplatform 9020 * @since 20 9021 */ 9022 static union(rect: common2D.Rect, other: common2D.Rect): void; 9023 9024 /** 9025 * Checks if the 2D rectangular object is empty. 9026 * 9027 * @param { common2D.Rect } rect - Indicates the Rect object. 9028 * @returns { boolean } - Returns true if the rectangle is empty (left >= right or top >= bottom); 9029 * returns false otherwise. 9030 * @static 9031 * @syscap SystemCapability.Graphics.Drawing 9032 * @crossplatform 9033 * @since 20 9034 */ 9035 static isEmpty(rect: common2D.Rect): boolean; 9036 9037 /** 9038 * Offsets the 2D rectangular object by adding dx to its left and right coordinates, 9039 * and adding dy to its top and bottom coordinates. 9040 * 9041 * @param { common2D.Rect } rect - Indicates the Rect object. 9042 * @param { number } dx - Indicates the amount to add to the rectangle's left and right coordinates. 9043 * @param { number } dy - Indicates the amount to add to the rectangle's top and bottom coordinates. 9044 * @static 9045 * @syscap SystemCapability.Graphics.Drawing 9046 * @crossplatform 9047 * @since 20 9048 */ 9049 static offset(rect: common2D.Rect, dx: number, dy: number): void; 9050 9051 /** 9052 * Offsets the rectangle to a specific position and kepps the width and height unchanged. 9053 * 9054 * @param { common2D.Rect } rect - Indicates the Rect object. 9055 * @param { number } newLeft - Indicates the new left coordinates. 9056 * @param { number } newTop - Indicates the new top coordinates. 9057 * @static 9058 * @syscap SystemCapability.Graphics.Drawing 9059 * @crossplatform 9060 * @since 20 9061 */ 9062 static offsetTo(rect: common2D.Rect, newLeft: number, newTop: number): void; 9063 9064 /** 9065 * Sets the boundary coordinates of a 2D rectangular object with that of another. 9066 * @param { common2D.Rect } rect - Indicates the Rect object to be modified. 9067 * @param { common2D.Rect } other - Indicates the source rectangle to copy. 9068 * @static 9069 * @syscap SystemCapability.Graphics.Drawing 9070 * @crossplatform 9071 * @since 20 9072 */ 9073 static setRect(rect: common2D.Rect, other: common2D.Rect): void; 9074 9075 /** 9076 * Sets the boundary coordinates of a 2D rectangular object with that of specific value. 9077 * @param { common2D.Rect } rect - Indicates the Rect object to be modified. 9078 * @param { number } left - Indicates the X-coordinate of the left edge. 9079 * @param { number } top - Indicates the Y-coordinate of the top edge. 9080 * @param { number } right - Indicates the X-coordinate of the right edge. 9081 * @param { number } bottom - Indicates the Y-coordinate of the bottom edge. 9082 * @static 9083 * @syscap SystemCapability.Graphics.Drawing 9084 * @crossplatform 9085 * @since 20 9086 */ 9087 static setLtrb(rect: common2D.Rect, left: number, top: number, right: number, bottom: number): void; 9088 9089 /** 9090 * Sets the boundary coordinates of a 2D rectangular object to zero. 9091 * @param { common2D.Rect } rect - Indicates the Rect object to be modified. 9092 * @static 9093 * @syscap SystemCapability.Graphics.Drawing 9094 * @crossplatform 9095 * @since 20 9096 */ 9097 static setEmpty(rect: common2D.Rect): void; 9098 9099 /** 9100 * Normalizes the 2D rectangular object to ensuer validity. 9101 * Swaps the left and right if the left is greater than right; 9102 * and swaps top and bottom if the top is greater than bottom. 9103 * If the edges are already valid, then nothing is done. 9104 * 9105 * @param { common2D.Rect } rect - Indicates the Rect object. 9106 * @static 9107 * @syscap SystemCapability.Graphics.Drawing 9108 * @crossplatform 9109 * @since 20 9110 */ 9111 static sort(rect: common2D.Rect): void; 9112 9113 /** 9114 * Checks if the 2D rectangular object has the same coordinates value with another. 9115 * 9116 * @param { common2D.Rect } rect - Indicates the Rect object. 9117 * @param { common2D.Rect } other - Indicates the other Rect object for comparison. 9118 * @returns { boolean } Returns true if left, top, right and bottom of rect and other are equal; 9119 * returns false otherwise. 9120 * @static 9121 * @syscap SystemCapability.Graphics.Drawing 9122 * @crossplatform 9123 * @since 20 9124 */ 9125 static isEqual(rect: common2D.Rect, other: common2D.Rect): boolean; 9126 } 9127} 9128 9129export default drawing; 9130