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