1/* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkGraphics2D 19 */ 20 21import type image from './@ohos.multimedia.image'; 22import type common2D from './@ohos.graphics.common2D'; 23import { Resource } from './global/resource'; 24 25/** 26 * Provides functions such as 2D graphics rendering, text drawing, and image display. 27 * 28 * @namespace drawing 29 * @syscap SystemCapability.Graphics.Drawing 30 * @since 11 31 */ 32declare namespace drawing { 33 /** 34 * Enumerate blending modes for colors. 35 * Blend is a operation that use 4 components(red, green, blue, alpha) to generate 36 * a new color from two colors(source, destination). 37 * @enum { number } 38 * @syscap SystemCapability.Graphics.Drawing 39 * @since 11 40 */ 41 enum BlendMode { 42 /** 43 * Disable 4 regions(red, green, blue, alpha) 44 * @syscap SystemCapability.Graphics.Drawing 45 * @since 11 46 */ 47 CLEAR = 0, 48 /** 49 * Use components of the source 50 * @syscap SystemCapability.Graphics.Drawing 51 * @since 11 52 */ 53 SRC = 1, 54 /** 55 * Use components of the destination 56 * @syscap SystemCapability.Graphics.Drawing 57 * @since 11 58 */ 59 DST = 2, 60 /** 61 * The source is placed above the destination. 62 * @syscap SystemCapability.Graphics.Drawing 63 * @since 11 64 */ 65 SRC_OVER = 3, 66 /** 67 * The Destination is placed above the source. 68 * @syscap SystemCapability.Graphics.Drawing 69 * @since 11 70 */ 71 DST_OVER = 4, 72 /** 73 * Use source replaces the destination, and will not exceed the boundaries of the destination 74 * @syscap SystemCapability.Graphics.Drawing 75 * @since 11 76 */ 77 SRC_IN = 5, 78 /** 79 * Use destination, and will not exceed the boundaries of the source 80 * @syscap SystemCapability.Graphics.Drawing 81 * @since 11 82 */ 83 DST_IN = 6, 84 /** 85 * Source is use in outside of the boundaries of the destination. 86 * @syscap SystemCapability.Graphics.Drawing 87 * @since 11 88 */ 89 SRC_OUT = 7, 90 /** 91 * Destination is use in outside of the boundaries of the source. 92 * @syscap SystemCapability.Graphics.Drawing 93 * @since 11 94 */ 95 DST_OUT = 8, 96 /** 97 * Source which overlaps the destination will replaces the destination. 98 * @syscap SystemCapability.Graphics.Drawing 99 * @since 11 100 */ 101 SRC_ATOP = 9, 102 /** 103 * Destination which overlaps the source will replaces the source. 104 * @syscap SystemCapability.Graphics.Drawing 105 * @since 11 106 */ 107 DST_ATOP = 10, 108 /** 109 * Combine regions where source and destination do not overlap. 110 * @syscap SystemCapability.Graphics.Drawing 111 * @since 11 112 */ 113 XOR = 11, 114 /** 115 * The sum of the source and destination. 116 * @syscap SystemCapability.Graphics.Drawing 117 * @since 11 118 */ 119 PLUS = 12, 120 /** 121 * All components are multiplied. 122 * @syscap SystemCapability.Graphics.Drawing 123 * @since 11 124 */ 125 MODULATE = 13, 126 /** 127 * Multiply the complement values of the background and source color values, 128 * and then complement the result. 129 * @syscap SystemCapability.Graphics.Drawing 130 * @since 11 131 */ 132 SCREEN = 14, 133 /** 134 * Multiplies or screens the colors, depending on destination 135 * @syscap SystemCapability.Graphics.Drawing 136 * @since 11 137 */ 138 OVERLAY = 15, 139 /** 140 * Choose a darker background and source color. 141 * @syscap SystemCapability.Graphics.Drawing 142 * @since 11 143 */ 144 DARKEN = 16, 145 /** 146 * Choose a lighter background and source color. 147 * @syscap SystemCapability.Graphics.Drawing 148 * @since 11 149 */ 150 LIGHTEN = 17, 151 /** 152 * Brightens destination color to reflect the source color. 153 * @syscap SystemCapability.Graphics.Drawing 154 * @since 11 155 */ 156 COLOR_DODGE = 18, 157 /** 158 * Darkens destination color to reflect the source color. 159 * @syscap SystemCapability.Graphics.Drawing 160 * @since 11 161 */ 162 COLOR_BURN = 19, 163 /** 164 * Multiplies or screens the colors, depending on source 165 * @syscap SystemCapability.Graphics.Drawing 166 * @since 11 167 */ 168 HARD_LIGHT = 20, 169 /** 170 * Lightens or Darkens the colors, depending on the source. 171 * @syscap SystemCapability.Graphics.Drawing 172 * @since 11 173 */ 174 SOFT_LIGHT = 21, 175 /** 176 * Subtract the darker of the two colors from the brighter color. 177 * @syscap SystemCapability.Graphics.Drawing 178 * @since 11 179 */ 180 DIFFERENCE = 22, 181 /** 182 * Produces an effect similar to difference mode, but with lower contrast. 183 * @syscap SystemCapability.Graphics.Drawing 184 * @since 11 185 */ 186 EXCLUSION = 23, 187 /** 188 * Multiply the source color by the destination color and replace the destination. 189 * @syscap SystemCapability.Graphics.Drawing 190 * @since 11 191 */ 192 MULTIPLY = 24, 193 /** 194 * Use the hue of the source and the saturation and brightness of the destination. 195 * @syscap SystemCapability.Graphics.Drawing 196 * @since 11 197 */ 198 HUE = 25, 199 /** 200 * Use the saturation of the source and the hue and brightness of the destination. 201 * @syscap SystemCapability.Graphics.Drawing 202 * @since 11 203 */ 204 SATURATION = 26, 205 /** 206 * Use the hue and saturation of the source and the brightness of the destination. 207 * @syscap SystemCapability.Graphics.Drawing 208 * @since 11 209 */ 210 COLOR = 27, 211 /** 212 * Use the brightness of the source and the hue and saturation of the destination. 213 * @syscap SystemCapability.Graphics.Drawing 214 * @since 11 215 */ 216 LUMINOSITY = 28, 217 } 218 219 /** 220 * Enumerates direction for adding closed contours. 221 * @enum { number } 222 * @syscap SystemCapability.Graphics.Drawing 223 * @since 12 224 */ 225 enum PathDirection { 226 /** 227 * Clockwise direction for adding closed contours. 228 * @syscap SystemCapability.Graphics.Drawing 229 * @since 12 230 */ 231 CLOCKWISE = 0, 232 233 /** 234 * Counter-clockwise direction for adding closed contours. 235 * @syscap SystemCapability.Graphics.Drawing 236 * @since 12 237 */ 238 COUNTER_CLOCKWISE = 1, 239 } 240 241 /** 242 * Enumerates fill type of path. 243 * @enum { number } 244 * @syscap SystemCapability.Graphics.Drawing 245 * @since 12 246 */ 247 enum PathFillType { 248 /** 249 * Specifies that "inside" is computed by a non-zero sum of signed edge crossings. 250 * @syscap SystemCapability.Graphics.Drawing 251 * @since 12 252 */ 253 WINDING = 0, 254 255 /** 256 * Specifies that "inside" is computed by an odd number of edge crossings. 257 * @syscap SystemCapability.Graphics.Drawing 258 * @since 12 259 */ 260 EVEN_ODD = 1, 261 262 /** 263 * Same as winding, but draws outside of the path, rather than inside. 264 * @syscap SystemCapability.Graphics.Drawing 265 * @since 12 266 */ 267 INVERSE_WINDING = 2, 268 269 /** 270 * Same as evenOdd, but draws outside of the path, rather than inside. 271 * @syscap SystemCapability.Graphics.Drawing 272 * @since 12 273 */ 274 INVERSE_EVEN_ODD = 3, 275 } 276 277 /** 278 * Enumerate path measure flags for matrix. 279 * @enum { number } 280 * @syscap SystemCapability.Graphics.Drawing 281 * @since 12 282 */ 283 enum PathMeasureMatrixFlags { 284 /** 285 * Gets position. 286 * @syscap SystemCapability.Graphics.Drawing 287 * @since 12 288 */ 289 GET_POSITION_MATRIX = 0, 290 /** 291 * Gets tangent. 292 * @syscap SystemCapability.Graphics.Drawing 293 * @since 12 294 */ 295 GET_TANGENT_MATRIX = 1, 296 /** 297 * Gets both position and tangent. 298 * @syscap SystemCapability.Graphics.Drawing 299 * @since 12 300 */ 301 GET_POSITION_AND_TANGENT_MATRIX = 2, 302 } 303 304 /** 305 * Provides the definition of the roundRect. 306 * 307 * @syscap SystemCapability.Graphics.Drawing 308 * @since 12 309 */ 310 class RoundRect { 311 /** 312 * Creates a simple round rect with the same four corner radii. 313 * @param { common2D.Rect } rect - Indicates the Rect object. 314 * @param { number } xRadii - Indicates the corner radii on x-axis. 315 * @param { number } yRadii - Indicates the corner radii on y-axis. 316 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 317 * <br>2. Incorrect parameter types. 318 * @syscap SystemCapability.Graphics.Drawing 319 * @since 12 320 */ 321 constructor(rect: common2D.Rect, xRadii: number, yRadii: number); 322 323 /** 324 * Sets the radiusX and radiusY for a specific corner position. 325 * @param { CornerPos } pos - Indicates the corner radius position. 326 * @param { number } x - Indicates the corner radius on x-axis. 327 * @param { number } y - Indicates the corner radius on y-axis. 328 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 329 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 330 * @syscap SystemCapability.Graphics.Drawing 331 * @since 12 332 */ 333 setCorner(pos: CornerPos, x: number, y: number): void; 334 335 /** 336 * Gets a point with the values of x-axis and y-axis of the selected corner radius. 337 * @param { CornerPos } pos - Indicates the corner radius position. 338 * @returns { common2D.Point } Returns a point with the values of x-axis and y-axis of the corner radius. 339 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 340 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 341 * @syscap SystemCapability.Graphics.Drawing 342 * @since 12 343 */ 344 getCorner(pos: CornerPos): common2D.Point; 345 346 /** 347 * Translates round rect by (dx, dy). 348 * @param { number } dx - Indicates the offsets added to rect left and rect right. 349 * @param { number } dy - Indicates the offsets added to rect top and rect bottom. 350 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 351 * <br>2. Incorrect parameter types. 352 * @syscap SystemCapability.Graphics.Drawing 353 * @since 12 354 */ 355 offset(dx: number, dy: number): void; 356 } 357 358 /** 359 * Enumerates of operations when two paths are combined. 360 * @enum { number } 361 * @syscap SystemCapability.Graphics.Drawing 362 * @since 12 363 */ 364 enum PathOp { 365 /** 366 * Difference operation. 367 * @syscap SystemCapability.Graphics.Drawing 368 * @since 12 369 */ 370 DIFFERENCE = 0, 371 372 /** 373 * Intersect operation. 374 * @syscap SystemCapability.Graphics.Drawing 375 * @since 12 376 */ 377 INTERSECT = 1, 378 379 /** 380 * Union operation. 381 * @syscap SystemCapability.Graphics.Drawing 382 * @since 12 383 */ 384 UNION = 2, 385 386 /** 387 * Xor operation. 388 * @syscap SystemCapability.Graphics.Drawing 389 * @since 12 390 */ 391 XOR = 3, 392 393 /** 394 * Reverse difference operation. 395 * @syscap SystemCapability.Graphics.Drawing 396 * @since 12 397 */ 398 REVERSE_DIFFERENCE = 4, 399 } 400 401 /** 402 * Enumerates of types of operation for the path. 403 * @enum { number } 404 * @syscap SystemCapability.Graphics.Drawing 405 * @since 18 406 */ 407 enum PathIteratorVerb { 408 /** 409 * Move operation. 410 * @syscap SystemCapability.Graphics.Drawing 411 * @since 18 412 */ 413 MOVE = 0, 414 415 /** 416 * Line operation. 417 * @syscap SystemCapability.Graphics.Drawing 418 * @since 18 419 */ 420 LINE = 1, 421 422 /** 423 * Quad operation. 424 * @syscap SystemCapability.Graphics.Drawing 425 * @since 18 426 */ 427 QUAD = 2, 428 429 /** 430 * Conic operation. 431 * @syscap SystemCapability.Graphics.Drawing 432 * @since 18 433 */ 434 CONIC = 3, 435 436 /** 437 * Cubic operation. 438 * @syscap SystemCapability.Graphics.Drawing 439 * @since 18 440 */ 441 CUBIC = 4, 442 443 /** 444 * Close operation. 445 * @syscap SystemCapability.Graphics.Drawing 446 * @since 18 447 */ 448 CLOSE = 5, 449 450 /** 451 * There are no more operations in the path. 452 * @syscap SystemCapability.Graphics.Drawing 453 * @since 18 454 */ 455 DONE = CLOSE + 1, 456 } 457 458 /** 459 * Describes a pathIterator object. 460 * 461 * @syscap SystemCapability.Graphics.Drawing 462 * @since 18 463 */ 464 class PathIterator { 465 /** 466 * Creates a pathIterator with path. 467 * @param { Path } path - the path is used to create PathIterator. 468 * @syscap SystemCapability.Graphics.Drawing 469 * @since 18 470 */ 471 constructor(path: Path); 472 473 /** 474 * Get the next verb in this iterator's path, and fill entries in the point2D array 475 * with point data (if any) for that operation, the point2D array size must be 4 or more. 476 * The number of pairs of point data supplied in the resulting array depends on the PathIteratorVerb: 477 * <ul> 478 * <li>MOVE: 1 pair</li> 479 * <li>LINE: 2 pairs</li> 480 * <li>QUAD: 3 pairs</li> 481 * <li>CONIC: 3.5 pairs</li> 482 * <li>CUBIC: 4 pairs</li> 483 * <li>CLOSE: 0 pairs</li> 484 * <li>DONE: 0 pairs</li> 485 * </ul> 486 * @param { Array<common2D.Point> } points - Indicates the point array. 487 * @param { number } offset - Indicates the offset into the array where entries should be placed. The default value is 0. 488 * @returns { PathIteratorVerb } Returns the next verb in this iterator's path. 489 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 490 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 491 * @syscap SystemCapability.Graphics.Drawing 492 * @since 18 493 */ 494 next(points: Array<common2D.Point>, offset?: number): PathIteratorVerb; 495 496 /** 497 * Get the next verb in the iteration, or DONE if there are no more elements. 498 * @returns { PathIteratorVerb } Returns the next verb in the iteration. 499 * @syscap SystemCapability.Graphics.Drawing 500 * @since 18 501 */ 502 peek(): PathIteratorVerb; 503 504 /** 505 * Query whether there are more elements in the iterator. 506 * @returns { boolean } Returns true if there are more elements to be iterated through, false otherwise. 507 * @syscap SystemCapability.Graphics.Drawing 508 * @since 18 509 */ 510 hasNext(): boolean; 511 } 512 513 /** 514 * Describes a path object. 515 * 516 * @syscap SystemCapability.Graphics.Drawing 517 * @since 11 518 */ 519 class Path { 520 /** 521 * Creates a Path. 522 * @syscap SystemCapability.Graphics.Drawing 523 * @since 12 524 */ 525 constructor(); 526 527 /** 528 * Creates a Path from other path. 529 * @param { Path } path - the path to copy content from. 530 * @syscap SystemCapability.Graphics.Drawing 531 * @since 12 532 */ 533 constructor(path: Path); 534 535 /** 536 * Sets the start point of a path 537 * @param { number } x - Indicates the x coordinate of the start point. 538 * @param { number } y - Indicates the y coordinate of the start point. 539 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 540 * <br>2. Incorrect parameter types. 541 * @syscap SystemCapability.Graphics.Drawing 542 * @since 11 543 */ 544 moveTo(x: number, y: number): void; 545 546 /** 547 * Draws a line segment from the last point of a path to the target point. 548 * @param { number } x - Indicates the x coordinate of the target point. 549 * @param { number } y - Indicates the y coordinate of the target point. 550 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 551 * <br>2. Incorrect parameter types. 552 * @syscap SystemCapability.Graphics.Drawing 553 * @since 11 554 */ 555 lineTo(x: number, y: number): void; 556 557 /** 558 * This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, 559 * and then a start angle and a sweep angle are specified. 560 * The arc is a portion of the ellipse defined by the start angle and the sweep angle. 561 * By default, a line segment from the last point of the path to the start point of the arc is also added. 562 * @param { number } x1 - Indicates the x coordinate of the upper left corner of the rectangle. 563 * @param { number } y1 - Indicates the y coordinate of the upper left corner of the rectangle. 564 * @param { number } x2 - Indicates the x coordinate of the lower right corner of the rectangle. 565 * @param { number } y2 - Indicates the y coordinate of the lower right corner of the rectangle. 566 * @param { number } startDeg - Indicates the start angle, in degrees. 567 * @param { number } sweepDeg - Indicates the angle to sweep, in degrees. 568 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 569 * <br>2. Incorrect parameter types. 570 * @syscap SystemCapability.Graphics.Drawing 571 * @since 11 572 */ 573 arcTo(x1: number, y1: number, x2: number, y2: number, startDeg: number, sweepDeg: number): void; 574 575 /** 576 * Draws a quadratic Bezier curve from the last point of a path to the target point. 577 * @param { number } ctrlX - Indicates the x coordinate of the control point. 578 * @param { number } ctrlY - Indicates the y coordinate of the control point. 579 * @param { number } endX - Indicates the x coordinate of the target point. 580 * @param { number } endY - Indicates the y coordinate of the target point. 581 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 582 * <br>2. Incorrect parameter types. 583 * @syscap SystemCapability.Graphics.Drawing 584 * @since 11 585 */ 586 quadTo(ctrlX: number, ctrlY: number, endX: number, endY: number): void; 587 588 /** 589 * Draws a conic from the last point of a path to the target point. 590 * @param { number } ctrlX - Indicates the x coordinate of the control point. 591 * @param { number } ctrlY - Indicates the y coordinate of the control point. 592 * @param { number } endX - Indicates the x coordinate of the target point. 593 * @param { number } endY - Indicates the y coordinate of the target point. 594 * @param { number } weight - Indicates the weight of added conic. 595 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 596 * <br>2. Incorrect parameter types. 597 * @syscap SystemCapability.Graphics.Drawing 598 * @since 12 599 */ 600 conicTo(ctrlX: number, ctrlY: number, endX: number, endY: number, weight: number): void; 601 602 /** 603 * Draws a cubic Bezier curve from the last point of a path to the target point. 604 * @param { number } ctrlX1 - Indicates the x coordinate of the first control point. 605 * @param { number } ctrlY1 - Indicates the y coordinate of the first control point. 606 * @param { number } ctrlX2 - Indicates the x coordinate of the second control point. 607 * @param { number } ctrlY2 - Indicates the y coordinate of the second control point. 608 * @param { number } endX - Indicates the x coordinate of the target point. 609 * @param { number } endY - Indicates the y coordinate of the target point. 610 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 611 * <br>2. Incorrect parameter types. 612 * @syscap SystemCapability.Graphics.Drawing 613 * @since 11 614 */ 615 cubicTo(ctrlX1: number, ctrlY1: number, ctrlX2: number, ctrlY2: number, endX: number, endY: number): void; 616 617 /** 618 * Sets the relative starting point of a path. 619 * @param { number } dx - Indicates the x coordinate of the relative starting point. 620 * @param { number } dy - Indicates the y coordinate of the relative starting point. 621 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 622 * <br>2. Incorrect parameter types. 623 * @syscap SystemCapability.Graphics.Drawing 624 * @since 12 625 */ 626 rMoveTo(dx: number, dy: number): void; 627 628 /** 629 * Draws a line segment from the last point of a path to the relative target point. 630 * @param { number } dx - Indicates the x coordinate of the relative target point. 631 * @param { number } dy - Indicates the y coordinate of the relative target point. 632 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 633 * <br>2. Incorrect parameter types. 634 * @syscap SystemCapability.Graphics.Drawing 635 * @since 12 636 */ 637 rLineTo(dx: number, dy: number): void; 638 639 /** 640 * Draws a quadratic bezier curve from the last point of a path to the relative target point. 641 * @param { number } dx1 - Indicates the x coordinate of the relative control point. 642 * @param { number } dy1 - Indicates the y coordinate of the relative control point. 643 * @param { number } dx2 - Indicates the x coordinate of the relative target point. 644 * @param { number } dy2 - Indicates the y coordinate of the relative target point. 645 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 646 * <br>2. Incorrect parameter types. 647 * @syscap SystemCapability.Graphics.Drawing 648 * @since 12 649 */ 650 rQuadTo(dx1: number, dy1: number, dx2: number, dy2: number): void; 651 652 /** 653 * Draws a conic from the last point of a path to the relative target point. 654 * @param { number } ctrlX - Indicates the x coordinate of the relative control point. 655 * @param { number } ctrlY - Indicates the y coordinate of the relative control point. 656 * @param { number } endX - Indicates the x coordinate of the relative target point. 657 * @param { number } endY - Indicates the y coordinate of the relative target point. 658 * @param { number } weight - Indicates the weight of added conic. 659 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 660 * <br>2. Incorrect parameter types. 661 * @syscap SystemCapability.Graphics.Drawing 662 * @since 12 663 */ 664 rConicTo(ctrlX: number, ctrlY: number, endX: number, endY: number, weight: number): void; 665 666 /** 667 * Draws a cubic bezier curve from the last point of a path to the relative target point. 668 * @param { number } ctrlX1 - Indicates the x coordinate of the first relative control point. 669 * @param { number } ctrlY1 - Indicates the y coordinate of the first relative control point. 670 * @param { number } ctrlX2 - Indicates the x coordinate of the second relative control point. 671 * @param { number } ctrlY2 - Indicates the y coordinate of the second relative control point. 672 * @param { number } endX - Indicates the x coordinate of the relative target point. 673 * @param { number } endY - Indicates the y coordinate of the relative target point. 674 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 675 * <br>2. Incorrect parameter types. 676 * @syscap SystemCapability.Graphics.Drawing 677 * @since 12 678 */ 679 rCubicTo(ctrlX1: number, ctrlY1: number, ctrlX2: number, ctrlY2: number, endX: number, endY: number): void; 680 681 /** 682 * Adds contour created from point array, adding (count - 1) line segments. 683 * @param { Array<common2D.Point> } points - Indicates the point array. 684 * @param { boolean } close - Indicates Whether to add lines that connect the end and start. 685 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 686 * <br>2. Incorrect parameter types. 687 * @syscap SystemCapability.Graphics.Drawing 688 * @since 12 689 */ 690 addPolygon(points: Array<common2D.Point>, close: boolean): void; 691 692 /** 693 * Combines two paths. 694 * @param { Path } path - Indicates the Path object. 695 * @param { PathOp } pathOp - Indicates the operator to apply path. 696 * @returns { boolean } boolean - Returns true if constructed path is not empty; returns false otherwise. 697 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 698 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 699 * @syscap SystemCapability.Graphics.Drawing 700 * @since 12 701 */ 702 op(path: Path, pathOp: PathOp): boolean; 703 704 /** 705 * Appends arc to path, as the start of new contour. 706 * Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. 707 * @param { common2D.Rect } rect - The bounds of the arc is described by a rect. 708 * @param { number } startAngle - Indicates the starting angle of arc in degrees. 709 * @param { number } sweepAngle - Indicates the sweep, in degrees. Positive is clockwise. 710 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 711 * <br>2. Incorrect parameter types. 712 * @syscap SystemCapability.Graphics.Drawing 713 * @since 12 714 */ 715 addArc(rect: common2D.Rect, startAngle: number, sweepAngle: number): void; 716 717 /** 718 * Adds a circle to the path, and wound in the specified direction. 719 * @param { number } x - Indicates the x coordinate of the center of the circle. 720 * @param { number } y - Indicates the y coordinate of the center of the circle. 721 * @param { number } radius - Indicates the radius of the circle. 722 * @param { PathDirection } pathDirection - The default value is CLOCKWISE. 723 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 724 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 725 * @syscap SystemCapability.Graphics.Drawing 726 * @since 12 727 */ 728 addCircle(x: number, y: number, radius: number, pathDirection?: PathDirection): void; 729 730 /** 731 * Adds a oval to the path, defined by the rect, and wound in the specified direction. 732 * @param { common2D.Rect } rect - The bounds of the oval is described by a rect. 733 * @param { number } start - Indicates the index of initial point of ellipse. 734 * @param { PathDirection } pathDirection - The default value is CLOCKWISE. 735 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 736 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 737 * @syscap SystemCapability.Graphics.Drawing 738 * @since 12 739 */ 740 addOval(rect: common2D.Rect, start: number, pathDirection?: PathDirection): void; 741 742 /** 743 * Adds a new contour to the path, defined by the rect, and wound in the specified direction. 744 * @param { common2D.Rect } rect - Indicates the Rect object. 745 * @param { PathDirection } pathDirection - The default value is CLOCKWISE. 746 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 747 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 748 * @syscap SystemCapability.Graphics.Drawing 749 * @since 12 750 */ 751 addRect(rect: common2D.Rect, pathDirection?: PathDirection): void; 752 753 /** 754 * Adds a new contour to the path, defined by the round rect, and wound in the specified direction. 755 * @param { RoundRect } roundRect - Indicates the RoundRect object. 756 * @param { PathDirection } pathDirection - The default value is CLOCKWISE. 757 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 758 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 759 * @syscap SystemCapability.Graphics.Drawing 760 * @since 12 761 */ 762 addRoundRect(roundRect: RoundRect, pathDirection?: PathDirection): void; 763 764 /** 765 * Appends src path to path, transformed by matrix. 766 * @param { Path } path - Indicates the Path object. 767 * @param { Matrix | null } matrix - Indicates transform applied to path. The default value is null. 768 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 769 * <br>2. Incorrect parameter types. 770 * @syscap SystemCapability.Graphics.Drawing 771 * @since 12 772 */ 773 addPath(path: Path, matrix?: Matrix | null): void; 774 775 /** 776 * Path is replaced by transformed data. 777 * @param { Matrix } matrix - Indicates transform applied to path. 778 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 779 * <br>2. Incorrect parameter types. 780 * @syscap SystemCapability.Graphics.Drawing 781 * @since 12 782 */ 783 transform(matrix: Matrix): void; 784 785 /** 786 * Returns the status that point (x, y) is contained by path. 787 * @param { number } x - Indicates the x-axis value of containment test. 788 * @param { number } y - Indicates the y-axis value of containment test. 789 * @returns { boolean } Returns true if the point (x, y) is contained by path; returns false otherwise. 790 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 791 * <br>2. Incorrect parameter types. 792 * @syscap SystemCapability.Graphics.Drawing 793 * @since 12 794 */ 795 contains(x: number, y: number): boolean; 796 797 /** 798 * Sets fill type, the rule used to fill path. 799 * @param { PathFillType } pathFillType - Indicates the enum path fill type. 800 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 801 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 802 * @syscap SystemCapability.Graphics.Drawing 803 * @since 12 804 */ 805 setFillType(pathFillType: PathFillType): void; 806 807 /** 808 * Gets the smallest bounding box that contains the path. 809 * @returns { common2D.Rect } Rect object. 810 * @syscap SystemCapability.Graphics.Drawing 811 * @since 12 812 */ 813 getBounds(): common2D.Rect; 814 815 /** 816 * Closes a path. A line segment from the start point to the last point of the path is added. 817 * @syscap SystemCapability.Graphics.Drawing 818 * @since 11 819 */ 820 close(): void; 821 822 /** 823 * Offsets point array by (dx, dy). Path is replaced by offset data. 824 * @param { number } dx - Indicates offset added to dst path x-axis coordinates. 825 * @param { number } dy - Indicates offset added to dst path y-axis coordinates. 826 * @returns { Path } Returns a new Path object. 827 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 828 * <br>2. Incorrect parameter types. 829 * @syscap SystemCapability.Graphics.Drawing 830 * @since 12 831 */ 832 offset(dx: number, dy: number): Path; 833 834 /** 835 * Resets path data. 836 * @syscap SystemCapability.Graphics.Drawing 837 * @since 11 838 */ 839 reset(): void; 840 841 /** 842 * Get path length. 843 * @param { boolean } forceClosed - Whether to close the Path. 844 * @returns { number } Return path length. 845 * @syscap SystemCapability.Graphics.Drawing 846 * @since 12 847 */ 848 getLength(forceClosed: boolean): number; 849 850 /** 851 * Gets the position and tangent of the distance from the starting position of the path. 852 * 853 * @param { boolean } forceClosed - Whether to close the path. 854 * @param { number } distance - The distance from the start of the path, should be greater than 0 and less than 'GetLength()' 855 * @param { common2D.Point } position - Sets to the position of distance from the starting position of the path. 856 * @param { common2D.Point } tangent - Sets to the tangent of distance from the starting position of the path. 857 * @returns { boolean } - Returns true if succeeded, otherwise false. 858 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 859 * <br>2. Incorrect parameter types. 860 * @syscap SystemCapability.Graphics.Drawing 861 * @since 12 862 */ 863 getPositionAndTangent(forceClosed: boolean, distance: number, position: common2D.Point, tangent: common2D.Point): boolean; 864 865 /** 866 * Gets the path between the start and end points. 867 * 868 * @param { boolean } forceClosed - Whether to close the path. 869 * @param { number } start - The distance from the starting point of the segment to the starting point of the path. 870 * @param { number } stop - The distance from the end point of the segment to the starting point of the path. 871 * @param { boolean } startWithMoveTo - Whether the path obtained moveTo to the starting segment. 872 * @param { Path } dst - The path obtained. 873 * @returns { boolean } - Returns false if the segment is zero-length or start >= stop, else return true. 874 * @syscap SystemCapability.Graphics.Drawing 875 * @since 18 876 */ 877 getSegment(forceClosed: boolean, start: number, stop: number, startWithMoveTo: boolean, dst: Path): boolean; 878 879 /** 880 * Determines whether the current contour is closed. 881 * 882 * @returns { boolean } - Returns true if the current contour is closed, otherwise false. 883 * @syscap SystemCapability.Graphics.Drawing 884 * @since 12 885 */ 886 isClosed(): boolean; 887 888 /** 889 * Computes the corresponding matrix at the specified distance. 890 * 891 * @param { boolean } forceClosed - Whether to close the path. 892 * @param { number } distance - The distance from the start of the path. 893 * @param { Matrix } matrix - Indicates the pointer to an Matrix object. 894 * @param { PathMeasureMatrixFlags } flags - Indicates what should be returned in the matrix. 895 * @returns { boolean } - Returns false if there is no path, or a zero-length path was specified, in which case matrix is unchanged. 896 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 897 * @syscap SystemCapability.Graphics.Drawing 898 * @since 12 899 */ 900 getMatrix(forceClosed: boolean, distance: number, matrix: Matrix, flags: PathMeasureMatrixFlags): boolean; 901 902 /** 903 * Parses the SVG format string that describes the drawing path, and sets the path. 904 * 905 * @param { string } str - A string in SVG format that describes the drawing path. 906 * @returns { boolean } true if build succeeded, otherwise false. 907 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 908 * @syscap SystemCapability.Graphics.Drawing 909 * @since 12 910 */ 911 buildFromSvgString(str: string): boolean; 912 913 /** 914 * Get pathIterator from path. 915 * 916 * @returns { PathIterator } Indicates the pointer to an pathIterator object. 917 * @syscap SystemCapability.Graphics.Drawing 918 * @since 18 919 */ 920 getPathIterator(): PathIterator; 921 } 922 923 /** 924 * Enumerates of scale to fit flags, selects if an array of points are drawn as discrete points, 925 * as lines, or as an open polygon. 926 * @enum { number } 927 * @syscap SystemCapability.Graphics.Drawing 928 * @since 12 929 */ 930 enum PointMode { 931 /** 932 * Draws each point separately. 933 * @syscap SystemCapability.Graphics.Drawing 934 * @since 12 935 */ 936 POINTS = 0, 937 938 /** 939 * Draws each pair of points as a line segment. 940 * @syscap SystemCapability.Graphics.Drawing 941 * @since 12 942 */ 943 LINES = 1, 944 945 /** 946 * Draws the array of points as a open polygon. 947 * @syscap SystemCapability.Graphics.Drawing 948 * @since 12 949 */ 950 POLYGON = 2, 951 } 952 953 /** 954 * Enumerates storage filter mode. 955 * @enum { number } 956 * @syscap SystemCapability.Graphics.Drawing 957 * @since 12 958 */ 959 enum FilterMode { 960 /** 961 * Single sample point (nearest neighbor). 962 * @syscap SystemCapability.Graphics.Drawing 963 * @since 12 964 */ 965 FILTER_MODE_NEAREST = 0, 966 967 /** 968 * Interpolate between 2x2 sample points (bilinear interpolation). 969 * @syscap SystemCapability.Graphics.Drawing 970 * @since 12 971 */ 972 FILTER_MODE_LINEAR = 1, 973 } 974 975 /** 976 * Enumerates of shadow flags. 977 * @enum { number } 978 * @syscap SystemCapability.Graphics.Drawing 979 * @since 12 980 */ 981 enum ShadowFlag { 982 /** 983 * Use no shadow flags. 984 * @syscap SystemCapability.Graphics.Drawing 985 * @since 12 986 */ 987 NONE = 0, 988 989 /** 990 * The occluding object is transparent. 991 * @syscap SystemCapability.Graphics.Drawing 992 * @since 12 993 */ 994 TRANSPARENT_OCCLUDER = 1, 995 996 /** 997 * No need to analyze shadows. 998 * @syscap SystemCapability.Graphics.Drawing 999 * @since 12 1000 */ 1001 GEOMETRIC_ONLY = 2, 1002 1003 /** 1004 * Use all shadow flags. 1005 * @syscap SystemCapability.Graphics.Drawing 1006 * @since 12 1007 */ 1008 ALL = 3, 1009 } 1010 1011 /** 1012 * Provides an interface to the drawing, and samplingOptions used when sampling from the image. 1013 * @syscap SystemCapability.Graphics.Drawing 1014 * @since 12 1015 */ 1016 class SamplingOptions { 1017 /** 1018 * Constructor for the samplingOptions. 1019 * @syscap SystemCapability.Graphics.Drawing 1020 * @since 12 1021 */ 1022 constructor(); 1023 /** 1024 * Constructor for the samplingOptions with filter mode. 1025 * @param { FilterMode } filterMode - Storage filter mode. 1026 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1027 * <br>2. Incorrect parameter types. 1028 * @syscap SystemCapability.Graphics.Drawing 1029 * @since 12 1030 */ 1031 constructor(filterMode: FilterMode); 1032 } 1033 1034 /** 1035 * Provides an interface to the drawing, and how to clip and transform the drawing. 1036 * @syscap SystemCapability.Graphics.Drawing 1037 * @since 11 1038 */ 1039 class Canvas { 1040 /** 1041 * Constructor for the Canvas. 1042 * @param { image.PixelMap } pixelmap - PixelMap. 1043 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1044 * <br>2. Incorrect parameter types. 1045 * @syscap SystemCapability.Graphics.Drawing 1046 * @since 11 1047 */ 1048 constructor(pixelmap: image.PixelMap); 1049 1050 /** 1051 * If rectangle is stroked, use pen to stroke width describes the line thickness, 1052 * else use brush to fill the rectangle. 1053 * @param { common2D.Rect } rect - Rectangle to draw. 1054 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1055 * <br>2. Incorrect parameter types. 1056 * @syscap SystemCapability.Graphics.Drawing 1057 * @since 11 1058 */ 1059 drawRect(rect: common2D.Rect): void; 1060 1061 /** 1062 * If rectangle is stroked, use pen to stroke width describes the line thickness, 1063 * else use brush to fill the rectangle. 1064 * @param { number } left - Indicates the left position of the rectangle. 1065 * @param { number } top - Indicates the top position of the rectangle. 1066 * @param { number } right - Indicates the right position of the rectangle. 1067 * @param { number } bottom - Indicates the bottom position of the rectangle. 1068 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1069 * <br>2. Incorrect parameter types. 1070 * @syscap SystemCapability.Graphics.Drawing 1071 * @since 12 1072 */ 1073 drawRect(left: number, top: number, right: number, bottom: number): void; 1074 1075 /** 1076 * Draws a RoundRect. 1077 * @param { RoundRect } roundRect - Indicates the RectRound object. 1078 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1079 * <br>2. Incorrect parameter types. 1080 * @syscap SystemCapability.Graphics.Drawing 1081 * @since 12 1082 */ 1083 drawRoundRect(roundRect: RoundRect): void; 1084 1085 /** 1086 * Draws a nested RoundRect. 1087 * @param { RoundRect } outer - Indicates the outer RectRound object. 1088 * @param { RoundRect } inner - Indicates the inner RectRound object. 1089 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1090 * <br>2. Incorrect parameter types. 1091 * @syscap SystemCapability.Graphics.Drawing 1092 * @since 12 1093 */ 1094 drawNestedRoundRect(outer: RoundRect, inner: RoundRect): void; 1095 1096 /** 1097 * Fills clipped canvas area with brush. 1098 * @param { Brush } brush - Indicates the Brush object. 1099 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1100 * <br>2. Incorrect parameter types. 1101 * @syscap SystemCapability.Graphics.Drawing 1102 * @since 12 1103 */ 1104 drawBackground(brush: Brush): void; 1105 1106 /** 1107 * Draws an offset spot shadow and outlining ambient shadow for the given path with circular light. 1108 * @param { Path } path - Indicates the Path object. 1109 * @param { common2D.Point3d } planeParams - Represents z offset of the occluder from the canvas based on x and y. 1110 * @param { common2D.Point3d } devLightPos - Represents the position of the light relative to the canvas. 1111 * @param { number } lightRadius - The radius of the circular light. 1112 * @param { common2D.Color } ambientColor - Ambient shadow's color. 1113 * @param { common2D.Color } spotColor - Spot shadow's color. 1114 * @param { ShadowFlag } flag - Indicates the flag to control opaque occluder, shadow, and light position. 1115 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1116 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1117 * @syscap SystemCapability.Graphics.Drawing 1118 * @since 12 1119 */ 1120 drawShadow(path: Path, planeParams: common2D.Point3d, devLightPos: common2D.Point3d, lightRadius: number, 1121 ambientColor: common2D.Color, spotColor: common2D.Color, flag: ShadowFlag) : void; 1122 1123 /** 1124 * Draws an offset spot shadow and outlining ambient shadow for the given path with circular light. 1125 * In this function, the input of the parameter 'ambientColor' and 'spotColor' should be number 1126 * @param { Path } path - Indicates the Path object. 1127 * @param { common2D.Point3d } planeParams - Represents z offset of the occluder from the canvas based on x and y. 1128 * @param { common2D.Point3d } devLightPos - Represents the position of the light relative to the canvas. 1129 * @param { number } lightRadius - The radius of the circular light. 1130 * @param { common2D.Color | number } ambientColor - Ambient shadow's color represented by ARGB color of hexadecimal format. 1131 * @param { common2D.Color | number } spotColor - Spot shadow's color represented by ARGB color of hexadecimal format. 1132 * @param { ShadowFlag } flag - Indicates the flag to control opaque occluder, shadow, and light position. 1133 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1134 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1135 * @syscap SystemCapability.Graphics.Drawing 1136 * @since 18 1137 */ 1138 drawShadow(path: Path, planeParams: common2D.Point3d, devLightPos: common2D.Point3d, lightRadius: number, 1139 ambientColor: common2D.Color | number, spotColor: common2D.Color | number, flag: ShadowFlag) : void; 1140 1141 /** 1142 * If radius is zero or less, nothing is drawn. If circle is stroked, use pen to 1143 * stroke width describes the line thickness, else use brush to fill the circle. 1144 * @param { number } x - X coordinate of the circle center. 1145 * @param { number } y - Y coordinate of the circle center. 1146 * @param { number } radius - The radius of the circle must be greater than 0. 1147 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1148 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1149 * @syscap SystemCapability.Graphics.Drawing 1150 * @since 11 1151 */ 1152 drawCircle(x: number, y: number, radius: number): void; 1153 1154 /** 1155 * Draw a pixelmap, with the upper left corner at (left, top). 1156 * @param { image.PixelMap } pixelmap - PixelMap. 1157 * @param { number } left - Left side of image. 1158 * @param { number } top - Top side of image. 1159 * @throws { BusinessError } 401 - Parameter error. 1160 * @syscap SystemCapability.Graphics.Drawing 1161 * @since 11 1162 */ 1163 /** 1164 * Draw a pixelmap, with the upper left corner at (left, top). 1165 * @param { image.PixelMap } pixelmap - PixelMap. 1166 * @param { number } left - Left side of image. 1167 * @param { number } top - Top side of image. 1168 * @param { SamplingOptions } samplingOptions - SamplingOptions used to describe the sampling mode. 1169 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1170 * <br>2. Incorrect parameter types. 1171 * @syscap SystemCapability.Graphics.Drawing 1172 * @since 12 1173 */ 1174 drawImage(pixelmap: image.PixelMap, left: number, top: number, samplingOptions?: SamplingOptions): void; 1175 1176 /** 1177 * Divides the image into a grid by lattice. 1178 * Draws each seciont of the image onto the area of destination rectangle on canvas. 1179 * @param { image.PixelMap } pixelmap - The source image. 1180 * @param { Lattice } lattice - The area of source image. 1181 * @param { common2D.Rect } dstRect - The area of destination canvas. 1182 * @param { FilterMode } filterMode - Storage filter mode. 1183 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1184 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1185 * @syscap SystemCapability.Graphics.Drawing 1186 * @since 18 1187 */ 1188 drawImageLattice(pixelmap: image.PixelMap, lattice: Lattice, dstRect: common2D.Rect, 1189 filterMode: FilterMode): void; 1190 1191 /** 1192 * Divides the image into a grid with nine sections: four sides, four corners, and the center. 1193 * Draws the specified section of the image onto the canvas, corners are unmodified or scaled down if they exceed 1194 * the destination rectangle, center and four sides are scaled to fit remaining space. 1195 * @param { image.PixelMap } pixelmap - The source image. 1196 * @param { common2D.Rect } center - The rect used to divide the source image. 1197 * @param { common2D.Rect } dstRect - The area of destination rectangle on canvas. 1198 * @param { FilterMode } filterMode - Storage filter mode. 1199 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1200 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1201 * @syscap SystemCapability.Graphics.Drawing 1202 * @since 18 1203 */ 1204 drawImageNine(pixelmap: image.PixelMap, center: common2D.Rect, dstRect: common2D.Rect, 1205 filterMode: FilterMode): void; 1206 1207 /** 1208 * Draws the specified source image onto the canvas, 1209 * scaled and translated to the destination rectangle. 1210 * @param { image.PixelMap } pixelmap - The source image. 1211 * @param { common2D.Rect } dstRect - The area of destination canvas. 1212 * @param { SamplingOptions } samplingOptions - SamplingOptions used to describe the sampling mode. 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 drawImageRect(pixelmap: image.PixelMap, dstRect: common2D.Rect, samplingOptions?: SamplingOptions): void; 1219 1220 /** 1221 * Draws the specified source rectangle of the image onto the canvas, 1222 * scaled and translated to the destination rectangle. 1223 * @param { image.PixelMap } pixelmap - The source image. 1224 * @param { common2D.Rect } srcRect - The area of source image. 1225 * @param { common2D.Rect } dstRect - The area of destination canvas. 1226 * @param { SamplingOptions } samplingOptions - SamplingOptions used to describe the sampling mode. 1227 * @param { SrcRectConstraint } constraint - Constraint type. The default value is STRICT. 1228 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1229 * <br>2. Incorrect parameter types. 1230 * @syscap SystemCapability.Graphics.Drawing 1231 * @since 12 1232 */ 1233 drawImageRectWithSrc(pixelmap: image.PixelMap, srcRect: common2D.Rect, dstRect: common2D.Rect, 1234 samplingOptions?: SamplingOptions, constraint?: SrcRectConstraint): void; 1235 1236 /** 1237 * Fills clip with color color. Mode determines how ARGB is combined with destination. 1238 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 1239 * @param { BlendMode } blendMode - Used to combine source color and destination. The default value is SRC_OVER. 1240 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1241 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1242 * @syscap SystemCapability.Graphics.Drawing 1243 * @since 11 1244 */ 1245 drawColor(color: common2D.Color, blendMode?: BlendMode): void; 1246 1247 /** 1248 * Fills the clipped rectangle with the specified ARGB color. 1249 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 1250 * @param { number } red - Red channel of color. The range of red must be [0, 255]. 1251 * @param { number } green - Green channel of color. The range of green must be [0, 255]. 1252 * @param { number } blue - Blue channel of color. The range of blue must be [0, 255]. 1253 * @param { BlendMode } blendMode - Used to combine source color and destination. The default value is SRC_OVER. 1254 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1255 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1256 * @syscap SystemCapability.Graphics.Drawing 1257 * @since 12 1258 */ 1259 drawColor(alpha: number, red: number, green: number, blue: number, blendMode?: BlendMode): void; 1260 1261 /** 1262 * Fills clip with the specified ARGB color of hexadecimal format. 1263 * @param { number } color - Number must be ARGB color of hexadecimal format. 1264 * @param { BlendMode } blendMode - Used to combine source color and destination. The default value is SRC_OVER. 1265 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1266 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1267 * @syscap SystemCapability.Graphics.Drawing 1268 * @since 18 1269 */ 1270 drawColor(color: number, blendMode?: BlendMode): void; 1271 1272 /** 1273 * Draws an oval. 1274 * @param { common2D.Rect } oval - The bounds of the oval is described by a rect. 1275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1276 * <br>2. Incorrect parameter types. 1277 * @syscap SystemCapability.Graphics.Drawing 1278 * @since 12 1279 */ 1280 drawOval(oval: common2D.Rect): void; 1281 1282 /** 1283 * Draws an arc. 1284 * @param { common2D.Rect } arc - The bounds of the arc is described by a rect. 1285 * @param { number } startAngle - Indicates the startAngle of the arc. 1286 * @param { number } sweepAngle - Indicates the sweepAngle of the arc. 1287 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1288 * <br>2. Incorrect parameter types. 1289 * @syscap SystemCapability.Graphics.Drawing 1290 * @since 12 1291 */ 1292 drawArc(arc: common2D.Rect, startAngle: number, sweepAngle: number): void; 1293 1294 /** 1295 * Draws an arc with use center. 1296 * @param { common2D.Rect } arc - The bounds of the arc is described by a rect. 1297 * @param { number } startAngle - Indicates the startAngle of the arc. 1298 * @param { number } sweepAngle - Indicates the sweepAngle of the arc. 1299 * @param { boolean } useCenter - If true, include the center of the oval in the arc, and close it if it is being stroked. 1300 * @syscap SystemCapability.Graphics.Drawing 1301 * @since 18 1302 */ 1303 drawArcWithCenter(arc: common2D.Rect, startAngle: number, sweepAngle: number, useCenter: boolean): void; 1304 1305 /** 1306 * Draw a point. 1307 * @param { number } x - X coordinate position of the point. 1308 * @param { number } y - Y coordinate position of the point. 1309 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1310 * <br>2. Incorrect parameter types. 1311 * @syscap SystemCapability.Graphics.Drawing 1312 * @since 11 1313 */ 1314 drawPoint(x: number, y: number): void; 1315 1316 /** 1317 * Draws point array as separate point, line segment or open polygon according to given point mode. 1318 * @param { Array<common2D.Point> } points - Points array. 1319 * @param { PointMode } mode - Draws points enum method. The default value is POINTS. 1320 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1321 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1322 * @syscap SystemCapability.Graphics.Drawing 1323 * @since 12 1324 */ 1325 drawPoints(points: Array<common2D.Point>, mode?: PointMode): void; 1326 1327 /** 1328 * Draws a path. 1329 * @param { Path } path - Path to draw. 1330 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1331 * <br>2. Incorrect parameter types. 1332 * @syscap SystemCapability.Graphics.Drawing 1333 * @since 11 1334 */ 1335 drawPath(path: Path): void; 1336 1337 /** 1338 * Draws line segment from startPt to endPt. 1339 * @param { number } x0 - X coordinate of the start point of the line segment. 1340 * @param { number } y0 - Y coordinate of the start point of the line segment. 1341 * @param { number } x1 - X coordinate of the end point of the line segment. 1342 * @param { number } y1 - Y coordinate of the end point of the line segment. 1343 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1344 * <br>2. Incorrect parameter types. 1345 * @syscap SystemCapability.Graphics.Drawing 1346 * @since 11 1347 */ 1348 drawLine(x0: number, y0: number, x1: number, y1: number): void; 1349 1350 /** 1351 * Draws a single character. 1352 * @param { string } text - A string containing only a single character. 1353 * @param { Font } font - Font object. 1354 * @param { number } x - X coordinate of the single character start point. 1355 * @param { number } y - Y coordinate of the single character start point. 1356 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1357 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1358 * @syscap SystemCapability.Graphics.Drawing 1359 * @since 12 1360 */ 1361 drawSingleCharacter(text: string, font: Font, x: number, y: number): void; 1362 1363 /** 1364 * Draws a textBlob 1365 * @param { TextBlob } blob - TextBlob to draw. 1366 * @param { number } x - X coordinate of the text start point. 1367 * @param { number } y - Y coordinate of the text start point. 1368 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1369 * <br>2. Incorrect parameter types. 1370 * @syscap SystemCapability.Graphics.Drawing 1371 * @since 11 1372 */ 1373 drawTextBlob(blob: TextBlob, x: number, y: number): void; 1374 1375 /** 1376 * Draws the pixelmap base on the mesh which is evenly distributed across the pixelmap. 1377 * @param { image.PixelMap } pixelmap - The pixelmap to draw using the mesh. 1378 * @param { number } meshWidth - The number of columns in the mesh. 1379 * @param { number } meshHeight - The number of rows in the mesh. 1380 * @param { Array<number> } vertices - Array of vertices, specifying where the mesh should be drawn. 1381 * @param { number } vertOffset - Number of vert elements to skip before drawing. 1382 * @param { Array<number> } colors - Array of colors, specifying a color at each vertex. 1383 * @param { number } colorOffset - Number of color elements to skip before drawing. 1384 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1385 * <br>2. Incorrect parameter types. 1386 * @syscap SystemCapability.Graphics.Drawing 1387 * @since 12 1388 */ 1389 drawPixelMapMesh(pixelmap: image.PixelMap, meshWidth: number, meshHeight: number, 1390 vertices: Array<number>, vertOffset: number, colors: Array<number>, colorOffset: number): void; 1391 1392 /** 1393 * Draws a region. 1394 * @param { Region } region - Region object. 1395 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1396 * <br>2. Incorrect parameter types. 1397 * @syscap SystemCapability.Graphics.Drawing 1398 * @since 12 1399 */ 1400 drawRegion(region: Region): void; 1401 1402 /** 1403 * Set pen to a canvas. 1404 * @param { Pen } pen - object. 1405 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1406 * <br>2. Incorrect parameter types. 1407 * @syscap SystemCapability.Graphics.Drawing 1408 * @since 11 1409 */ 1410 attachPen(pen: Pen): void; 1411 1412 /** 1413 * Set brush to a canvas. 1414 * @param { Brush } brush - Object. 1415 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1416 * <br>2. Incorrect parameter types. 1417 * @syscap SystemCapability.Graphics.Drawing 1418 * @since 11 1419 */ 1420 attachBrush(brush: Brush): void; 1421 1422 /** 1423 * Unset pen to a canvas. 1424 * @syscap SystemCapability.Graphics.Drawing 1425 * @since 11 1426 */ 1427 detachPen(): void; 1428 1429 /** 1430 * Unset brush to a canvas. 1431 * @syscap SystemCapability.Graphics.Drawing 1432 * @since 11 1433 */ 1434 detachBrush(): void; 1435 1436 /** 1437 * Saves the current canvas status (canvas matrix) to the top of the stack. 1438 * @returns { number } Return the number of saved states. 1439 * @syscap SystemCapability.Graphics.Drawing 1440 * @since 12 1441 */ 1442 save(): number; 1443 1444 /** 1445 * Saves matrix and clip, and allocates a bitmap for subsequent drawing. 1446 * Calling restore discards changes to matrix and clip, and draws the bitmap. 1447 * @param { common2D.Rect | null} rect - Optional layer size. The default value is null. 1448 * @param { Brush | null} brush - Optional brush effect used to draw the layer. The default value is null. 1449 * @returns { number } Return the number of saved states before this call. 1450 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 1451 * @syscap SystemCapability.Graphics.Drawing 1452 * @since 12 1453 */ 1454 saveLayer(rect?: common2D.Rect | null, brush?: Brush | null): number; 1455 1456 /** 1457 * Clears a canvas by using a specified color. 1458 * @param { common2D.Color } color - Indicates the color, which is a 32-bit (ARGB) variable. 1459 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1460 * <br>2. Incorrect parameter types. 1461 * @syscap SystemCapability.Graphics.Drawing 1462 * @since 12 1463 */ 1464 clear(color: common2D.Color): void; 1465 1466 /** 1467 * Clears a canvas by using a specified color represented by ARGB color of hexadecimal format. 1468 * @param { common2D.Color | number } color - Number must be ARGB color of hexadecimal format. 1469 * @syscap SystemCapability.Graphics.Drawing 1470 * @since 18 1471 */ 1472 clear(color: common2D.Color | number): void; 1473 1474 /** 1475 * Restores the canvas status (canvas matrix) saved on the top of the stack. 1476 * @syscap SystemCapability.Graphics.Drawing 1477 * @since 12 1478 */ 1479 restore(): void; 1480 1481 /** 1482 * Restores the specific number of the canvas status (canvas matrix) saved in the stack. 1483 * @param { number } count - Depth of state stack to restore. 1484 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1485 * <br>2. Incorrect parameter types. 1486 * @syscap SystemCapability.Graphics.Drawing 1487 * @since 12 1488 */ 1489 restoreToCount(count: number): void; 1490 1491 /** 1492 * Gets the number of the canvas status (canvas matrix) saved in the stack. 1493 * @returns { number } Return represent depth of save state stack. 1494 * @syscap SystemCapability.Graphics.Drawing 1495 * @since 12 1496 */ 1497 getSaveCount(): number; 1498 1499 /** 1500 * Gets the width of a canvas. 1501 * @returns { number } Return the width of a canvas. 1502 * @syscap SystemCapability.Graphics.Drawing 1503 * @since 12 1504 */ 1505 getWidth(): number; 1506 1507 /** 1508 * Gets the height of a canvas. 1509 * @returns { number } Return the height of a canvas. 1510 * @syscap SystemCapability.Graphics.Drawing 1511 * @since 12 1512 */ 1513 getHeight(): number; 1514 1515 /** 1516 * Gets the bounds of clip of a canvas. 1517 * @returns { common2D.Rect } Rect object. 1518 * @syscap SystemCapability.Graphics.Drawing 1519 * @since 12 1520 */ 1521 getLocalClipBounds(): common2D.Rect; 1522 1523 /** 1524 * Gets a 3x3 matrix of the transform from local coordinates to 'device'. 1525 * @returns { Matrix } Matrix object. 1526 * @syscap SystemCapability.Graphics.Drawing 1527 * @since 12 1528 */ 1529 getTotalMatrix(): Matrix; 1530 1531 /** 1532 * Scales by sx on the x-axis and sy on the y-axis. 1533 * @param { number } sx - Indicates the amount to scale on x-axis. 1534 * @param { number } sy - Indicates the amount to scale on y-axis. 1535 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1536 * <br>2. Incorrect parameter types. 1537 * @syscap SystemCapability.Graphics.Drawing 1538 * @since 12 1539 */ 1540 scale(sx: number, sy: number): void; 1541 1542 /** 1543 * Skews by sx on the x-axis and sy on the y-axis. 1544 * @param { number } sx - Indicates the value skew transformation on x-axis. 1545 * @param { number } sy - Indicates the value skew transformation on y-axis. 1546 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1547 * <br>2. Incorrect parameter types. 1548 * @syscap SystemCapability.Graphics.Drawing 1549 * @since 12 1550 */ 1551 skew(sx: number, sy: number) : void; 1552 1553 /** 1554 * Rotates by degrees, positive degrees rotates clockwise. 1555 * @param { number } degrees - Indicates the amount to rotate, in degrees. 1556 * @param { number } sx - Indicates the x-axis value of the point to rotate about. 1557 * @param { number } sy - Indicates the y-axis value of the point to rotate about. 1558 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1559 * <br>2. Incorrect parameter types. 1560 * @syscap SystemCapability.Graphics.Drawing 1561 * @since 12 1562 */ 1563 rotate(degrees: number, sx: number, sy: number) : void; 1564 1565 /** 1566 * Translates by dx along the x-axis and dy along the y-axis. 1567 * @param { number } dx - Indicates the distance to translate on x-axis. 1568 * @param { number } dy - Indicates the distance to translate on y-axis. 1569 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1570 * <br>2. Incorrect parameter types. 1571 * @syscap SystemCapability.Graphics.Drawing 1572 * @since 12 1573 */ 1574 translate(dx: number, dy: number): void; 1575 1576 /** 1577 * Replaces the clipping area with the intersection or difference of the current clipping area and path, 1578 * and use a clipping edge that is aliased or anti-aliased. 1579 * @param { Path } path - To combine with clip. 1580 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1581 * @param { boolean } doAntiAlias - True if clip is to be anti-aliased. The default value is false. 1582 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1583 * <br>2. Incorrect parameter types. 1584 * @syscap SystemCapability.Graphics.Drawing 1585 * @since 12 1586 */ 1587 clipPath(path: Path, clipOp?: ClipOp, doAntiAlias?: boolean): void; 1588 1589 /** 1590 * Replaces the clipping area with the intersection or difference between the 1591 * current clipping area and Rect, and use a clipping edge that is aliased or anti-aliased. 1592 * @param { common2D.Rect } rect - To combine with clipping area. 1593 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1594 * @param { boolean } doAntiAlias - True if clip is to be anti-aliased. The default value is false. 1595 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1596 * <br>2. Incorrect parameter types. 1597 * @syscap SystemCapability.Graphics.Drawing 1598 * @since 12 1599 */ 1600 clipRect(rect: common2D.Rect, clipOp?: ClipOp, doAntiAlias?: boolean): void; 1601 1602 /** 1603 * Uses the passed matrix to transforming the geometry, then use existing matrix. 1604 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 1605 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1606 * <br>2. Incorrect parameter types. 1607 * @syscap SystemCapability.Graphics.Drawing 1608 * @since 12 1609 */ 1610 concatMatrix(matrix: Matrix): void; 1611 1612 /** 1613 * Replace the clipping area with the intersection or difference of the 1614 * current clipping area and Region, and use a clipping edge that is aliased or anti-aliased. 1615 * @param { Region } region - Region object. 1616 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1617 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1618 * <br>2. Incorrect parameter types. 1619 * @syscap SystemCapability.Graphics.Drawing 1620 * @since 12 1621 */ 1622 clipRegion(region: Region, clipOp?: ClipOp): void; 1623 1624 /** 1625 * Replaces the clipping area with the intersection or difference between the 1626 * current clipping area and RoundRect, and use a clipping edge that is aliased or anti-aliased. 1627 * @param { RoundRect } roundRect - To combine with clipping area. 1628 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1629 * @param { boolean } doAntiAlias - True if clip is to be anti-aliased. The default value is false. 1630 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1631 * <br>2. Incorrect parameter types. 1632 * @syscap SystemCapability.Graphics.Drawing 1633 * @since 12 1634 */ 1635 clipRoundRect(roundRect: RoundRect, clipOp?: ClipOp, doAntiAlias?: boolean): void; 1636 1637 /** 1638 * Checks whether the drawable area is empty. 1639 * @returns { boolean } Returns true if drawable area is empty. 1640 * @syscap SystemCapability.Graphics.Drawing 1641 * @since 12 1642 */ 1643 isClipEmpty(): boolean; 1644 1645 /** 1646 * Sets matrix of canvas. 1647 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 1648 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1649 * <br>2. Incorrect parameter types. 1650 * @syscap SystemCapability.Graphics.Drawing 1651 * @since 12 1652 */ 1653 setMatrix(matrix: Matrix): void; 1654 1655 /** 1656 * Sets matrix of canvas to the identity matrix. 1657 * @syscap SystemCapability.Graphics.Drawing 1658 * @since 12 1659 */ 1660 resetMatrix(): void; 1661 1662 /** 1663 * Determines whether path is intersect with current clip area. 1664 * @param { Path } path - Path to draw. 1665 * @returns { boolean } Returns true if path is not intersect; returns false otherwise. 1666 * @syscap SystemCapability.Graphics.Drawing 1667 * @since 18 1668 */ 1669 quickRejectPath(path: Path): boolean; 1670 1671 /** 1672 * Determines whether rect is intersect with current clip area. 1673 * @param { common2D.Rect } rect - Rectangle to determines. 1674 * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. 1675 * @syscap SystemCapability.Graphics.Drawing 1676 * @since 18 1677 */ 1678 quickRejectRect(rect: common2D.Rect): boolean; 1679 } 1680 1681 /** 1682 * Enumerates clip operations. 1683 * 1684 * @enum { number } 1685 * @syscap SystemCapability.Graphics.Drawing 1686 * @since 12 1687 */ 1688 enum ClipOp { 1689 /** 1690 * Clips with difference. 1691 * @syscap SystemCapability.Graphics.Drawing 1692 * @since 12 1693 */ 1694 DIFFERENCE = 0, 1695 /** 1696 * Clips with intersection. 1697 * @syscap SystemCapability.Graphics.Drawing 1698 * @since 12 1699 */ 1700 INTERSECT = 1, 1701 } 1702 1703 /** 1704 * Provide a description of the type and position of the text. 1705 * @typedef TextBlobRunBuffer 1706 * @syscap SystemCapability.Graphics.Drawing 1707 * @since 11 1708 */ 1709 interface TextBlobRunBuffer { 1710 /** 1711 * Text model. 1712 * @type { number } 1713 * @syscap SystemCapability.Graphics.Drawing 1714 * @since 11 1715 */ 1716 glyph: number; 1717 /** 1718 * X-coordinate of the text start point. 1719 * @type { number } 1720 * @syscap SystemCapability.Graphics.Drawing 1721 * @since 11 1722 */ 1723 positionX: number; 1724 /** 1725 * Y-coordinate of the text start point. 1726 * @type { number } 1727 * @syscap SystemCapability.Graphics.Drawing 1728 * @since 11 1729 */ 1730 positionY: number; 1731 } 1732 1733 /** 1734 * Encoding type of the description text. 1735 * 1736 * @enum { number } 1737 * @syscap SystemCapability.Graphics.Drawing 1738 * @since 11 1739 */ 1740 enum TextEncoding { 1741 /** 1742 * Use 1 byte to represent UTF-8 or ASCII 1743 * @syscap SystemCapability.Graphics.Drawing 1744 * @since 11 1745 */ 1746 TEXT_ENCODING_UTF8 = 0, 1747 /** 1748 * Use 2 bytes to represent most of unicode 1749 * @syscap SystemCapability.Graphics.Drawing 1750 * @since 11 1751 */ 1752 TEXT_ENCODING_UTF16 = 1, 1753 /** 1754 * Use 4 bytes to represent all unicode. 1755 * @syscap SystemCapability.Graphics.Drawing 1756 * @since 11 1757 */ 1758 TEXT_ENCODING_UTF32 = 2, 1759 /** 1760 * Use 2 bytes to represent the glyph index. 1761 * @syscap SystemCapability.Graphics.Drawing 1762 * @since 11 1763 */ 1764 TEXT_ENCODING_GLYPH_ID = 3, 1765 } 1766 1767 /** 1768 * Provide a description of the text 1769 * 1770 * class TextBlob 1771 * @syscap SystemCapability.Graphics.Drawing 1772 * @since 11 1773 */ 1774 class TextBlob { 1775 /** 1776 * Create a textblob from a string 1777 * @param { string } text - Drawn glyph content. 1778 * @param { Font } font - Specify text size, font, text scale, etc. 1779 * @param { TextEncoding } encoding - The default value is TEXT_ENCODING_UTF8. 1780 * @returns { TextBlob } TextBlob object. 1781 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1782 * <br>2. Incorrect parameter types. 1783 * @static 1784 * @syscap SystemCapability.Graphics.Drawing 1785 * @since 11 1786 */ 1787 static makeFromString(text: string, font: Font, encoding?: TextEncoding): TextBlob; 1788 1789 /** 1790 * Create a textblob from a string, each element of which is located at the given positions. 1791 * @param { string } text - Drawn glyph content. 1792 * @param { number } len - string length, value must equal to points length. 1793 * @param { common2D.Point[] } points - Position coordinates of a textblob elements. 1794 * @param { Font } font - Specify text size, font, text scale, etc. 1795 * @returns { TextBlob } TextBlob object. 1796 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1797 * <br>2. Incorrect parameter types. 1798 * @static 1799 * @syscap SystemCapability.Graphics.Drawing 1800 * @since 12 1801 */ 1802 static makeFromPosText(text: string, len: number, points: common2D.Point[], font: Font): TextBlob; 1803 1804 /** 1805 * Creating a textblob object based on RunBuffer information 1806 * @param { Array<TextBlobRunBuffer> } pos - The array of TextBlobRunBuffer. 1807 * @param { Font } font - Font used for this run. 1808 * @param { common2D.Rect } bounds - Optional run bounding box. The default value is null; 1809 * @returns { TextBlob } TextBlob object. 1810 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1811 * <br>2. Incorrect parameter types. 1812 * @static 1813 * @syscap SystemCapability.Graphics.Drawing 1814 * @since 11 1815 */ 1816 static makeFromRunBuffer(pos: Array<TextBlobRunBuffer>, font: Font, bounds?: common2D.Rect): TextBlob; 1817 1818 /** 1819 * Returns the bounding rectangle shape 1820 * @returns { common2D.Rect } Rect object. 1821 * @syscap SystemCapability.Graphics.Drawing 1822 * @since 11 1823 */ 1824 bounds(): common2D.Rect; 1825 1826 /** 1827 * Returns an unique identifier for a textblob. 1828 * @returns { number } Unique ID. 1829 * @syscap SystemCapability.Graphics.Drawing 1830 * @since 12 1831 */ 1832 uniqueID(): number; 1833 } 1834 1835 /** 1836 * The Typeface class specifies the typeface and intrinsic style of a font. 1837 * 1838 * @syscap SystemCapability.Graphics.Drawing 1839 * @since 11 1840 */ 1841 class Typeface { 1842 /** 1843 * Get the family name for this typeface. 1844 * @returns { string } Family name. 1845 * @syscap SystemCapability.Graphics.Drawing 1846 * @since 11 1847 */ 1848 getFamilyName(): string; 1849 1850 /** 1851 * Generate typeface from file. 1852 * @param { string } filePath - file path for typeface. 1853 * @returns { Typeface } Typeface. 1854 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1855 * <br>2. Incorrect parameter types. 1856 * @syscap SystemCapability.Graphics.Drawing 1857 * @since 12 1858 */ 1859 static makeFromFile(filePath: string): Typeface; 1860 1861 /** 1862 * Generate typeface from Rawfile. 1863 * @param { Resource } rawfile - RawFile for typeface. 1864 * @returns { Typeface } Typeface. 1865 * @syscap SystemCapability.Graphics.Drawing 1866 * @since 18 1867 */ 1868 static makeFromRawFile(rawfile: Resource): Typeface; 1869 } 1870 1871 /** 1872 * Enumerates text edging types. 1873 * 1874 * @enum { number } 1875 * @syscap SystemCapability.Graphics.Drawing 1876 * @since 12 1877 */ 1878 enum FontEdging { 1879 /** 1880 * Uses anti aliasing, default value. 1881 * @syscap SystemCapability.Graphics.Drawing 1882 * @since 12 1883 */ 1884 ALIAS = 0, 1885 1886 /** 1887 * Uses sub-pixel anti aliasing. 1888 * @syscap SystemCapability.Graphics.Drawing 1889 * @since 12 1890 */ 1891 ANTI_ALIAS = 1, 1892 1893 /** 1894 * Uses sub-pixel anti aliasing and enable sub-pixel localization. 1895 * @syscap SystemCapability.Graphics.Drawing 1896 * @since 12 1897 */ 1898 SUBPIXEL_ANTI_ALIAS = 2, 1899 } 1900 1901 /** 1902 * Enumerates text hinting types. 1903 * 1904 * @enum { number } 1905 * @syscap SystemCapability.Graphics.Drawing 1906 * @since 12 1907 */ 1908 enum FontHinting { 1909 /** 1910 * Not use text hinting. 1911 * @syscap SystemCapability.Graphics.Drawing 1912 * @since 12 1913 */ 1914 NONE = 0, 1915 1916 /** 1917 * Uses slight text hinting. 1918 * @syscap SystemCapability.Graphics.Drawing 1919 * @since 12 1920 */ 1921 SLIGHT = 1, 1922 1923 /** 1924 * Uses normal text hinting. 1925 * @syscap SystemCapability.Graphics.Drawing 1926 * @since 12 1927 */ 1928 NORMAL = 2, 1929 1930 /** 1931 * Uses full text hinting. 1932 * @syscap SystemCapability.Graphics.Drawing 1933 * @since 12 1934 */ 1935 FULL = 3, 1936 } 1937 1938 /** 1939 * Font controls options applied when drawing and measuring text. 1940 * 1941 * @syscap SystemCapability.Graphics.Drawing 1942 * @since 11 1943 */ 1944 class Font { 1945 /** 1946 * Requests, but does not require, that glyphs respect sub-pixel positioning. 1947 * @param { boolean } isSubpixel - Setting for sub-pixel positioning. 1948 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1949 * <br>2. Incorrect parameter types. 1950 * @syscap SystemCapability.Graphics.Drawing 1951 * @since 11 1952 */ 1953 enableSubpixel(isSubpixel: boolean): void; 1954 1955 /** 1956 * Increases stroke width when creating glyph bitmaps to approximate a bold typeface. 1957 * @param { boolean } isEmbolden - Setting for bold approximation. 1958 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1959 * <br>2. Incorrect parameter types. 1960 * @syscap SystemCapability.Graphics.Drawing 1961 * @since 11 1962 */ 1963 enableEmbolden(isEmbolden: boolean): void; 1964 1965 /** 1966 * Requests linearly scalable font and glyph metrics. 1967 * @param { boolean } isLinearMetrics - Setting for linearly scalable font and glyph metrics. 1968 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1969 * <br>2. Incorrect parameter types. 1970 * @syscap SystemCapability.Graphics.Drawing 1971 * @since 11 1972 */ 1973 enableLinearMetrics(isLinearMetrics: boolean): void; 1974 1975 /** 1976 * Sets text size in points. Has no effect if textSize is not greater than or equal to zero. 1977 * @param { number } textSize - Typographic height of text. The height of the text must be greater than 0. 1978 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1979 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1980 * @syscap SystemCapability.Graphics.Drawing 1981 * @since 11 1982 */ 1983 setSize(textSize: number): void; 1984 1985 /** 1986 * Obtains the text size. 1987 * @returns { number } Text size. 1988 * @syscap SystemCapability.Graphics.Drawing 1989 * @since 11 1990 */ 1991 getSize(): number; 1992 1993 /** 1994 * Sets Typeface to font. 1995 * @param { Typeface } typeface - Font and style used to draw text. 1996 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1997 * <br>2. Incorrect parameter types. 1998 * @syscap SystemCapability.Graphics.Drawing 1999 * @since 11 2000 */ 2001 setTypeface(typeface: Typeface): void; 2002 2003 /** 2004 * Get Typeface to font. 2005 * @returns { Typeface } Typeface. 2006 * @syscap SystemCapability.Graphics.Drawing 2007 * @since 11 2008 */ 2009 getTypeface(): Typeface; 2010 2011 /** 2012 * Get fontMetrics associated with typeface. 2013 * @returns { FontMetrics } The fontMetrics value returned to the caller. 2014 * @syscap SystemCapability.Graphics.Drawing 2015 * @since 11 2016 */ 2017 getMetrics(): FontMetrics; 2018 2019 /** 2020 * Measure a single character. 2021 * @param { string } text - A string containing only a single character. 2022 * @returns { number } The width of the single character. 2023 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2024 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2025 * @syscap SystemCapability.Graphics.Drawing 2026 * @since 12 2027 */ 2028 measureSingleCharacter(text: string): number; 2029 /** 2030 * Measure the width of text. 2031 * @param { string } text - Text Symbol Content. 2032 * @param { TextEncoding } encoding - Encoding format. 2033 * @returns { number } The width of text. 2034 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2035 * <br>2. Incorrect parameter types. 2036 * @syscap SystemCapability.Graphics.Drawing 2037 * @since 11 2038 */ 2039 measureText(text: string, encoding: TextEncoding): number; 2040 2041 /** 2042 * Sets text scale on x-axis to font. 2043 * @param { number } scaleX - Text scaleX. 2044 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2045 * <br>2. Incorrect parameter types. 2046 * @syscap SystemCapability.Graphics.Drawing 2047 * @since 12 2048 */ 2049 setScaleX(scaleX: number): void; 2050 2051 /** 2052 * Sets text skew on x-axis to font. 2053 * @param { number } skewX - Text skewX. 2054 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2055 * <br>2. Incorrect parameter types. 2056 * @syscap SystemCapability.Graphics.Drawing 2057 * @since 12 2058 */ 2059 setSkewX(skewX: number): void; 2060 2061 /** 2062 * Sets the edging effect to font. 2063 * @param { FontEdging } edging - Text edging. 2064 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2065 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2066 * @syscap SystemCapability.Graphics.Drawing 2067 * @since 12 2068 */ 2069 setEdging(edging: FontEdging): void; 2070 2071 /** 2072 * Sets the hinting pattern to font. 2073 * @param { FontHinting } hinting - Text hinting. 2074 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2075 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2076 * @syscap SystemCapability.Graphics.Drawing 2077 * @since 12 2078 */ 2079 setHinting(hinting: FontHinting): void; 2080 2081 /** 2082 * Calculates number of glyphs represented by text. 2083 * @param { string } text - Indicates the character storage encoded with text encoding. 2084 * @returns { number } Returns the count of text. 2085 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2086 * <br>2. Incorrect parameter types. 2087 * @syscap SystemCapability.Graphics.Drawing 2088 * @since 12 2089 */ 2090 countText(text: string): number; 2091 2092 /** 2093 * Sets whether the font baselines and pixels alignment when the transformation matrix is axis aligned. 2094 * @param { boolean } isBaselineSnap - Indicates whether the font baselines and pixels alignment. 2095 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2096 * <br>2. Incorrect parameter types. 2097 * @syscap SystemCapability.Graphics.Drawing 2098 * @since 12 2099 */ 2100 setBaselineSnap(isBaselineSnap: boolean): void; 2101 2102 /** 2103 * Gets whether the font baselines and pixels alignment when the transformation matrix is axis aligned. 2104 * @returns { boolean } Returns true if the font baselines and pixels alignment; returns false otherwise. 2105 * @syscap SystemCapability.Graphics.Drawing 2106 * @since 12 2107 */ 2108 isBaselineSnap(): boolean; 2109 2110 /** 2111 * Sets whether to use bitmaps instead of outlines in the object. 2112 * @param { boolean } isEmbeddedBitmaps - Indicates whether to use bitmaps instead of outlines. 2113 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2114 * <br>2. Incorrect parameter types. 2115 * @syscap SystemCapability.Graphics.Drawing 2116 * @since 12 2117 */ 2118 setEmbeddedBitmaps(isEmbeddedBitmaps: boolean): void; 2119 2120 /** 2121 * Gets whether to use bitmaps instead of outlines in the object. 2122 * @returns { boolean } if using bitmaps instead of outlines; returns false otherwise. 2123 * @syscap SystemCapability.Graphics.Drawing 2124 * @since 12 2125 */ 2126 isEmbeddedBitmaps(): boolean; 2127 2128 /** 2129 * Sets whether the font outline is automatically adjusted. 2130 * @param { boolean } isForceAutoHinting - Indicates whether the font outline is automatically adjusted. 2131 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2132 * <br>2. Incorrect parameter types. 2133 * @syscap SystemCapability.Graphics.Drawing 2134 * @since 12 2135 */ 2136 setForceAutoHinting(isForceAutoHinting: boolean): void; 2137 2138 /** 2139 * Gets whether the font outline is automatically adjusted. 2140 * @returns { boolean } Returns true if the font outline is automatically adjusted; returns false otherwise. 2141 * @syscap SystemCapability.Graphics.Drawing 2142 * @since 12 2143 */ 2144 isForceAutoHinting(): boolean; 2145 2146 /** 2147 * Retrieves the advance for each glyph in glyphs. 2148 * @param { Array<number> } glyphs - Array of glyph indices to be measured. 2149 * @returns { Array<number> } Returns the width of each character in a string. 2150 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2151 * <br>2. Incorrect parameter types. 2152 * @syscap SystemCapability.Graphics.Drawing 2153 * @since 12 2154 */ 2155 getWidths(glyphs: Array<number>): Array<number>; 2156 2157 /** 2158 * Gets storage for glyph indexes. 2159 * @param { string } text - Indicates the character storage encoded with text encoding. 2160 * @param { number } glyphCount - The number of glyph. The default value is the result of calling countText. 2161 * @returns { Array<number> } Returns the storage for glyph indices. 2162 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2163 * <br>2. Incorrect parameter types. 2164 * @syscap SystemCapability.Graphics.Drawing 2165 * @since 12 2166 */ 2167 textToGlyphs(text: string, glyphCount?: number): Array<number>; 2168 2169 /** 2170 * Returns true if glyphs may be drawn at sub-pixel offsets. 2171 * @returns { boolean } True if glyphs may be drawn at sub-pixel offsets. 2172 * @syscap SystemCapability.Graphics.Drawing 2173 * @since 12 2174 */ 2175 isSubpixel(): boolean; 2176 /** 2177 * Returns true if font and glyph metrics are requested to be linearly scalable. 2178 * @returns { boolean } True if font and glyph metrics are requested to be linearly scalable. 2179 * @syscap SystemCapability.Graphics.Drawing 2180 * @since 12 2181 */ 2182 isLinearMetrics(): boolean; 2183 /** 2184 * Returns text skew on x-axis. 2185 * @returns { number } Additional shear on x-axis relative to y-axis. 2186 * @syscap SystemCapability.Graphics.Drawing 2187 * @since 12 2188 */ 2189 getSkewX(): number; 2190 /** 2191 * Gets whether to increase the stroke width to approximate bold fonts. 2192 * @returns { boolean } Returns true to increase the stroke width to approximate bold fonts; 2193 * returns false otherwise. 2194 * @syscap SystemCapability.Graphics.Drawing 2195 * @since 12 2196 */ 2197 isEmbolden(): boolean; 2198 /** 2199 * Returns text scale on x-axis. 2200 * @returns { number } Text horizontal scale. 2201 * @syscap SystemCapability.Graphics.Drawing 2202 * @since 12 2203 */ 2204 getScaleX(): number; 2205 /** 2206 * Gets font hinting pattern. 2207 * @returns { FontHinting } Font hinting level. 2208 * @syscap SystemCapability.Graphics.Drawing 2209 * @since 12 2210 */ 2211 getHinting(): FontHinting; 2212 /** 2213 * Gets font edge pixels pattern. 2214 * @returns { FontEdging } Edge pixels pattern. 2215 * @syscap SystemCapability.Graphics.Drawing 2216 * @since 12 2217 */ 2218 getEdging(): FontEdging; 2219 /** 2220 * Create path object of specified Glyph. 2221 * @param { number } index - the index of Glyphs. 2222 * @returns { Path } The path object for specified glyph, undefined if not found. 2223 * Note: Path use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. 2224 * @syscap SystemCapability.Graphics.Drawing 2225 * @since 18 2226 */ 2227 createPathForGlyph(index: number): Path; 2228 /** 2229 * Retrieves the bounding rect for each glyph in glyphs. 2230 * @param { Array<number> } glyphs - Indicates the array of glyph indices to be measured. 2231 * @returns { Array<common2D.Rect> } Returns bounds for each glyph relative to (0, 0). 2232 * Note: 1. Rect use y-axis-goes-down system, y axis is inverted to the y-axis-goes-up system. 2233 * <br>2. Rect use two points(left-bottom & right-top) to describe the bound. 2234 * <br>3. The bound rect will be snap to integral boundaries. 2235 * @syscap SystemCapability.Graphics.Drawing 2236 * @since 18 2237 */ 2238 getBounds(glyphs: Array<number>): Array<common2D.Rect>; 2239 /** 2240 * Get path of text. 2241 * @param { string } text - Indicates the character storage encoded with text encoding. 2242 * @param { number } byteLength - Indicates the byte length of the text. 2243 * @param { number } x - Indicates X coordinate for the starting position of the text within the drawing area. 2244 * @param { number } y - Indicates Y coordinate for the starting position of the text within the drawing area. 2245 * @returns { Path } The path object for Glyph. 2246 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2247 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2248 * @syscap SystemCapability.Graphics.Drawing 2249 * @since 18 2250 */ 2251 getTextPath(text: string, byteLength: number, x: number, y: number): Path; 2252 2253 /** 2254 * Sets whether to follow the theme font. If the value is true, the theme font is used when typeface is not set. 2255 * @param { boolean } followed - Indicates whether to follow the theme font. 2256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2257 * <br>2. Incorrect parameter types. 2258 * @syscap SystemCapability.Graphics.Drawing 2259 * @since 15 2260 */ 2261 setThemeFontFollowed(followed: boolean): void; 2262 2263 /** 2264 * Gets whether to follow the theme font. 2265 * @returns { boolean } Returns true if font follows theme font; returns false otherwise. 2266 * @syscap SystemCapability.Graphics.Drawing 2267 * @since 15 2268 */ 2269 isThemeFontFollowed(): boolean; 2270 } 2271 2272 /** 2273 * Indicate when certain metrics are valid; the underline or strikeout metrics may be valid and zero. 2274 * Fonts with embedded bitmaps may not have valid underline or strikeout metrics. 2275 * @enum { number } 2276 * @syscap SystemCapability.Graphics.Drawing 2277 * @since 12 2278 */ 2279 enum FontMetricsFlags { 2280 /** 2281 * Set if underlineThickness of FontMetrics is valid. 2282 * @syscap SystemCapability.Graphics.Drawing 2283 * @since 12 2284 */ 2285 UNDERLINE_THICKNESS_VALID = 1 << 0, 2286 2287 /** 2288 * Set if underlinePosition of FontMetrics is valid. 2289 * @syscap SystemCapability.Graphics.Drawing 2290 * @since 12 2291 */ 2292 UNDERLINE_POSITION_VALID = 1 << 1, 2293 2294 /** 2295 * Set if strikethroughThickness of FontMetrics is valid. 2296 * @syscap SystemCapability.Graphics.Drawing 2297 * @since 12 2298 */ 2299 STRIKETHROUGH_THICKNESS_VALID = 1 << 2, 2300 2301 /** 2302 * Set if strikethroughPosition of FontMetrics is valid. 2303 * @syscap SystemCapability.Graphics.Drawing 2304 * @since 12 2305 */ 2306 STRIKETHROUGH_POSITION_VALID = 1 << 3, 2307 2308 /** 2309 * set if top, bottom, xMin, xMax of FontMetrics invalid. 2310 * @syscap SystemCapability.Graphics.Drawing 2311 * @since 12 2312 */ 2313 BOUNDS_INVALID = 1 << 4, 2314 } 2315 2316 /** 2317 * The metrics of an Font. 2318 * @typedef FontMetrics 2319 * @syscap SystemCapability.Graphics.Drawing 2320 * @since 11 2321 */ 2322 interface FontMetrics { 2323 /** 2324 * Indicating which metrics are valid. 2325 * @type { ?FontMetricsFlags } 2326 * @syscap SystemCapability.Graphics.Drawing 2327 * @since 12 2328 */ 2329 flags?: FontMetricsFlags; 2330 2331 /** 2332 * Maximum range above the glyph bounding box. 2333 * @type { number } 2334 * @syscap SystemCapability.Graphics.Drawing 2335 * @since 11 2336 */ 2337 top: number; 2338 /** 2339 * Distance Retained Above Baseline. 2340 * @type { number } 2341 * @syscap SystemCapability.Graphics.Drawing 2342 * @since 11 2343 */ 2344 ascent: number; 2345 /** 2346 * The distance that remains below the baseline. 2347 * @type { number } 2348 * @syscap SystemCapability.Graphics.Drawing 2349 * @since 11 2350 */ 2351 descent: number; 2352 /** 2353 * Maximum range below the glyph bounding box. 2354 * @type { number } 2355 * @syscap SystemCapability.Graphics.Drawing 2356 * @since 11 2357 */ 2358 bottom: number; 2359 /** 2360 * Line Spacing. 2361 * @type { number } 2362 * @syscap SystemCapability.Graphics.Drawing 2363 * @since 11 2364 */ 2365 leading: number; 2366 /** 2367 * Average character width, zero if unknown. 2368 * @type { ?number } 2369 * @syscap SystemCapability.Graphics.Drawing 2370 * @since 12 2371 */ 2372 avgCharWidth?: number; 2373 2374 /** 2375 * Maximum character width, zero if unknown. 2376 * @type { ?number } 2377 * @syscap SystemCapability.Graphics.Drawing 2378 * @since 12 2379 */ 2380 maxCharWidth?: number; 2381 2382 /** 2383 * Greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with variable fonts. 2384 * @type { ?number } 2385 * @syscap SystemCapability.Graphics.Drawing 2386 * @since 12 2387 */ 2388 xMin?: number; 2389 2390 /** 2391 * Greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with variable fonts. 2392 * @type { ?number } 2393 * @syscap SystemCapability.Graphics.Drawing 2394 * @since 12 2395 */ 2396 xMax?: number; 2397 2398 /** 2399 * Height of lower-case 'x', zero if unknown, typically negative. 2400 * @type { ?number } 2401 * @syscap SystemCapability.Graphics.Drawing 2402 * @since 12 2403 */ 2404 xHeight?: number; 2405 2406 /** 2407 * Height of an upper-case letter, zero if unknown, typically negative. 2408 * @type { ?number } 2409 * @syscap SystemCapability.Graphics.Drawing 2410 * @since 12 2411 */ 2412 capHeight?: number; 2413 2414 /** 2415 * Underline thickness. 2416 * @type { ?number } 2417 * @syscap SystemCapability.Graphics.Drawing 2418 * @since 12 2419 */ 2420 underlineThickness?: number; 2421 2422 /** 2423 * Distance from baseline to top of stroke, typically positive. 2424 * @type { ?number } 2425 * @syscap SystemCapability.Graphics.Drawing 2426 * @since 12 2427 */ 2428 underlinePosition?: number; 2429 2430 /** 2431 * Strikethrough thickness. 2432 * @type { ?number } 2433 * @syscap SystemCapability.Graphics.Drawing 2434 * @since 12 2435 */ 2436 strikethroughThickness?: number; 2437 2438 /** 2439 * Distance from baseline to bottom of stroke, typically negative. 2440 * @type { ?number } 2441 * @syscap SystemCapability.Graphics.Drawing 2442 * @since 12 2443 */ 2444 strikethroughPosition?: number; 2445 } 2446 2447 /** 2448 * Lattice is the class for dividing an image into grids. 2449 * @syscap SystemCapability.Graphics.Drawing 2450 * @since 12 2451 */ 2452 class Lattice { 2453 /** 2454 * Divide an image into a rectangular grid. Grid entries on even columns and even rows are fixed; 2455 * these entries are always drawn at their original size if the destination is large enough. If the destination 2456 * side is too small to hold the fixed entries, all fixed entries are scaled down to fit. 2457 * The grid entries not on even columns and rows are scaled to fit the remaining space, if any. 2458 * @param { Array<number> } xDivs - X coordinate of values used to divide the image. 2459 * @param { Array<number> } yDivs - Y coordinate of values used to divide the image. 2460 * @param { number } fXCount - Number of x coordinates. Must be >= 0. 2461 * @param { number } fYCount - Number of y coordinates. Must be >= 0. 2462 * @param { common2D.Rect | null } fBounds - Source bounds to draw from. The default value is null. 2463 * @param { Array<RectType> | null } fRectTypes - Array of fill types. The default value is null. 2464 * @param { Array<common2D.Color> | null } fColors - Array of colors. The default value is null. 2465 * @returns { Lattice } Lattice object. 2466 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2467 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2468 * @static 2469 * @syscap SystemCapability.Graphics.Drawing 2470 * @since 12 2471 */ 2472 static createImageLattice(xDivs: Array<number>, yDivs: Array<number>, fXCount: number, fYCount: number, 2473 fBounds?: common2D.Rect | null, fRectTypes?: Array<RectType> | null, fColors?: Array<common2D.Color> | null): Lattice; 2474 2475 /** 2476 * Divide an image into a rectangular grid. Grid entries on even columns and even rows are fixed; 2477 * these entries are always drawn at their original size if the destination is large enough. If the destination 2478 * side is too small to hold the fixed entries, all fixed entries are scaled down to fit. 2479 * The grid entries not on even columns and rows are scaled to fit the remaining space, if any. 2480 * @param { Array<number> } xDivs - X coordinate of values used to divide the image. 2481 * @param { Array<number> } yDivs - Y coordinate of values used to divide the image. 2482 * @param { number } fXCount - Number of x coordinates. Must be >= 0. 2483 * @param { number } fYCount - Number of y coordinates. Must be >= 0. 2484 * @param { common2D.Rect | null } fBounds - Source bounds to draw from. The default value is null. 2485 * @param { Array<RectType> | null } fRectTypes - Array of fill types. The default value is null. 2486 * @param { Array<number> | null } fColors - Array of colors represented by ARGB color of hexadecimal format. The default value is null. 2487 * @returns { Lattice } Lattice object. 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 * @static 2491 * @syscap SystemCapability.Graphics.Drawing 2492 * @since 18 2493 */ 2494 static createImageLattice(xDivs: Array<number>, yDivs: Array<number>, fXCount: number, fYCount: number, 2495 fBounds?: common2D.Rect | null, fRectTypes?: Array<RectType> | null, fColors?: Array<number> | null): Lattice; 2496 } 2497 2498 /** 2499 * Enumerate rect types. Optional setting per rectangular grid entry to make it transparent, 2500 * or to fill the grid entry with a color. only used in Lattice. 2501 * @enum { number } 2502 * @syscap SystemCapability.Graphics.Drawing 2503 * @since 12 2504 */ 2505 enum RectType { 2506 /** 2507 * Draws image into lattice rect. 2508 * @syscap SystemCapability.Graphics.Drawing 2509 * @since 12 2510 */ 2511 DEFAULT = 0, 2512 2513 /** 2514 * Skips lattice rect by making it transparent. 2515 * @syscap SystemCapability.Graphics.Drawing 2516 * @since 12 2517 */ 2518 TRANSPARENT = 1, 2519 2520 /** 2521 * Draws one of fColors into lattice rect. 2522 * @syscap SystemCapability.Graphics.Drawing 2523 * @since 12 2524 */ 2525 FIXEDCOLOR = 2 2526 } 2527 2528 /** 2529 * MaskFilter is the class for object that perform transformations on an alpha-channel mask before drawing it. 2530 * @syscap SystemCapability.Graphics.Drawing 2531 * @since 12 2532 */ 2533 class MaskFilter { 2534 /** 2535 * Makes a MaskFilter with a blur effect. 2536 * @param { BlurType } blurType - Indicates the blur type. 2537 * @param { number } sigma - Indicates the standard deviation of the Gaussian blur to apply. Must be > 0. 2538 * @returns { MaskFilter } MaskFilter object. 2539 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2540 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2541 * @static 2542 * @syscap SystemCapability.Graphics.Drawing 2543 * @since 12 2544 */ 2545 static createBlurMaskFilter(blurType: BlurType, sigma: number): MaskFilter; 2546 } 2547 2548 /** 2549 * How to transform path at each point (based on the current position and tangent). 2550 * @enum { number } 2551 * @syscap SystemCapability.Graphics.Drawing 2552 * @since 18 2553 */ 2554 enum PathDashStyle { 2555 /** 2556 * Translate the shape to each position. 2557 * @syscap SystemCapability.Graphics.Drawing 2558 * @since 18 2559 */ 2560 TRANSLATE = 0, 2561 /** 2562 * Rotate the shape about its center. 2563 * @syscap SystemCapability.Graphics.Drawing 2564 * @since 18 2565 */ 2566 ROTATE = 1, 2567 /** 2568 * Transform each point, and turn lines into curves. 2569 * @syscap SystemCapability.Graphics.Drawing 2570 * @since 18 2571 */ 2572 MORPH = 2, 2573 } 2574 2575 /** 2576 * Defines a PathEffect, which is used to affects stroked paths. 2577 * @syscap SystemCapability.Graphics.Drawing 2578 * @since 12 2579 */ 2580 class PathEffect { 2581 /** 2582 * Makes a dash PathEffect. 2583 * @param { Array<number> } intervals - Array of ON and OFF distances. Must contain an even number of entries (>=2), 2584 * with the even indices specifying the "on" intervals, and the odd indices specifying the "off" intervals. 2585 * @param { number } phase - Offset into the intervals array. 2586 * @returns { PathEffect } PathEffect object. 2587 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2588 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2589 * @static 2590 * @syscap SystemCapability.Graphics.Drawing 2591 * @since 12 2592 */ 2593 static createDashPathEffect(intervals: Array<number>, phase: number): PathEffect; 2594 2595 /** 2596 * Makes a corner PathEffect. 2597 * @param { number } radius - Indicates the radius of the tangent circle at the corners of the path. 2598 * The radius must be greater than 0. 2599 * @returns { PathEffect } PathEffect object. 2600 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2601 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2602 * @static 2603 * @syscap SystemCapability.Graphics.Drawing 2604 * @since 12 2605 */ 2606 static createCornerPathEffect(radius: number): PathEffect; 2607 2608 /** 2609 * Makes a discrete PathEffect. 2610 * @param { number } segLength - Indicates the maximum segment length of the path. 2611 * @param { number } dev - Indicates the deviation during drawing. 2612 * @param { number } seedAssist - Indicates generate effect pseudo-random sequence, the default value is zero. 2613 * @returns { PathEffect } PathEffect object. 2614 * @static 2615 * @syscap SystemCapability.Graphics.Drawing 2616 * @since 18 2617 */ 2618 static createDiscretePathEffect(segLength: number, dev: number, seedAssist?: number): PathEffect; 2619 2620 /** 2621 * Makes a compose PathEffect. 2622 * @param { PathEffect } outer - Indicates the path effect that takes effect later in the combination path effect. 2623 * @param { PathEffect } inner - Indicates the path effect of the first effect in the combination path effect. 2624 * @returns { PathEffect } PathEffect object. 2625 * @static 2626 * @syscap SystemCapability.Graphics.Drawing 2627 * @since 18 2628 */ 2629 static createComposePathEffect(outer: PathEffect, inner: PathEffect): PathEffect; 2630 2631 /** 2632 * Makes a path dash PathEffect. 2633 * @param { Path } path - Indicates the path to be used for the dash effect. 2634 * @param { number } advance - Indicates the advance distance for the dash effect. 2635 * @param { number } phase - Indicates the phase offset for the dash effect. 2636 * @param { PathDashStyle } style - Indicates the style of the dash effect. 2637 * @returns { PathEffect } PathEffect object. 2638 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2639 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2640 * @static 2641 * @syscap SystemCapability.Graphics.Drawing 2642 * @since 18 2643 */ 2644 static createPathDashEffect(path: Path, advance: number, phase: number, style: PathDashStyle): PathEffect; 2645 2646 /** 2647 * Makes a sum PathEffect. 2648 * @param { PathEffect } firstPathEffect - Indicates the first path effect. 2649 * @param { PathEffect } secondPathEffect - Indicates the second path effect. 2650 * @returns { PathEffect } PathEffect object. 2651 * @static 2652 * @syscap SystemCapability.Graphics.Drawing 2653 * @since 18 2654 */ 2655 static createSumPathEffect(firstPathEffect: PathEffect, secondPathEffect: PathEffect): PathEffect; 2656 } 2657 2658 /** 2659 * Describes a shader effect object. 2660 * @syscap SystemCapability.Graphics.Drawing 2661 * @since 12 2662 */ 2663 class ShaderEffect { 2664 /** 2665 * Creates an ShaderEffect object that generates a shader with single color. 2666 * @param { number } color - Indicates the color used by the shader. 2667 * @returns { ShaderEffect } Returns the shader with single color ShaderEffect object. 2668 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2669 * <br>2. Incorrect parameter types. 2670 * @syscap SystemCapability.Graphics.Drawing 2671 * @since 12 2672 */ 2673 static createColorShader(color: number): ShaderEffect; 2674 2675 /** 2676 * Creates an ShaderEffect object that generates a linear gradient between the two specified points. 2677 * @param { common2D.Point } startPt - Indicates the start point for the gradient. 2678 * @param { common2D.Point } endPt - Indicates the end point for the gradient. 2679 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2680 * @param { TileMode } mode - Indicates the tile mode. 2681 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2682 * <br> in the colors array. The default value is empty for uniform distribution. 2683 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2684 * @returns { ShaderEffect } Returns a linear gradient ShaderEffect object. 2685 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2686 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2687 * @syscap SystemCapability.Graphics.Drawing 2688 * @since 12 2689 */ 2690 static createLinearGradient(startPt: common2D.Point, endPt: common2D.Point, colors: Array<number>, 2691 mode: TileMode, pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 2692 2693 /** 2694 * Creates an ShaderEffect object that generates a radial gradient given the center and radius. 2695 * @param { common2D.Point } centerPt - Indicates the center of the circle for the gradient. 2696 * @param { number } radius - Indicates the radius of the circle for this gradient. 2697 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2698 * @param { TileMode } mode - Indicates the tile mode. 2699 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2700 * <br> in the colors array. The default value is empty for uniform distribution. 2701 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2702 * @returns { ShaderEffect } Returns a radial gradient ShaderEffect object. 2703 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2704 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2705 * @syscap SystemCapability.Graphics.Drawing 2706 * @since 12 2707 */ 2708 static createRadialGradient(centerPt: common2D.Point, radius: number, colors: Array<number>, 2709 mode: TileMode, pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 2710 2711 /** 2712 * Creates an ShaderEffect object that generates a sweep gradient given a center. 2713 * @param { common2D.Point } centerPt - Indicates the center of the circle for the gradient. 2714 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2715 * @param { TileMode } mode - Indicates the tile mode. 2716 * @param { number } startAngle - The starting angle of the gradient. 2717 * @param { number } endAngle - The ending angle of the gradient. 2718 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2719 * <br> in the colors array. The default value is empty for uniform distribution. 2720 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2721 * @returns { ShaderEffect } Returns a sweep gradient ShaderEffect object. 2722 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2723 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2724 * @syscap SystemCapability.Graphics.Drawing 2725 * @since 12 2726 */ 2727 static createSweepGradient(centerPt: common2D.Point, colors: Array<number>, 2728 mode: TileMode, startAngle: number, endAngle: number, pos?: Array<number> | null, 2729 matrix?: Matrix | null): ShaderEffect; 2730 2731 /** 2732 * Creates an ShaderEffect object that generates a conical gradient given two circles. 2733 * @param { common2D.Point } startPt - Indicates the center of the start circle for the gradient. 2734 * @param { number } startRadius - Indicates the radius of the start circle for this gradient. 2735 * @param { common2D.Point } endPt - Indicates the center of the end circle for the gradient. 2736 * @param { number } endRadius - Indicates the radius of the end circle for this gradient. 2737 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2738 * @param { TileMode } mode - Indicates the tile mode. 2739 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2740 * <br> in the colors array. The default value is empty for uniform distribution. 2741 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2742 * @returns { ShaderEffect } Returns a conical gradient ShaderEffect object. 2743 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2744 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2745 * @syscap SystemCapability.Graphics.Drawing 2746 * @since 12 2747 */ 2748 static createConicalGradient(startPt: common2D.Point, startRadius: number, endPt: common2D.Point, 2749 endRadius: number, colors: Array<number>, mode: TileMode, 2750 pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 2751 } 2752 2753 /** 2754 * Enumerates tile modes that describe an image or texture. 2755 * @enum { number } 2756 * @syscap SystemCapability.Graphics.Drawing 2757 * @since 12 2758 */ 2759 enum TileMode { 2760 /** 2761 * Replicate the edge color if the shader effect draws outside of its original bounds. 2762 * @syscap SystemCapability.Graphics.Drawing 2763 * @since 12 2764 */ 2765 CLAMP = 0, 2766 2767 /** 2768 * Repeat the shader effect image horizontally and vertically. 2769 * @syscap SystemCapability.Graphics.Drawing 2770 * @since 12 2771 */ 2772 REPEAT = 1, 2773 2774 /** 2775 * Repeat the shader effect image horizontally and vertically, alternating mirror images 2776 * so that adjacent images always seam. 2777 * @syscap SystemCapability.Graphics.Drawing 2778 * @since 12 2779 */ 2780 MIRROR = 2, 2781 2782 /** 2783 * Only draw within the original domain, return transparent-black everywhere else. 2784 * @syscap SystemCapability.Graphics.Drawing 2785 * @since 12 2786 */ 2787 DECAL = 3, 2788 } 2789 2790 /** 2791 * Defines a ShadowLayer, which is used to specify the color, blur radius, and offset of the shadow. 2792 * @syscap SystemCapability.Graphics.Drawing 2793 * @since 12 2794 */ 2795 class ShadowLayer { 2796 /** 2797 * Makes a new ShadowLayer. 2798 * 2799 * @param { number } blurRadius - The blur radius of the shadow. The blur radius must be greater than 0. 2800 * @param { number } x - The offset point on x-axis. 2801 * @param { number } y - The offset point on y-axis. 2802 * @param { common2D.Color } color - The shadow color. The range of color channels must be [0, 255]. 2803 * @returns { ShadowLayer } ShadowLayer object. 2804 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2805 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2806 * @static 2807 * @syscap SystemCapability.Graphics.Drawing 2808 * @since 12 2809 */ 2810 static create(blurRadius: number, x: number, y: number, color: common2D.Color): ShadowLayer; 2811 2812 /** 2813 * Makes a new ShadowLayer with the specified ARGB color of hexadecimal format. 2814 * 2815 * @param { number } blurRadius - The blur radius of the shadow. The blur radius must be greater than 0. 2816 * @param { number } x - The offset point on x-axis. 2817 * @param { number } y - The offset point on y-axis. 2818 * @param { common2D.Color | number } color - The shadow color. Number must be ARGB color of hexadecimal format. 2819 * @returns { ShadowLayer } ShadowLayer object. 2820 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2821 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2822 * @static 2823 * @syscap SystemCapability.Graphics.Drawing 2824 * @since 18 2825 */ 2826 static create(blurRadius: number, x: number, y: number, color: common2D.Color | number): ShadowLayer; 2827 } 2828 2829 /** 2830 * ColorFilters are optional objects in the drawing pipeline. 2831 * 2832 * @syscap SystemCapability.Graphics.Drawing 2833 * @since 11 2834 */ 2835 class ColorFilter { 2836 /** 2837 * Makes a color filter with the given color and blend mode. 2838 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 2839 * @param { BlendMode } mode - BlendMode. 2840 * @returns { ColorFilter } Colorfilter object. 2841 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2842 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2843 * @static 2844 * @syscap SystemCapability.Graphics.Drawing 2845 * @since 11 2846 */ 2847 static createBlendModeColorFilter(color: common2D.Color, mode: BlendMode): ColorFilter; 2848 2849 /** 2850 * Makes a color filter with the given ARGB color of hexadecimal format and blend mode. 2851 * @param { common2D.Color | number } color - Number must be ARGB color of hexadecimal format. 2852 * @param { BlendMode } mode - BlendMode. 2853 * @returns { ColorFilter } Colorfilter object. 2854 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2855 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2856 * @static 2857 * @syscap SystemCapability.Graphics.Drawing 2858 * @since 18 2859 */ 2860 static createBlendModeColorFilter(color: common2D.Color | number, mode: BlendMode): ColorFilter; 2861 2862 /** 2863 * Create a color filter consisting of two filters. 2864 * @param { ColorFilter } outer - The filter is used next. 2865 * @param { ColorFilter } inner - The filter is used first. 2866 * @returns { ColorFilter } Colorfilter object. 2867 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2868 * <br>2. Incorrect parameter types. 2869 * @static 2870 * @syscap SystemCapability.Graphics.Drawing 2871 * @since 11 2872 */ 2873 static createComposeColorFilter(outer: ColorFilter, inner: ColorFilter): ColorFilter; 2874 2875 /** 2876 * Makes a color filter that converts between linear colors and sRGB colors. 2877 * @returns { ColorFilter } Colorfilter object. 2878 * @static 2879 * @syscap SystemCapability.Graphics.Drawing 2880 * @since 11 2881 */ 2882 static createLinearToSRGBGamma(): ColorFilter; 2883 2884 /** 2885 * Makes a color filter that converts between sRGB colors and linear colors. 2886 * @returns { ColorFilter } Colorfilter object. 2887 * @static 2888 * @syscap SystemCapability.Graphics.Drawing 2889 * @since 11 2890 */ 2891 static createSRGBGammaToLinear(): ColorFilter; 2892 2893 /** 2894 * Makes a color filter that multiplies the luma of its input into the alpha channel, 2895 * and sets the red, green, and blue channels to zero. 2896 * @returns { ColorFilter } Colorfilter. 2897 * @static 2898 * @syscap SystemCapability.Graphics.Drawing 2899 * @since 11 2900 */ 2901 static createLumaColorFilter(): ColorFilter; 2902 /** 2903 * Makes a color filter with a 5x4 color matrix 2904 * @param { Array<number> } matrix - Indicates the matrix, which is represented as a number array of length 20. 2905 * @returns { ColorFilter } Colorfilter object. 2906 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2907 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2908 * @static 2909 * @syscap SystemCapability.Graphics.Drawing 2910 * @since 12 2911 */ 2912 static createMatrixColorFilter(matrix: Array<number>): ColorFilter; 2913 } 2914 2915 /** 2916 * ImageFilters are optional objects in the drawing pipeline. 2917 * 2918 * @syscap SystemCapability.Graphics.Drawing 2919 * @since 12 2920 */ 2921 class ImageFilter { 2922 /** 2923 * Makes an ImageFilter object that blurs its input by the separate X and Y sigmas. 2924 * @param { number } sigmaX - Indicates the Gaussian sigma value for blurring along the X axis. Must be > 0. 2925 * @param { number } sigmaY - Indicates the Gaussian sigma value for blurring along the Y axis. Must be > 0. 2926 * @param { TileMode } tileMode - Indicates the tile mode applied at edges. 2927 * @param { ImageFilter | null } imageFilter - Indicates the input filter that is blurred, 2928 * uses source bitmap if this is null. 2929 * @returns { ImageFilter } ImageFilter object. 2930 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2931 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2932 * @static 2933 * @syscap SystemCapability.Graphics.Drawing 2934 * @since 12 2935 */ 2936 static createBlurImageFilter(sigmaX: number, sigmaY: number, 2937 tileMode: TileMode, imageFilter?: ImageFilter | null): ImageFilter; 2938 /** 2939 * Makes an ImageFilter object that applies the color filter to the input. 2940 * @param { ColorFilter } colorFilter - Indicates the color filter that transforms the input image. 2941 * @param { ImageFilter | null } imageFilter - Indicates the input filter, or uses the source bitmap if this is null. 2942 * @returns { ImageFilter } ImageFilter object. 2943 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2944 * <br>2. Incorrect parameter types. 2945 * @static 2946 * @syscap SystemCapability.Graphics.Drawing 2947 * @since 12 2948 */ 2949 static createFromColorFilter(colorFilter: ColorFilter, imageFilter?: ImageFilter | null): ImageFilter; 2950 } 2951 /** 2952 * Enumerate join styles. The join style defines the shape of the joins of a 2953 * polyline segment drawn by the pen. 2954 * @enum { number } 2955 * @syscap SystemCapability.Graphics.Drawing 2956 * @since 12 2957 */ 2958 enum JoinStyle { 2959 /** 2960 * Miter corner. If the angle of a polyline is small, its miter length may be inappropriate. 2961 * In this case, you need to use the miter limit to limit the miter length. 2962 * @syscap SystemCapability.Graphics.Drawing 2963 * @since 12 2964 */ 2965 MITER_JOIN = 0, 2966 2967 /** 2968 * Round corner. 2969 * @syscap SystemCapability.Graphics.Drawing 2970 * @since 12 2971 */ 2972 ROUND_JOIN = 1, 2973 2974 /** 2975 * Bevel corner. 2976 * @syscap SystemCapability.Graphics.Drawing 2977 * @since 12 2978 */ 2979 BEVEL_JOIN = 2 2980 } 2981 2982 /** 2983 * Enumerates cap styles of a pen. The cap style defines 2984 * the style of both ends of a segment drawn by the pen. 2985 * @enum { number } 2986 * @syscap SystemCapability.Graphics.Drawing 2987 * @since 12 2988 */ 2989 enum CapStyle { 2990 /** 2991 * No cap style. Both ends of the segment are cut off square. 2992 * @syscap SystemCapability.Graphics.Drawing 2993 * @since 12 2994 */ 2995 FLAT_CAP = 0, 2996 2997 /** 2998 * Square cap style. Both ends have a square, the height of which 2999 * is half of the width of the segment, with the same width. 3000 * @syscap SystemCapability.Graphics.Drawing 3001 * @since 12 3002 */ 3003 SQUARE_CAP = 1, 3004 3005 /** 3006 * Round cap style. Both ends have a semicircle centered, the diameter of which 3007 * is the same as the width of the segment. 3008 * @syscap SystemCapability.Graphics.Drawing 3009 * @since 12 3010 */ 3011 ROUND_CAP = 2 3012 } 3013 3014 /** 3015 * Enumerates blur type. 3016 * @enum { number } 3017 * @syscap SystemCapability.Graphics.Drawing 3018 * @since 12 3019 */ 3020 enum BlurType { 3021 /** 3022 * Fuzzy inside and outside. 3023 * @syscap SystemCapability.Graphics.Drawing 3024 * @since 12 3025 */ 3026 NORMAL = 0, 3027 3028 /** 3029 * Solid inside, fuzzy outside. 3030 * @syscap SystemCapability.Graphics.Drawing 3031 * @since 12 3032 */ 3033 SOLID = 1, 3034 3035 /** 3036 * Nothing inside, fuzzy outside. 3037 * @syscap SystemCapability.Graphics.Drawing 3038 * @since 12 3039 */ 3040 OUTER = 2, 3041 3042 /** 3043 * Fuzzy inside, nothing outside. 3044 * @syscap SystemCapability.Graphics.Drawing 3045 * @since 12 3046 */ 3047 INNER = 3 3048 } 3049 3050 /** 3051 * Provides settings for strokes during drawing. 3052 * @syscap SystemCapability.Graphics.Drawing 3053 * @since 11 3054 */ 3055 class Pen { 3056 /** 3057 * Constructor for the pen. 3058 * @syscap SystemCapability.Graphics.Drawing 3059 * @since 12 3060 */ 3061 constructor(); 3062 3063 /** 3064 * Constructor for the pen from an existing pen object pen. 3065 * @param { Pen } pen - Indicates the Pen object. 3066 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3067 * <br>2. Incorrect parameter types. 3068 * @syscap SystemCapability.Graphics.Drawing 3069 * @since 12 3070 */ 3071 constructor(pen: Pen); 3072 3073 /** 3074 * Sets the stroke miter limit for a polyline drawn by a pen. 3075 * @param { number } miter - Indicates a variable that describes the miter limit. 3076 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3077 * <br>2. Incorrect parameter types. 3078 * @syscap SystemCapability.Graphics.Drawing 3079 * @since 12 3080 */ 3081 setMiterLimit(miter: number): void; 3082 3083 /** 3084 * Obtains the stroke miter limit of a polyline drawn by a pen. 3085 * @returns { number } Returns the miter limit. 3086 * @syscap SystemCapability.Graphics.Drawing 3087 * @since 12 3088 */ 3089 getMiterLimit(): number; 3090 3091 /** 3092 * Sets the shaderEffect for a pen. 3093 * @param { ShaderEffect } shaderEffect - Indicates the ShaderEffect object. 3094 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3095 * <br>2. Incorrect parameter types. 3096 * @syscap SystemCapability.Graphics.Drawing 3097 * @since 12 3098 */ 3099 setShaderEffect(shaderEffect: ShaderEffect): void; 3100 3101 /** 3102 * Set the color of the pen. 3103 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 3104 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3105 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3106 * @syscap SystemCapability.Graphics.Drawing 3107 * @since 11 3108 */ 3109 setColor(color: common2D.Color): void; 3110 3111 /** 3112 * Set the AGRB color of the pen. 3113 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 3114 * @param { number } red - Red channel of color. The range of red must be [0, 255]. 3115 * @param { number } green - Green channel of color. The range of green must be [0, 255]. 3116 * @param { number } blue - Blue channel of color. The range of blue must be [0, 255]. 3117 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3118 * <br>2. Incorrect parameter types. 3119 * @syscap SystemCapability.Graphics.Drawing 3120 * @since 12 3121 */ 3122 setColor(alpha: number, red: number, green: number, blue: number): void; 3123 3124 /** 3125 * Set the specified ARGB color of hexadecimal format to the pen. 3126 * @param { number } color - Number must be ARGB color of hexadecimal format. 3127 * @syscap SystemCapability.Graphics.Drawing 3128 * @since 18 3129 */ 3130 setColor(color: number): void; 3131 3132 /** 3133 * Obtains the color of a pen. The color is used by the pen to outline a shape. 3134 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 3135 * @syscap SystemCapability.Graphics.Drawing 3136 * @since 12 3137 */ 3138 getColor(): common2D.Color; 3139 3140 /** 3141 * Obtains the color of a pen. The color is used by the pen to outline a shape. 3142 * @returns { number } Returns a 32-bit (ARGB) variable that describes the color of hexadecimal format. 3143 * @syscap SystemCapability.Graphics.Drawing 3144 * @since 18 3145 */ 3146 getHexColor(): number; 3147 3148 /** 3149 * Sets the thickness of the pen used by the paint to outline the shape. 3150 * 3151 * @param { number } width - Zero thickness for hairline; greater than zero for pen thickness. 3152 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3153 * <br>2. Incorrect parameter types. 3154 * @syscap SystemCapability.Graphics.Drawing 3155 * @since 11 3156 */ 3157 setStrokeWidth(width: number): void; 3158 3159 /** 3160 * Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. 3161 * @returns { number } Returns the thickness. 3162 * @syscap SystemCapability.Graphics.Drawing 3163 * @since 12 3164 */ 3165 getWidth(): number; 3166 3167 /** 3168 * Requests, but does not require, that edge pixels draw opaque or with partial transparency. 3169 * 3170 * @param { boolean } aa - Setting for antialiasing. 3171 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3172 * <br>2. Incorrect parameter types. 3173 * @syscap SystemCapability.Graphics.Drawing 3174 * @since 11 3175 */ 3176 setAntiAlias(aa: boolean): void; 3177 3178 /** 3179 * Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, 3180 * edges will be drawn with partial transparency. 3181 * @returns { boolean } Returns true if the anti-aliasing is enabled; returns false otherwise. 3182 * @syscap SystemCapability.Graphics.Drawing 3183 * @since 12 3184 */ 3185 isAntiAlias(): boolean; 3186 3187 /** 3188 * Replaces alpha, leaving RGB 3189 * 3190 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 3191 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3192 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3193 * @syscap SystemCapability.Graphics.Drawing 3194 * @since 11 3195 */ 3196 setAlpha(alpha: number): void; 3197 3198 /** 3199 * Obtains the alpha of a pen. The alpha is used by the pen to outline a shape. 3200 * @returns { number } Returns a 8-bit variable that describes the alpha. 3201 * @syscap SystemCapability.Graphics.Drawing 3202 * @since 12 3203 */ 3204 getAlpha(): number; 3205 3206 /** 3207 * Sets ColorFilter to pen 3208 * 3209 * @param { ColorFilter } filter - ColorFilter to apply to subsequent draw. 3210 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3211 * <br>2. Incorrect parameter types. 3212 * @syscap SystemCapability.Graphics.Drawing 3213 * @since 11 3214 */ 3215 setColorFilter(filter: ColorFilter): void; 3216 /** 3217 * Gets ColorFilter of pen 3218 * @returns { ColorFilter } ColorFilter. 3219 * @syscap SystemCapability.Graphics.Drawing 3220 * @since 12 3221 */ 3222 getColorFilter(): ColorFilter; 3223 /** 3224 * Sets ImageFilter to pen 3225 * @param { ImageFilter | null } filter - ImageFilter to apply to subsequent draw. 3226 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3227 * <br>2. Incorrect parameter types. 3228 * @syscap SystemCapability.Graphics.Drawing 3229 * @since 12 3230 */ 3231 setImageFilter(filter: ImageFilter | null): void; 3232 /** 3233 * Sets MaskFilter to pen. 3234 * 3235 * @param { MaskFilter } filter - MaskFilter to apply to subsequent draw. 3236 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3237 * <br>2. Incorrect parameter types. 3238 * @syscap SystemCapability.Graphics.Drawing 3239 * @since 12 3240 */ 3241 setMaskFilter(filter: MaskFilter): void; 3242 3243 /** 3244 * Sets PathEffect to pen. 3245 * 3246 * @param { PathEffect } effect - PathEffect to apply to subsequent draw. 3247 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3248 * <br>2. Incorrect parameter types. 3249 * @syscap SystemCapability.Graphics.Drawing 3250 * @since 12 3251 */ 3252 setPathEffect(effect: PathEffect): void; 3253 3254 /** 3255 * Sets ShadowLayer to pen. 3256 * 3257 * @param { ShadowLayer } shadowLayer - ShadowLayer to apply to subsequent draw. 3258 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3259 * <br>2. Incorrect parameter types. 3260 * @syscap SystemCapability.Graphics.Drawing 3261 * @since 12 3262 */ 3263 setShadowLayer(shadowLayer: ShadowLayer): void; 3264 3265 /** 3266 * Sets a blender that implements the specified blendmode enum. 3267 * 3268 * @param { BlendMode } mode - Blendmode. 3269 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3270 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3271 * @syscap SystemCapability.Graphics.Drawing 3272 * @since 11 3273 */ 3274 setBlendMode(mode: BlendMode): void; 3275 3276 /** 3277 * Request color distribution error. 3278 * 3279 * @param { boolean } dither - Whether the color is distributed incorrectly. 3280 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3281 * <br>2. Incorrect parameter types. 3282 * @syscap SystemCapability.Graphics.Drawing 3283 * @since 11 3284 */ 3285 setDither(dither: boolean): void; 3286 3287 /** 3288 * Sets the JoinStyle for a pen. 3289 * 3290 * @param { JoinStyle } style - The JoinStyle. 3291 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3292 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3293 * @syscap SystemCapability.Graphics.Drawing 3294 * @since 12 3295 */ 3296 setJoinStyle(style: JoinStyle): void; 3297 3298 /** 3299 * Obtains the JoinStyle of a pen. 3300 * 3301 * @returns { JoinStyle } The JoinStyle. 3302 * @syscap SystemCapability.Graphics.Drawing 3303 * @since 12 3304 */ 3305 getJoinStyle(): JoinStyle; 3306 3307 /** 3308 * Sets the CapStyle for a pen. 3309 * 3310 * @param { CapStyle } style - The CapStyle. 3311 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3312 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3313 * @syscap SystemCapability.Graphics.Drawing 3314 * @since 12 3315 */ 3316 setCapStyle(style: CapStyle): void; 3317 3318 /** 3319 * Obtains the CapStyle of a pen. 3320 * 3321 * @returns { CapStyle } The CapStyle. 3322 * @syscap SystemCapability.Graphics.Drawing 3323 * @since 12 3324 */ 3325 getCapStyle(): CapStyle; 3326 3327 /** 3328 * Resets all pen contents to their initial values. 3329 * @syscap SystemCapability.Graphics.Drawing 3330 * @since 12 3331 */ 3332 reset(): void; 3333 /** 3334 * Obtains the filled equivalent of the src path. 3335 * 3336 * @param { Path } src - The path read to create a filled version. 3337 * @param { Path } dst - The resulting path (may be the same as src). 3338 * @returns { boolean } true if the path should be filled, or false if it should be drawn with a hairline (width == 0) 3339 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3340 * <br>2. Incorrect parameter types. 3341 * @syscap SystemCapability.Graphics.Drawing 3342 * @since 12 3343 */ 3344 getFillPath(src: Path, dst: Path): boolean; 3345 } 3346 3347 /** 3348 * Provides settings for brush fill when drawing. 3349 * @syscap SystemCapability.Graphics.Drawing 3350 * @since 11 3351 */ 3352 class Brush { 3353 /** 3354 * Constructor for the Brush. 3355 * @syscap SystemCapability.Graphics.Drawing 3356 * @since 12 3357 */ 3358 constructor(); 3359 3360 /** 3361 * Constructor for the Brush from an existing brush object brush. 3362 * @param { Brush } brush - Indicates the Brush object. 3363 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3364 * <br>2. Incorrect parameter types. 3365 * @syscap SystemCapability.Graphics.Drawing 3366 * @since 12 3367 */ 3368 constructor(brush: Brush); 3369 3370 /** 3371 * Set the color of the brush. 3372 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 3373 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3374 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3375 * @syscap SystemCapability.Graphics.Drawing 3376 * @since 11 3377 */ 3378 setColor(color: common2D.Color): void; 3379 3380 /** 3381 * Set the ARGB color of the brush. 3382 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 3383 * @param { number } red - Red channel of color. The range of red must be [0, 255]. 3384 * @param { number } green - Green channel of color. The range of green must be [0, 255]. 3385 * @param { number } blue - Blue channel of color. The range of blue must be [0, 255]. 3386 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3387 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3388 * @syscap SystemCapability.Graphics.Drawing 3389 * @since 12 3390 */ 3391 setColor(alpha: number, red: number, green: number, blue: number): void; 3392 3393 /** 3394 * Set the specified ARGB color of hexadecimal format to the brush. 3395 * @param { number } color - Number must be ARGB color of hexadecimal format. 3396 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3397 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3398 * @syscap SystemCapability.Graphics.Drawing 3399 * @since 18 3400 */ 3401 setColor(color: number): void; 3402 3403 /** 3404 * Obtains the color of a brush. The color is used by the brush to fill in a shape. 3405 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 3406 * @syscap SystemCapability.Graphics.Drawing 3407 * @since 12 3408 */ 3409 getColor(): common2D.Color; 3410 3411 /** 3412 * Obtains the color of a brush. The color is used by the brush to fill in a shape. 3413 * @returns { number } Returns a 32-bit (ARGB) variable that describes the color of hexadecimal format. 3414 * @syscap SystemCapability.Graphics.Drawing 3415 * @since 18 3416 */ 3417 getHexColor(): number; 3418 3419 /** 3420 * Requests, but does not require, that edge pixels draw opaque or with partial transparency. 3421 * @param { boolean } aa - Setting for antialiasing. 3422 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3423 * <br>2. Incorrect parameter types. 3424 * @syscap SystemCapability.Graphics.Drawing 3425 * @since 11 3426 */ 3427 setAntiAlias(aa: boolean): void; 3428 3429 /** 3430 * Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, 3431 * edges will be drawn with partial transparency. 3432 * @returns { boolean } Returns true if anti-aliasing is enabled; returns false otherwise. 3433 * @syscap SystemCapability.Graphics.Drawing 3434 * @since 12 3435 */ 3436 isAntiAlias(): boolean; 3437 3438 /** 3439 * Replaces alpha, leaving RGB 3440 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 3441 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3442 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3443 * @syscap SystemCapability.Graphics.Drawing 3444 * @since 11 3445 */ 3446 setAlpha(alpha: number): void; 3447 3448 /** 3449 * Obtains the alpha of a brush. The alpha is used by the brush to fill in a shape. 3450 * @returns { number } Returns a 8-bit variable that describes the alpha. 3451 * @syscap SystemCapability.Graphics.Drawing 3452 * @since 12 3453 */ 3454 getAlpha(): number; 3455 3456 /** 3457 * Sets ColorFilter to brush 3458 * @param { ColorFilter } filter - ColorFilter to apply to subsequent draw. 3459 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3460 * <br>2. Incorrect parameter types. 3461 * @syscap SystemCapability.Graphics.Drawing 3462 * @since 11 3463 */ 3464 setColorFilter(filter: ColorFilter): void; 3465 3466 /** 3467 * Gets ColorFilter of brush 3468 * @returns { ColorFilter } ColorFilter. 3469 * @syscap SystemCapability.Graphics.Drawing 3470 * @since 12 3471 */ 3472 getColorFilter(): ColorFilter; 3473 /** 3474 * Sets ImageFilter to brush 3475 * @param { ImageFilter | null } filter - ImageFilter to apply to subsequent draw. 3476 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3477 * <br>2. Incorrect parameter types. 3478 * @syscap SystemCapability.Graphics.Drawing 3479 * @since 12 3480 */ 3481 setImageFilter(filter: ImageFilter | null): void; 3482 /** 3483 * Sets MaskFilter to brush. 3484 * @param { MaskFilter } filter - MaskFilter to apply to subsequent draw. 3485 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3486 * <br>2. Incorrect parameter types. 3487 * @syscap SystemCapability.Graphics.Drawing 3488 * @since 12 3489 */ 3490 setMaskFilter(filter: MaskFilter): void; 3491 3492 /** 3493 * Sets ShadowLayer to brush. 3494 * 3495 * @param { ShadowLayer } shadowLayer - ShadowLayer painting. 3496 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3497 * <br>2. Incorrect parameter types. 3498 * @syscap SystemCapability.Graphics.Drawing 3499 * @since 12 3500 */ 3501 setShadowLayer(shadowLayer: ShadowLayer): void; 3502 3503 /** 3504 * Sets the shaderEffect for a brush. 3505 * @param { ShaderEffect } shaderEffect - Indicates the ShaderEffect object. 3506 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3507 * <br>2. Incorrect parameter types. 3508 * @syscap SystemCapability.Graphics.Drawing 3509 * @since 12 3510 */ 3511 setShaderEffect(shaderEffect: ShaderEffect): void; 3512 3513 /** 3514 * Sets a blender that implements the specified blendmode enum. 3515 * @param { BlendMode } mode - Blendmode. 3516 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3517 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3518 * @syscap SystemCapability.Graphics.Drawing 3519 * @since 11 3520 */ 3521 setBlendMode(mode: BlendMode): void; 3522 3523 /** 3524 * Resets all brush contents to their initial values. 3525 * @syscap SystemCapability.Graphics.Drawing 3526 * @since 12 3527 */ 3528 reset(): void; 3529 } 3530 3531 /** 3532 * Declares functions related to the matrix object in the drawing module. 3533 * 3534 * @syscap SystemCapability.Graphics.Drawing 3535 * @since 12 3536 */ 3537 class Matrix { 3538 /** 3539 * Creates an identity matrix. 3540 * @syscap SystemCapability.Graphics.Drawing 3541 * @since 12 3542 */ 3543 constructor(); 3544 3545 /** 3546 * Sets matrix to rotate by degrees about a pivot point at (px, py). 3547 * @param { number } degree - Indicates the angle of axes relative to upright axes. 3548 * @param { number } px - Indicates the pivot on x-axis. 3549 * @param { number } py - Indicates the pivot on y-axis. 3550 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3551 * <br>2. Incorrect parameter types. 3552 * @syscap SystemCapability.Graphics.Drawing 3553 * @since 12 3554 */ 3555 setRotation(degree: number, px: number, py: number): void; 3556 3557 /** 3558 * Sets matrix to scale by sx and sy, about a pivot point at (px, py). 3559 * @param { number } sx - Indicates the horizontal scale factor. 3560 * @param { number } sy - Indicates the vertical scale factor. 3561 * @param { number } px - Indicates the pivot on x-axis. 3562 * @param { number } py - Indicates the pivot on y-axis. 3563 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3564 * <br>2. Incorrect parameter types. 3565 * @syscap SystemCapability.Graphics.Drawing 3566 * @since 12 3567 */ 3568 setScale(sx: number, sy: number, px: number, py: number): void; 3569 3570 /** 3571 * Sets matrix to translate by (dx, dy). 3572 * @param { number } dx - Indicates the horizontal translation. 3573 * @param { number } dy - Indicates the vertical translation. 3574 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3575 * <br>2. Incorrect parameter types. 3576 * @syscap SystemCapability.Graphics.Drawing 3577 * @since 12 3578 */ 3579 setTranslation(dx: number, dy: number): void; 3580 3581 /** 3582 * Sets the params for a matrix. 3583 * @param { Array<number> } values - Each value in the array represents the following parameters: 3584 * values[0] - horizontal scale factor to store. 3585 * values[1] - horizontal skew factor to store. 3586 * values[2] - horizontal translation to store. 3587 * values[3] - vertical skew factor to store. 3588 * values[4] - vertical scale factor to store. 3589 * values[5] - vertical translation to store. 3590 * values[6] - input x-axis values perspective factor to store. 3591 * values[7] - input y-axis values perspective factor to store. 3592 * values[8] - perspective scale factor to store. 3593 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3594 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3595 * @syscap SystemCapability.Graphics.Drawing 3596 * @since 12 3597 */ 3598 setMatrix(values: Array<number>): void; 3599 3600 /** 3601 * Sets matrix total to matrix a multiplied by matrix b. 3602 * @param { Matrix } matrix - Indicates the Matrix object. 3603 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3604 * <br>2. Incorrect parameter types. 3605 * @syscap SystemCapability.Graphics.Drawing 3606 * @since 12 3607 */ 3608 preConcat(matrix: Matrix): void; 3609 3610 /** 3611 * Returns true if the first matrix equals the second matrix. 3612 * @param { Matrix } matrix - Indicates the Matrix object. 3613 * @returns { Boolean } Returns true if the two matrices are equal; returns false otherwise. 3614 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3615 * <br>2. Incorrect parameter types. 3616 * @syscap SystemCapability.Graphics.Drawing 3617 * @since 12 3618 */ 3619 isEqual(matrix: Matrix): Boolean; 3620 3621 /** 3622 * Sets inverse to reciprocal matrix, returning true if matrix can be inverted. 3623 * @param { Matrix } matrix - Indicates the Matrix object. 3624 * @returns { Boolean } Returns true if matrix can be inverted; returns false otherwise. 3625 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3626 * <br>2. Incorrect parameter types. 3627 * @syscap SystemCapability.Graphics.Drawing 3628 * @since 12 3629 */ 3630 invert(matrix: Matrix): Boolean; 3631 3632 /** 3633 * Returns true if matrix is identity. 3634 * @returns { Boolean } Returns true if matrix is identity; returns false otherwise. 3635 * @syscap SystemCapability.Graphics.Drawing 3636 * @since 12 3637 */ 3638 isIdentity(): Boolean; 3639 3640 /** 3641 * Get one matrix value. Index is between the range of 0-8. 3642 * @param { number } index - one of 0-8 3643 * @returns { number } Returns value corresponding to index.Returns 0 if out of range. 3644 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3645 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3646 * @syscap SystemCapability.Graphics.Drawing 3647 * @since 12 3648 */ 3649 getValue(index: number): number; 3650 /** 3651 * Sets matrix to matrix multiplied by matrix constructed from rotating by degrees around pivot point (px, py). 3652 * This can be thought of as rotating around a pivot point after applying matrix. 3653 * @param { number } degree - Indicates the angle of axes relative to upright axes. 3654 * @param { number } px - Indicates the pivot on x-axis. 3655 * @param { number } py - Indicates the pivot on y-axis. 3656 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3657 * <br>2. Incorrect parameter types. 3658 * @syscap SystemCapability.Graphics.Drawing 3659 * @since 12 3660 */ 3661 postRotate(degree: number, px: number, py: number): void; 3662 /** 3663 * Sets matrix to matrix multiplied by matrix constructed from scaling by (sx, sy) relative to pivot point (px, py). 3664 * This can be thought of as scaling relative to a pivot point after applying matrix. 3665 * @param { number } sx - Indicates the horizontal scale factor. 3666 * @param { number } sy - Indicates the vertical scale factor. 3667 * @param { number } px - Indicates the pivot on x-axis. 3668 * @param { number } py - Indicates the pivot on y-axis. 3669 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3670 * <br>2. Incorrect parameter types. 3671 * @syscap SystemCapability.Graphics.Drawing 3672 * @since 12 3673 */ 3674 postScale(sx: number, sy: number, px: number, py: number): void; 3675 /** 3676 * Sets matrix to matrix multiplied by matrix constructed from translation (dx, dy). 3677 * This can be thought of as moving the point to be mapped after applying matrix. 3678 * @param { number } dx - Indicates the horizontal translation. 3679 * @param { number } dy - Indicates the vertical translation. 3680 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3681 * <br>2. Incorrect parameter types. 3682 * @syscap SystemCapability.Graphics.Drawing 3683 * @since 12 3684 */ 3685 postTranslate(dx: number, dy: number): void; 3686 /** 3687 * Sets matrix to matrix multiplied by matrix constructed from rotating by degrees around pivot point (px, py). 3688 * This can be thought of as rotating around a pivot point before applying matrix. 3689 * @param { number } degree - Indicates the angle of axes relative to upright axes. 3690 * @param { number } px - Indicates the pivot on x-axis. 3691 * @param { number } py - Indicates the pivot on y-axis. 3692 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3693 * <br>2. Incorrect parameter types. 3694 * @syscap SystemCapability.Graphics.Drawing 3695 * @since 12 3696 */ 3697 preRotate(degree: number, px: number, py: number): void; 3698 /** 3699 * Sets matrix to matrix multiplied by matrix constructed from scaling by (sx, sy) relative to pivot point (px, py). 3700 * This can be thought of as scaling relative to a pivot point before applying matrix. 3701 * @param { number } sx - Indicates the horizontal scale factor. 3702 * @param { number } sy - Indicates the vertical scale factor. 3703 * @param { number } px - Indicates the pivot on x-axis. 3704 * @param { number } py - Indicates the pivot on y-axis. 3705 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3706 * <br>2. Incorrect parameter types. 3707 * @syscap SystemCapability.Graphics.Drawing 3708 * @since 12 3709 */ 3710 preScale(sx: number, sy: number, px: number, py: number): void; 3711 /** 3712 * Sets matrix to matrix multiplied by matrix constructed from translation (dx, dy). 3713 * This can be thought of as moving the point to be mapped before applying matrix. 3714 * @param { number } dx - Indicates the horizontal translation. 3715 * @param { number } dy - Indicates the vertical translation. 3716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3717 * <br>2. Incorrect parameter types. 3718 * @syscap SystemCapability.Graphics.Drawing 3719 * @since 12 3720 */ 3721 preTranslate(dx: number, dy: number): void; 3722 /** 3723 * Reset matrix to identity. 3724 * @syscap SystemCapability.Graphics.Drawing 3725 * @since 12 3726 */ 3727 reset(): void; 3728 /** 3729 * Maps src array of length count to dst array of equal or greater length. 3730 * This can be thought of as moving the point to be mapped before applying matrix. 3731 * @param { Array<common2D.Point> } src - points to transform. 3732 * @returns { Array<common2D.Point> } Return mapped points array. 3733 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3734 * <br>2. Incorrect parameter types. 3735 * @syscap SystemCapability.Graphics.Drawing 3736 * @since 12 3737 */ 3738 mapPoints(src: Array<common2D.Point>): Array<common2D.Point>; 3739 /** 3740 * Return nine scalar values contained by Matrix. 3741 * @returns { Array<number> } nine scalar values contained by Matrix. 3742 * @syscap SystemCapability.Graphics.Drawing 3743 * @since 12 3744 */ 3745 getAll(): Array<number>; 3746 /** 3747 * Sets dst to bounds of src corners mapped by matrix transformation. 3748 * @param { common2D.Rect } dst - Rect to map from. 3749 * @param { common2D.Rect } src - Rect to map to. 3750 * @returns { boolean } Returns true if the mapped src is equal to the dst; returns false is not equal. 3751 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3752 * <br>2. Incorrect parameter types. 3753 * @syscap SystemCapability.Graphics.Drawing 3754 * @since 12 3755 */ 3756 mapRect(dst: common2D.Rect, src: common2D.Rect): boolean; 3757 /** 3758 * Sets matrix to scale and translate src rect to dst rect. 3759 * @param { common2D.Rect } src - Rect to map from. 3760 * @param { common2D.Rect } dst - Rect to map to. 3761 * @param { ScaleToFit } scaleToFit - Describes how matrix is constructed to map one rect to another. 3762 * @returns { boolean } Returns true if dst is empty, and sets matrix to: 3763 | 0 0 0 | 3764 | 0 0 0 | 3765 | 0 0 1 |. 3766 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3767 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3768 * @syscap SystemCapability.Graphics.Drawing 3769 * @since 12 3770 */ 3771 setRectToRect(src: common2D.Rect, dst: common2D.Rect, scaleToFit: ScaleToFit): boolean; 3772 /** 3773 * Sets Matrix to map src to dst. Count must be zero or greater, and four or less. 3774 * @param { Array<common2D.Point> } src - Point to map from 3775 * @param { Array<common2D.Point> } dst - Point to map to 3776 * @param { number } count - Number of Point in src and dst 3777 * @returns { boolean } Returns true if Matrix was constructed successfully 3778 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3779 * <br>2. Incorrect parameter types. 3780 * @syscap SystemCapability.Graphics.Drawing 3781 * @since 12 3782 */ 3783 setPolyToPoly(src: Array<common2D.Point>, dst: Array<common2D.Point>, count: number): boolean; 3784 } 3785 3786 /** 3787 * Describes a scale-to-fit values. 3788 * @enum { number } 3789 * @syscap SystemCapability.Graphics.Drawing 3790 * @since 12 3791 */ 3792 enum ScaleToFit { 3793 /** 3794 * Scales in x and y to fill destination Rect. 3795 * @syscap SystemCapability.Graphics.Drawing 3796 * @since 12 3797 */ 3798 FILL_SCALE_TO_FIT = 0, 3799 3800 /** 3801 * Scales and aligns to left and top. 3802 * @syscap SystemCapability.Graphics.Drawing 3803 * @since 12 3804 */ 3805 START_SCALE_TO_FIT = 1, 3806 3807 /** 3808 * Scales and aligns to center. 3809 * @syscap SystemCapability.Graphics.Drawing 3810 * @since 12 3811 */ 3812 CENTER_SCALE_TO_FIT = 2, 3813 3814 /** 3815 * Scales and aligns to right and bottom. 3816 * @syscap SystemCapability.Graphics.Drawing 3817 * @since 12 3818 */ 3819 END_SCALE_TO_FIT = 3 3820 } 3821 3822 /** 3823 * Describes a region object. 3824 * @syscap SystemCapability.Graphics.Drawing 3825 * @since 12 3826 */ 3827 class Region { 3828 /** 3829 * Determines whether the test point is in the region. 3830 * @param { number } x - Indicates the x coordinate of the point. The parameter must be an integer. 3831 * @param { number } y - Indicates the y coordinate of the point. The parameter must be an integer. 3832 * @returns { boolean } Returns true if (x, y) is inside region; returns false otherwise. 3833 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3834 * <br>2. Incorrect parameter types. 3835 * @syscap SystemCapability.Graphics.Drawing 3836 * @since 12 3837 */ 3838 isPointContained(x: number, y:number): boolean; 3839 3840 /** 3841 * Determines whether other region is in the region. 3842 * @param { Region } other - Other region object. 3843 * @returns { boolean } Returns true if other region is completely inside the region object; 3844 * <br>returns false otherwise. 3845 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3846 * <br>2. Incorrect parameter types. 3847 * @syscap SystemCapability.Graphics.Drawing 3848 * @since 12 3849 */ 3850 isRegionContained(other: Region): boolean; 3851 3852 /** 3853 * Replaces region with the result of region op region. 3854 * @param { Region } region - Region object. 3855 * @param { RegionOp } regionOp - Operation type. 3856 * @returns { boolean } Returns true if replaced region is not empty; returns false otherwise. 3857 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3858 * <br>2. Incorrect parameter types. 3859 * @syscap SystemCapability.Graphics.Drawing 3860 * @since 12 3861 */ 3862 op(region: Region, regionOp: RegionOp): boolean; 3863 3864 /** 3865 * Determines whether rect and region does not intersect. 3866 * @param { number } left - Left position of rectangle. The parameter must be an integer. 3867 * @param { number } top - Top position of rectangle. The parameter must be an integer. 3868 * @param { number } right - Right position of rectangle. The parameter must be an integer. 3869 * @param { number } bottom - Bottom position of rectangle. The parameter must be an integer. 3870 * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. 3871 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3872 * <br>2. Incorrect parameter types. 3873 * @syscap SystemCapability.Graphics.Drawing 3874 * @since 12 3875 */ 3876 quickReject(left: number, top: number, right: number, bottom: number): boolean; 3877 3878 /** 3879 * Sets the region to match outline of path within clip. 3880 * @param { Path } path - Providing outline. 3881 * @param { Region } clip - Region object. 3882 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 3883 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3884 * <br>2. Incorrect parameter types. 3885 * @syscap SystemCapability.Graphics.Drawing 3886 * @since 12 3887 */ 3888 setPath(path: Path, clip: Region): boolean; 3889 3890 /** 3891 * Sets a rect to region. 3892 * @param { number } left - Left position of rectangle. The parameter must be an integer. 3893 * @param { number } top - Top position of rectangle. The parameter must be an integer. 3894 * @param { number } right - Right position of rectangle. The parameter must be an integer. 3895 * @param { number } bottom - Bottom position of rectangle. The parameter must be an integer. 3896 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 3897 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3898 * <br>2. Incorrect parameter types. 3899 * @syscap SystemCapability.Graphics.Drawing 3900 * @since 12 3901 */ 3902 setRect(left: number, top: number, right: number, bottom: number): boolean; 3903 } 3904 3905 /** 3906 * Enumerates of operations when two regions are combined. 3907 * @enum { number } 3908 * @syscap SystemCapability.Graphics.Drawing 3909 * @since 12 3910 */ 3911 enum RegionOp { 3912 /** 3913 * Difference operation. 3914 * @syscap SystemCapability.Graphics.Drawing 3915 * @since 12 3916 */ 3917 DIFFERENCE = 0, 3918 3919 /** 3920 * Intersect operation. 3921 * @syscap SystemCapability.Graphics.Drawing 3922 * @since 12 3923 */ 3924 INTERSECT = 1, 3925 3926 /** 3927 * Union operation. 3928 * @syscap SystemCapability.Graphics.Drawing 3929 * @since 12 3930 */ 3931 UNION = 2, 3932 3933 /** 3934 * Xor operation. 3935 * @syscap SystemCapability.Graphics.Drawing 3936 * @since 12 3937 */ 3938 XOR = 3, 3939 3940 /** 3941 * Reverse difference operation. 3942 * @syscap SystemCapability.Graphics.Drawing 3943 * @since 12 3944 */ 3945 REVERSE_DIFFERENCE = 4, 3946 3947 /** 3948 * Replace operation. 3949 * @syscap SystemCapability.Graphics.Drawing 3950 * @since 12 3951 */ 3952 REPLACE = 5 3953 } 3954 3955 /** 3956 * Enumerates of corner radius position. 3957 * 3958 * @enum { number } 3959 * @syscap SystemCapability.Graphics.Drawing 3960 * @since 12 3961 */ 3962 enum CornerPos { 3963 /** 3964 * Index of top-left corner radius. 3965 * @syscap SystemCapability.Graphics.Drawing 3966 * @since 12 3967 */ 3968 TOP_LEFT_POS = 0, 3969 3970 /** 3971 * Index of top-right corner radius. 3972 * @syscap SystemCapability.Graphics.Drawing 3973 * @since 12 3974 */ 3975 TOP_RIGHT_POS = 1, 3976 3977 /** 3978 * Index of bottom-right corner radius. 3979 * @syscap SystemCapability.Graphics.Drawing 3980 * @since 12 3981 */ 3982 BOTTOM_RIGHT_POS = 2, 3983 3984 /** 3985 * Index of bottom-left corner radius. 3986 * @syscap SystemCapability.Graphics.Drawing 3987 * @since 12 3988 */ 3989 BOTTOM_LEFT_POS = 3 3990 } 3991 3992 /** 3993 * Enumeration defines the constraint type. 3994 * 3995 * @enum { number } 3996 * @syscap SystemCapability.Graphics.Drawing 3997 * @since 12 3998 */ 3999 enum SrcRectConstraint { 4000 4001 /** 4002 * Using sampling only inside bounds in a slower manner. 4003 * 4004 * @syscap SystemCapability.Graphics.Drawing 4005 * @since 12 4006 */ 4007 STRICT = 0, 4008 4009 /** 4010 * Using sampling outside bounds in a faster manner. 4011 * 4012 * @syscap SystemCapability.Graphics.Drawing 4013 * @since 12 4014 */ 4015 FAST = 1 4016 } 4017 4018 /** 4019 * The Tool class for drawing. 4020 * 4021 * @syscap SystemCapability.Graphics.Drawing 4022 * @since 15 4023 */ 4024 class Tool { 4025 /** 4026 * Make a common2D.Color variable that describes the color from ResourceColor. 4027 * @param { ResourceColor } resourceColor - ResourceColor. 4028 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 4029 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 4030 * <br>2. Incorrect parameter types. 4031 * @syscap SystemCapability.Graphics.Drawing 4032 * @since 15 4033 */ 4034 static makeColorFromResourceColor(resourceColor: ResourceColor): common2D.Color; 4035 } 4036} 4037 4038export default drawing; 4039