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 * If radius is zero or less, nothing is drawn. If circle is stroked, use pen to 989 * stroke width describes the line thickness, else use brush to fill the circle. 990 * @param { number } x - X coordinate of the circle center. 991 * @param { number } y - Y coordinate of the circle center. 992 * @param { number } radius - The radius of the circle must be greater than 0. 993 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 994 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 995 * @syscap SystemCapability.Graphics.Drawing 996 * @since 11 997 */ 998 drawCircle(x: number, y: number, radius: number): void; 999 1000 /** 1001 * Draw a pixelmap, with the upper left corner at (left, top). 1002 * @param { image.PixelMap } pixelmap - PixelMap. 1003 * @param { number } left - Left side of image. 1004 * @param { number } top - Top side of image. 1005 * @throws { BusinessError } 401 - Parameter error. 1006 * @syscap SystemCapability.Graphics.Drawing 1007 * @since 11 1008 */ 1009 /** 1010 * Draw a pixelmap, with the upper left corner at (left, top). 1011 * @param { image.PixelMap } pixelmap - PixelMap. 1012 * @param { number } left - Left side of image. 1013 * @param { number } top - Top side of image. 1014 * @param { SamplingOptions } samplingOptions - SamplingOptions used to describe the sampling mode. 1015 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1016 * <br>2. Incorrect parameter types. 1017 * @syscap SystemCapability.Graphics.Drawing 1018 * @since 12 1019 */ 1020 drawImage(pixelmap: image.PixelMap, left: number, top: number, samplingOptions?: SamplingOptions): void; 1021 1022 /** 1023 * Draws the specified source image onto the canvas, 1024 * scaled and translated to the destination rectangle. 1025 * @param { image.PixelMap } pixelmap - The source image. 1026 * @param { common2D.Rect } dstRect - The area of destination canvas. 1027 * @param { SamplingOptions } samplingOptions - SamplingOptions used to describe the sampling mode. 1028 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1029 * <br>2. Incorrect parameter types. 1030 * @syscap SystemCapability.Graphics.Drawing 1031 * @since 12 1032 */ 1033 drawImageRect(pixelmap: image.PixelMap, dstRect: common2D.Rect, samplingOptions?: SamplingOptions): void; 1034 1035 /** 1036 * Draws the specified source rectangle of the image onto the canvas, 1037 * scaled and translated to the destination rectangle. 1038 * @param { image.PixelMap } pixelmap - The source image. 1039 * @param { common2D.Rect } srcRect - The area of source image. 1040 * @param { common2D.Rect } dstRect - The area of destination canvas. 1041 * @param { SamplingOptions } samplingOptions - SamplingOptions used to describe the sampling mode. 1042 * @param { SrcRectConstraint } constraint - Constraint type. The default value is STRICT. 1043 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1044 * <br>2. Incorrect parameter types. 1045 * @syscap SystemCapability.Graphics.Drawing 1046 * @since 12 1047 */ 1048 drawImageRectWithSrc(pixelmap: image.PixelMap, srcRect: common2D.Rect, dstRect: common2D.Rect, 1049 samplingOptions?: SamplingOptions, constraint?: SrcRectConstraint): void; 1050 1051 /** 1052 * Fills clip with color color. Mode determines how ARGB is combined with destination. 1053 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 1054 * @param { BlendMode } blendMode - Used to combine source color and destination. The default value is SRC_OVER. 1055 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1056 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1057 * @syscap SystemCapability.Graphics.Drawing 1058 * @since 11 1059 */ 1060 drawColor(color: common2D.Color, blendMode?: BlendMode): void; 1061 1062 /** 1063 * Fills the clipped rectangle with the specified ARGB color. 1064 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 1065 * @param { number } red - Red channel of color. The range of red must be [0, 255]. 1066 * @param { number } green - Green channel of color. The range of green must be [0, 255]. 1067 * @param { number } blue - Blue channel of color. The range of blue must be [0, 255]. 1068 * @param { BlendMode } blendMode - Used to combine source color and destination. The default value is SRC_OVER. 1069 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1070 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1071 * @syscap SystemCapability.Graphics.Drawing 1072 * @since 12 1073 */ 1074 drawColor(alpha: number, red: number, green: number, blue: number, blendMode?: BlendMode): void; 1075 1076 /** 1077 * Draws an oval. 1078 * @param { common2D.Rect } oval - The bounds of the oval is described by a rect. 1079 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1080 * <br>2. Incorrect parameter types. 1081 * @syscap SystemCapability.Graphics.Drawing 1082 * @since 12 1083 */ 1084 drawOval(oval: common2D.Rect): void; 1085 1086 /** 1087 * Draws an arc. 1088 * @param { common2D.Rect } arc - The bounds of the arc is described by a rect. 1089 * @param { number } startAngle - Indicates the startAngle of the arc. 1090 * @param { number } sweepAngle - Indicates the sweepAngle of the arc. 1091 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1092 * <br>2. Incorrect parameter types. 1093 * @syscap SystemCapability.Graphics.Drawing 1094 * @since 12 1095 */ 1096 drawArc(arc: common2D.Rect, startAngle: number, sweepAngle: number): void; 1097 1098 /** 1099 * Draw a point. 1100 * @param { number } x - X coordinate position of the point. 1101 * @param { number } y - Y coordinate position of the point. 1102 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1103 * <br>2. Incorrect parameter types. 1104 * @syscap SystemCapability.Graphics.Drawing 1105 * @since 11 1106 */ 1107 drawPoint(x: number, y: number): void; 1108 1109 /** 1110 * Draws point array as separate point, line segment or open polygon according to given point mode. 1111 * @param { Array<common2D.Point> } points - Points array. 1112 * @param { PointMode } mode - Draws points enum method. The default value is POINTS. 1113 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1114 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1115 * @syscap SystemCapability.Graphics.Drawing 1116 * @since 12 1117 */ 1118 drawPoints(points: Array<common2D.Point>, mode?: PointMode): void; 1119 1120 /** 1121 * Draws a path. 1122 * @param { Path } path - Path to draw. 1123 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1124 * <br>2. Incorrect parameter types. 1125 * @syscap SystemCapability.Graphics.Drawing 1126 * @since 11 1127 */ 1128 drawPath(path: Path): void; 1129 1130 /** 1131 * Draws line segment from startPt to endPt. 1132 * @param { number } x0 - X coordinate of the start point of the line segment. 1133 * @param { number } y0 - Y coordinate of the start point of the line segment. 1134 * @param { number } x1 - X coordinate of the end point of the line segment. 1135 * @param { number } y1 - Y coordinate of the end point of the line segment. 1136 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1137 * <br>2. Incorrect parameter types. 1138 * @syscap SystemCapability.Graphics.Drawing 1139 * @since 11 1140 */ 1141 drawLine(x0: number, y0: number, x1: number, y1: number): void; 1142 1143 /** 1144 * Draws a single character. 1145 * @param { string } text - A string containing only a single character. 1146 * @param { Font } font - Font object. 1147 * @param { number } x - X coordinate of the single character start point. 1148 * @param { number } y - Y coordinate of the single character start point. 1149 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1150 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1151 * @syscap SystemCapability.Graphics.Drawing 1152 * @since 12 1153 */ 1154 drawSingleCharacter(text: string, font: Font, x: number, y: number): void; 1155 1156 /** 1157 * Draws a textBlob 1158 * @param { TextBlob } blob - TextBlob to draw. 1159 * @param { number } x - X coordinate of the text start point. 1160 * @param { number } y - Y coordinate of the text start point. 1161 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1162 * <br>2. Incorrect parameter types. 1163 * @syscap SystemCapability.Graphics.Drawing 1164 * @since 11 1165 */ 1166 drawTextBlob(blob: TextBlob, x: number, y: number): void; 1167 1168 /** 1169 * Draws the pixelmap base on the mesh which is evenly distributed across the pixelmap. 1170 * @param { image.PixelMap } pixelmap - The pixelmap to draw using the mesh. 1171 * @param { number } meshWidth - The number of columns in the mesh. 1172 * @param { number } meshHeight - The number of rows in the mesh. 1173 * @param { Array<number> } vertices - Array of vertices, specifying where the mesh should be drawn. 1174 * @param { number } vertOffset - Number of vert elements to skip before drawing. 1175 * @param { Array<number> } colors - Array of colors, specifying a color at each vertex. 1176 * @param { number } colorOffset - Number of color elements to skip before drawing. 1177 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1178 * <br>2. Incorrect parameter types. 1179 * @syscap SystemCapability.Graphics.Drawing 1180 * @since 12 1181 */ 1182 drawPixelMapMesh(pixelmap: image.PixelMap, meshWidth: number, meshHeight: number, 1183 vertices: Array<number>, vertOffset: number, colors: Array<number>, colorOffset: number): void; 1184 1185 /** 1186 * Draws a region. 1187 * @param { Region } region - Region object. 1188 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1189 * <br>2. Incorrect parameter types. 1190 * @syscap SystemCapability.Graphics.Drawing 1191 * @since 12 1192 */ 1193 drawRegion(region: Region): void; 1194 1195 /** 1196 * Set pen to a canvas. 1197 * @param { Pen } pen - object. 1198 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1199 * <br>2. Incorrect parameter types. 1200 * @syscap SystemCapability.Graphics.Drawing 1201 * @since 11 1202 */ 1203 attachPen(pen: Pen): void; 1204 1205 /** 1206 * Set brush to a canvas. 1207 * @param { Brush } brush - Object. 1208 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1209 * <br>2. Incorrect parameter types. 1210 * @syscap SystemCapability.Graphics.Drawing 1211 * @since 11 1212 */ 1213 attachBrush(brush: Brush): void; 1214 1215 /** 1216 * Unset pen to a canvas. 1217 * @syscap SystemCapability.Graphics.Drawing 1218 * @since 11 1219 */ 1220 detachPen(): void; 1221 1222 /** 1223 * Unset brush to a canvas. 1224 * @syscap SystemCapability.Graphics.Drawing 1225 * @since 11 1226 */ 1227 detachBrush(): void; 1228 1229 /** 1230 * Saves the current canvas status (canvas matrix) to the top of the stack. 1231 * @returns { number } Return the number of saved states. 1232 * @syscap SystemCapability.Graphics.Drawing 1233 * @since 12 1234 */ 1235 save(): number; 1236 1237 /** 1238 * Saves matrix and clip, and allocates a bitmap for subsequent drawing. 1239 * Calling restore discards changes to matrix and clip, and draws the bitmap. 1240 * @param { common2D.Rect | null} rect - Optional layer size. The default value is null. 1241 * @param { Brush | null} brush - Optional brush effect used to draw the layer. The default value is null. 1242 * @returns { number } Return the number of saved states before this call. 1243 * @throws { BusinessError } 401 - Parameter error. Possible causes: Mandatory parameters are left unspecified. 1244 * @syscap SystemCapability.Graphics.Drawing 1245 * @since 12 1246 */ 1247 saveLayer(rect?: common2D.Rect | null, brush?: Brush | null): number; 1248 1249 /** 1250 * Clears a canvas by using a specified color. 1251 * @param { common2D.Color } color - Indicates the color, which is a 32-bit (ARGB) variable. 1252 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1253 * <br>2. Incorrect parameter types. 1254 * @syscap SystemCapability.Graphics.Drawing 1255 * @since 12 1256 */ 1257 clear(color: common2D.Color): void; 1258 1259 /** 1260 * Restores the canvas status (canvas matrix) saved on the top of the stack. 1261 * @syscap SystemCapability.Graphics.Drawing 1262 * @since 12 1263 */ 1264 restore(): void; 1265 1266 /** 1267 * Restores the specific number of the canvas status (canvas matrix) saved in the stack. 1268 * @param { number } count - Depth of state stack to restore. 1269 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1270 * <br>2. Incorrect parameter types. 1271 * @syscap SystemCapability.Graphics.Drawing 1272 * @since 12 1273 */ 1274 restoreToCount(count: number): void; 1275 1276 /** 1277 * Gets the number of the canvas status (canvas matrix) saved in the stack. 1278 * @returns { number } Return represent depth of save state stack. 1279 * @syscap SystemCapability.Graphics.Drawing 1280 * @since 12 1281 */ 1282 getSaveCount(): number; 1283 1284 /** 1285 * Gets the width of a canvas. 1286 * @returns { number } Return the width of a canvas. 1287 * @syscap SystemCapability.Graphics.Drawing 1288 * @since 12 1289 */ 1290 getWidth(): number; 1291 1292 /** 1293 * Gets the height of a canvas. 1294 * @returns { number } Return the height of a canvas. 1295 * @syscap SystemCapability.Graphics.Drawing 1296 * @since 12 1297 */ 1298 getHeight(): number; 1299 1300 /** 1301 * Gets the bounds of clip of a canvas. 1302 * @returns { common2D.Rect } Rect object. 1303 * @syscap SystemCapability.Graphics.Drawing 1304 * @since 12 1305 */ 1306 getLocalClipBounds(): common2D.Rect; 1307 1308 /** 1309 * Gets a 3x3 matrix of the transform from local coordinates to 'device'. 1310 * @returns { Matrix } Matrix object. 1311 * @syscap SystemCapability.Graphics.Drawing 1312 * @since 12 1313 */ 1314 getTotalMatrix(): Matrix; 1315 1316 /** 1317 * Scales by sx on the x-axis and sy on the y-axis. 1318 * @param { number } sx - Indicates the amount to scale on x-axis. 1319 * @param { number } sy - Indicates the amount to scale on y-axis. 1320 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1321 * <br>2. Incorrect parameter types. 1322 * @syscap SystemCapability.Graphics.Drawing 1323 * @since 12 1324 */ 1325 scale(sx: number, sy: number): void; 1326 1327 /** 1328 * Skews by sx on the x-axis and sy on the y-axis. 1329 * @param { number } sx - Indicates the value skew transformation on x-axis. 1330 * @param { number } sy - Indicates the value skew transformation on y-axis. 1331 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1332 * <br>2. Incorrect parameter types. 1333 * @syscap SystemCapability.Graphics.Drawing 1334 * @since 12 1335 */ 1336 skew(sx: number, sy: number) : void; 1337 1338 /** 1339 * Rotates by degrees, positive degrees rotates clockwise. 1340 * @param { number } degrees - Indicates the amount to rotate, in degrees. 1341 * @param { number } sx - Indicates the x-axis value of the point to rotate about. 1342 * @param { number } sy - Indicates the y-axis value of the point to rotate about. 1343 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1344 * <br>2. Incorrect parameter types. 1345 * @syscap SystemCapability.Graphics.Drawing 1346 * @since 12 1347 */ 1348 rotate(degrees: number, sx: number, sy: number) : void; 1349 1350 /** 1351 * Translates by dx along the x-axis and dy along the y-axis. 1352 * @param { number } dx - Indicates the distance to translate on x-axis. 1353 * @param { number } dy - Indicates the distance to translate on y-axis. 1354 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1355 * <br>2. Incorrect parameter types. 1356 * @syscap SystemCapability.Graphics.Drawing 1357 * @since 12 1358 */ 1359 translate(dx: number, dy: number): void; 1360 1361 /** 1362 * Replaces the clipping area with the intersection or difference of the current clipping area and path, 1363 * and use a clipping edge that is aliased or anti-aliased. 1364 * @param { Path } path - To combine with clip. 1365 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1366 * @param { boolean } doAntiAlias - True if clip is to be anti-aliased. The default value is false. 1367 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1368 * <br>2. Incorrect parameter types. 1369 * @syscap SystemCapability.Graphics.Drawing 1370 * @since 12 1371 */ 1372 clipPath(path: Path, clipOp?: ClipOp, doAntiAlias?: boolean): void; 1373 1374 /** 1375 * Replaces the clipping area with the intersection or difference between the 1376 * current clipping area and Rect, and use a clipping edge that is aliased or anti-aliased. 1377 * @param { common2D.Rect } rect - To combine with clipping area. 1378 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1379 * @param { boolean } doAntiAlias - True if clip is to be anti-aliased. The default value is false. 1380 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1381 * <br>2. Incorrect parameter types. 1382 * @syscap SystemCapability.Graphics.Drawing 1383 * @since 12 1384 */ 1385 clipRect(rect: common2D.Rect, clipOp?: ClipOp, doAntiAlias?: boolean): void; 1386 1387 /** 1388 * Uses the passed matrix to transforming the geometry, then use existing matrix. 1389 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 1390 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1391 * <br>2. Incorrect parameter types. 1392 * @syscap SystemCapability.Graphics.Drawing 1393 * @since 12 1394 */ 1395 concatMatrix(matrix: Matrix): void; 1396 1397 /** 1398 * Replace the clipping area with the intersection or difference of the 1399 * current clipping area and Region, and use a clipping edge that is aliased or anti-aliased. 1400 * @param { Region } region - Region object. 1401 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1402 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1403 * <br>2. Incorrect parameter types. 1404 * @syscap SystemCapability.Graphics.Drawing 1405 * @since 12 1406 */ 1407 clipRegion(region: Region, clipOp?: ClipOp): void; 1408 1409 /** 1410 * Replaces the clipping area with the intersection or difference between the 1411 * current clipping area and RoundRect, and use a clipping edge that is aliased or anti-aliased. 1412 * @param { RoundRect } roundRect - To combine with clipping area. 1413 * @param { ClipOp } clipOp - Indicates the operation to apply to clip. The default value is intersect. 1414 * @param { boolean } doAntiAlias - True if clip is to be anti-aliased. The default value is false. 1415 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1416 * <br>2. Incorrect parameter types. 1417 * @syscap SystemCapability.Graphics.Drawing 1418 * @since 12 1419 */ 1420 clipRoundRect(roundRect: RoundRect, clipOp?: ClipOp, doAntiAlias?: boolean): void; 1421 1422 /** 1423 * Checks whether the drawable area is empty. 1424 * @returns { boolean } Returns true if drawable area is empty. 1425 * @syscap SystemCapability.Graphics.Drawing 1426 * @since 12 1427 */ 1428 isClipEmpty(): boolean; 1429 1430 /** 1431 * Sets matrix of canvas. 1432 * @param { Matrix } matrix - Declares functions related to the matrix object in the drawing module. 1433 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1434 * <br>2. Incorrect parameter types. 1435 * @syscap SystemCapability.Graphics.Drawing 1436 * @since 12 1437 */ 1438 setMatrix(matrix: Matrix): void; 1439 1440 /** 1441 * Sets matrix of canvas to the identity matrix. 1442 * @syscap SystemCapability.Graphics.Drawing 1443 * @since 12 1444 */ 1445 resetMatrix(): void; 1446 } 1447 1448 /** 1449 * Enumerates clip operations. 1450 * 1451 * @enum { number } 1452 * @syscap SystemCapability.Graphics.Drawing 1453 * @since 12 1454 */ 1455 enum ClipOp { 1456 /** 1457 * Clips with difference. 1458 * @syscap SystemCapability.Graphics.Drawing 1459 * @since 12 1460 */ 1461 DIFFERENCE = 0, 1462 /** 1463 * Clips with intersection. 1464 * @syscap SystemCapability.Graphics.Drawing 1465 * @since 12 1466 */ 1467 INTERSECT = 1, 1468 } 1469 1470 /** 1471 * Provide a description of the type and position of the text. 1472 * @typedef TextBlobRunBuffer 1473 * @syscap SystemCapability.Graphics.Drawing 1474 * @since 11 1475 */ 1476 interface TextBlobRunBuffer { 1477 /** 1478 * Text model. 1479 * @type { number } 1480 * @syscap SystemCapability.Graphics.Drawing 1481 * @since 11 1482 */ 1483 glyph: number; 1484 /** 1485 * X-coordinate of the text start point. 1486 * @type { number } 1487 * @syscap SystemCapability.Graphics.Drawing 1488 * @since 11 1489 */ 1490 positionX: number; 1491 /** 1492 * Y-coordinate of the text start point. 1493 * @type { number } 1494 * @syscap SystemCapability.Graphics.Drawing 1495 * @since 11 1496 */ 1497 positionY: number; 1498 } 1499 1500 /** 1501 * Encoding type of the description text. 1502 * 1503 * @enum { number } 1504 * @syscap SystemCapability.Graphics.Drawing 1505 * @since 11 1506 */ 1507 enum TextEncoding { 1508 /** 1509 * Use 1 byte to represent UTF-8 or ASCII 1510 * @syscap SystemCapability.Graphics.Drawing 1511 * @since 11 1512 */ 1513 TEXT_ENCODING_UTF8 = 0, 1514 /** 1515 * Use 2 bytes to represent most of unicode 1516 * @syscap SystemCapability.Graphics.Drawing 1517 * @since 11 1518 */ 1519 TEXT_ENCODING_UTF16 = 1, 1520 /** 1521 * Use 4 bytes to represent all unicode. 1522 * @syscap SystemCapability.Graphics.Drawing 1523 * @since 11 1524 */ 1525 TEXT_ENCODING_UTF32 = 2, 1526 /** 1527 * Use 2 bytes to represent the glyph index. 1528 * @syscap SystemCapability.Graphics.Drawing 1529 * @since 11 1530 */ 1531 TEXT_ENCODING_GLYPH_ID = 3, 1532 } 1533 1534 /** 1535 * Provide a description of the text 1536 * 1537 * class TextBlob 1538 * @syscap SystemCapability.Graphics.Drawing 1539 * @since 11 1540 */ 1541 class TextBlob { 1542 /** 1543 * Create a textblob from a string 1544 * @param { string } text - Drawn glyph content. 1545 * @param { Font } font - Specify text size, font, text scale, etc. 1546 * @param { TextEncoding } encoding - The default value is TEXT_ENCODING_UTF8. 1547 * @returns { TextBlob } TextBlob object. 1548 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1549 * <br>2. Incorrect parameter types. 1550 * @static 1551 * @syscap SystemCapability.Graphics.Drawing 1552 * @since 11 1553 */ 1554 static makeFromString(text: string, font: Font, encoding?: TextEncoding): TextBlob; 1555 1556 /** 1557 * Create a textblob from a string, each element of which is located at the given positions. 1558 * @param { string } text - Drawn glyph content. 1559 * @param { number } len - string length, value must equal to points length. 1560 * @param { common2D.Point[] } points - Position coordinates of a textblob elements. 1561 * @param { Font } font - Specify text size, font, text scale, etc. 1562 * @returns { TextBlob } TextBlob object. 1563 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1564 * <br>2. Incorrect parameter types. 1565 * @static 1566 * @syscap SystemCapability.Graphics.Drawing 1567 * @since 12 1568 */ 1569 static makeFromPosText(text: string, len: number, points: common2D.Point[], font: Font): TextBlob; 1570 1571 /** 1572 * Creating a textblob object based on RunBuffer information 1573 * @param { Array<TextBlobRunBuffer> } pos - The array of TextBlobRunBuffer. 1574 * @param { Font } font - Font used for this run. 1575 * @param { common2D.Rect } bounds - Optional run bounding box. The default value is null; 1576 * @returns { TextBlob } TextBlob object. 1577 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1578 * <br>2. Incorrect parameter types. 1579 * @static 1580 * @syscap SystemCapability.Graphics.Drawing 1581 * @since 11 1582 */ 1583 static makeFromRunBuffer(pos: Array<TextBlobRunBuffer>, font: Font, bounds?: common2D.Rect): TextBlob; 1584 1585 /** 1586 * Returns the bounding rectangle shape 1587 * @returns { common2D.Rect } Rect object. 1588 * @syscap SystemCapability.Graphics.Drawing 1589 * @since 11 1590 */ 1591 bounds(): common2D.Rect; 1592 1593 /** 1594 * Returns an unique identifier for a textblob. 1595 * @returns { number } Unique ID. 1596 * @syscap SystemCapability.Graphics.Drawing 1597 * @since 12 1598 */ 1599 uniqueID(): number; 1600 } 1601 1602 /** 1603 * The Typeface class specifies the typeface and intrinsic style of a font. 1604 * 1605 * @syscap SystemCapability.Graphics.Drawing 1606 * @since 11 1607 */ 1608 class Typeface { 1609 /** 1610 * Get the family name for this typeface. 1611 * @returns { string } Family name. 1612 * @syscap SystemCapability.Graphics.Drawing 1613 * @since 11 1614 */ 1615 getFamilyName(): string; 1616 1617 /** 1618 * Generate typeface from file. 1619 * @param { string } filePath - file path for typeface. 1620 * @returns { Typeface } Typeface. 1621 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1622 * <br>2. Incorrect parameter types. 1623 * @syscap SystemCapability.Graphics.Drawing 1624 * @since 12 1625 */ 1626 static makeFromFile(filePath: string): Typeface; 1627 } 1628 1629 /** 1630 * Enumerates text edging types. 1631 * 1632 * @enum { number } 1633 * @syscap SystemCapability.Graphics.Drawing 1634 * @since 12 1635 */ 1636 enum FontEdging { 1637 /** 1638 * Uses anti aliasing, default value. 1639 * @syscap SystemCapability.Graphics.Drawing 1640 * @since 12 1641 */ 1642 ALIAS = 0, 1643 1644 /** 1645 * Uses sub-pixel anti aliasing. 1646 * @syscap SystemCapability.Graphics.Drawing 1647 * @since 12 1648 */ 1649 ANTI_ALIAS = 1, 1650 1651 /** 1652 * Uses sub-pixel anti aliasing and enable sub-pixel localization. 1653 * @syscap SystemCapability.Graphics.Drawing 1654 * @since 12 1655 */ 1656 SUBPIXEL_ANTI_ALIAS = 2, 1657 } 1658 1659 /** 1660 * Enumerates text hinting types. 1661 * 1662 * @enum { number } 1663 * @syscap SystemCapability.Graphics.Drawing 1664 * @since 12 1665 */ 1666 enum FontHinting { 1667 /** 1668 * Not use text hinting. 1669 * @syscap SystemCapability.Graphics.Drawing 1670 * @since 12 1671 */ 1672 NONE = 0, 1673 1674 /** 1675 * Uses slight text hinting. 1676 * @syscap SystemCapability.Graphics.Drawing 1677 * @since 12 1678 */ 1679 SLIGHT = 1, 1680 1681 /** 1682 * Uses normal text hinting. 1683 * @syscap SystemCapability.Graphics.Drawing 1684 * @since 12 1685 */ 1686 NORMAL = 2, 1687 1688 /** 1689 * Uses full text hinting. 1690 * @syscap SystemCapability.Graphics.Drawing 1691 * @since 12 1692 */ 1693 FULL = 3, 1694 } 1695 1696 /** 1697 * Font controls options applied when drawing and measuring text. 1698 * 1699 * @syscap SystemCapability.Graphics.Drawing 1700 * @since 11 1701 */ 1702 class Font { 1703 /** 1704 * Requests, but does not require, that glyphs respect sub-pixel positioning. 1705 * @param { boolean } isSubpixel - Setting for sub-pixel positioning. 1706 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1707 * <br>2. Incorrect parameter types. 1708 * @syscap SystemCapability.Graphics.Drawing 1709 * @since 11 1710 */ 1711 enableSubpixel(isSubpixel: boolean): void; 1712 1713 /** 1714 * Increases stroke width when creating glyph bitmaps to approximate a bold typeface. 1715 * @param { boolean } isEmbolden - Setting for bold approximation. 1716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1717 * <br>2. Incorrect parameter types. 1718 * @syscap SystemCapability.Graphics.Drawing 1719 * @since 11 1720 */ 1721 enableEmbolden(isEmbolden: boolean): void; 1722 1723 /** 1724 * Requests linearly scalable font and glyph metrics. 1725 * @param { boolean } isLinearMetrics - Setting for linearly scalable font and glyph metrics. 1726 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1727 * <br>2. Incorrect parameter types. 1728 * @syscap SystemCapability.Graphics.Drawing 1729 * @since 11 1730 */ 1731 enableLinearMetrics(isLinearMetrics: boolean): void; 1732 1733 /** 1734 * Sets text size in points. Has no effect if textSize is not greater than or equal to zero. 1735 * @param { number } textSize - Typographic height of text. The height of the text must be greater than 0. 1736 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1737 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1738 * @syscap SystemCapability.Graphics.Drawing 1739 * @since 11 1740 */ 1741 setSize(textSize: number): void; 1742 1743 /** 1744 * Obtains the text size. 1745 * @returns { number } Text size. 1746 * @syscap SystemCapability.Graphics.Drawing 1747 * @since 11 1748 */ 1749 getSize(): number; 1750 1751 /** 1752 * Sets Typeface to font. 1753 * @param { Typeface } typeface - Font and style used to draw text. 1754 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1755 * <br>2. Incorrect parameter types. 1756 * @syscap SystemCapability.Graphics.Drawing 1757 * @since 11 1758 */ 1759 setTypeface(typeface: Typeface): void; 1760 1761 /** 1762 * Get Typeface to font. 1763 * @returns { Typeface } Typeface. 1764 * @syscap SystemCapability.Graphics.Drawing 1765 * @since 11 1766 */ 1767 getTypeface(): Typeface; 1768 1769 /** 1770 * Get fontMetrics associated with typeface. 1771 * @returns { FontMetrics } The fontMetrics value returned to the caller. 1772 * @syscap SystemCapability.Graphics.Drawing 1773 * @since 11 1774 */ 1775 getMetrics(): FontMetrics; 1776 1777 /** 1778 * Measure a single character. 1779 * @param { string } text - A string containing only a single character. 1780 * @returns { number } The width of the single character. 1781 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1782 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1783 * @syscap SystemCapability.Graphics.Drawing 1784 * @since 12 1785 */ 1786 measureSingleCharacter(text: string): number; 1787 /** 1788 * Measure the width of text. 1789 * @param { string } text - Text Symbol Content. 1790 * @param { TextEncoding } encoding - Encoding format. 1791 * @returns { number } The width of text. 1792 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1793 * <br>2. Incorrect parameter types. 1794 * @syscap SystemCapability.Graphics.Drawing 1795 * @since 11 1796 */ 1797 measureText(text: string, encoding: TextEncoding): number; 1798 1799 /** 1800 * Sets text scale on x-axis to font. 1801 * @param { number } scaleX - Text scaleX. 1802 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1803 * <br>2. Incorrect parameter types. 1804 * @syscap SystemCapability.Graphics.Drawing 1805 * @since 12 1806 */ 1807 setScaleX(scaleX: number): void; 1808 1809 /** 1810 * Sets text skew on x-axis to font. 1811 * @param { number } skewX - Text skewX. 1812 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1813 * <br>2. Incorrect parameter types. 1814 * @syscap SystemCapability.Graphics.Drawing 1815 * @since 12 1816 */ 1817 setSkewX(skewX: number): void; 1818 1819 /** 1820 * Sets the edging effect to font. 1821 * @param { FontEdging } edging - Text edging. 1822 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1823 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1824 * @syscap SystemCapability.Graphics.Drawing 1825 * @since 12 1826 */ 1827 setEdging(edging: FontEdging): void; 1828 1829 /** 1830 * Sets the hinting pattern to font. 1831 * @param { FontHinting } hinting - Text hinting. 1832 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1833 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1834 * @syscap SystemCapability.Graphics.Drawing 1835 * @since 12 1836 */ 1837 setHinting(hinting: FontHinting): void; 1838 1839 /** 1840 * Calculates number of glyphs represented by text. 1841 * @param { string } text - Indicates the character storage encoded with text encoding. 1842 * @returns { number } Returns the count of text. 1843 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1844 * <br>2. Incorrect parameter types. 1845 * @syscap SystemCapability.Graphics.Drawing 1846 * @since 12 1847 */ 1848 countText(text: string): number; 1849 1850 /** 1851 * Sets whether the font baselines and pixels alignment when the transformation matrix is axis aligned. 1852 * @param { boolean } isBaselineSnap - Indicates whether the font baselines and pixels alignment. 1853 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1854 * <br>2. Incorrect parameter types. 1855 * @syscap SystemCapability.Graphics.Drawing 1856 * @since 12 1857 */ 1858 setBaselineSnap(isBaselineSnap: boolean): void; 1859 1860 /** 1861 * Gets whether the font baselines and pixels alignment when the transformation matrix is axis aligned. 1862 * @returns { boolean } Returns true if the font baselines and pixels alignment; returns false otherwise. 1863 * @syscap SystemCapability.Graphics.Drawing 1864 * @since 12 1865 */ 1866 isBaselineSnap(): boolean; 1867 1868 /** 1869 * Sets whether to use bitmaps instead of outlines in the object. 1870 * @param { boolean } isEmbeddedBitmaps - Indicates whether to use bitmaps instead of outlines. 1871 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1872 * <br>2. Incorrect parameter types. 1873 * @syscap SystemCapability.Graphics.Drawing 1874 * @since 12 1875 */ 1876 setEmbeddedBitmaps(isEmbeddedBitmaps: boolean): void; 1877 1878 /** 1879 * Gets whether to use bitmaps instead of outlines in the object. 1880 * @returns { boolean } if using bitmaps instead of outlines; returns false otherwise. 1881 * @syscap SystemCapability.Graphics.Drawing 1882 * @since 12 1883 */ 1884 isEmbeddedBitmaps(): boolean; 1885 1886 /** 1887 * Sets whether the font outline is automatically adjusted. 1888 * @param { boolean } isForceAutoHinting - Indicates whether the font outline is automatically adjusted. 1889 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1890 * <br>2. Incorrect parameter types. 1891 * @syscap SystemCapability.Graphics.Drawing 1892 * @since 12 1893 */ 1894 setForceAutoHinting(isForceAutoHinting: boolean): void; 1895 1896 /** 1897 * Gets whether the font outline is automatically adjusted. 1898 * @returns { boolean } Returns true if the font outline is automatically adjusted; returns false otherwise. 1899 * @syscap SystemCapability.Graphics.Drawing 1900 * @since 12 1901 */ 1902 isForceAutoHinting(): boolean; 1903 1904 /** 1905 * Retrieves the advance for each glyph in glyphs. 1906 * @param { Array<number> } glyphs - Array of glyph indices to be measured. 1907 * @returns { Array<number> } Returns the width of each character in a string. 1908 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1909 * <br>2. Incorrect parameter types. 1910 * @syscap SystemCapability.Graphics.Drawing 1911 * @since 12 1912 */ 1913 getWidths(glyphs: Array<number>): Array<number>; 1914 1915 /** 1916 * Gets storage for glyph indexes. 1917 * @param { string } text - Indicates the character storage encoded with text encoding. 1918 * @param { number } glyphCount - The number of glyph. The default value is the result of calling countText. 1919 * @returns { Array<number> } Returns the storage for glyph indices. 1920 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1921 * <br>2. Incorrect parameter types. 1922 * @syscap SystemCapability.Graphics.Drawing 1923 * @since 12 1924 */ 1925 textToGlyphs(text: string, glyphCount?: number): Array<number>; 1926 1927 /** 1928 * Returns true if glyphs may be drawn at sub-pixel offsets. 1929 * @returns { boolean } True if glyphs may be drawn at sub-pixel offsets. 1930 * @syscap SystemCapability.Graphics.Drawing 1931 * @since 12 1932 */ 1933 isSubpixel(): boolean; 1934 /** 1935 * Returns true if font and glyph metrics are requested to be linearly scalable. 1936 * @returns { boolean } True if font and glyph metrics are requested to be linearly scalable. 1937 * @syscap SystemCapability.Graphics.Drawing 1938 * @since 12 1939 */ 1940 isLinearMetrics(): boolean; 1941 /** 1942 * Returns text skew on x-axis. 1943 * @returns { number } Additional shear on x-axis relative to y-axis. 1944 * @syscap SystemCapability.Graphics.Drawing 1945 * @since 12 1946 */ 1947 getSkewX(): number; 1948 /** 1949 * Gets whether to increase the stroke width to approximate bold fonts. 1950 * @returns { boolean } Returns true to increase the stroke width to approximate bold fonts; 1951 * returns false otherwise. 1952 * @syscap SystemCapability.Graphics.Drawing 1953 * @since 12 1954 */ 1955 isEmbolden(): boolean; 1956 /** 1957 * Returns text scale on x-axis. 1958 * @returns { number } Text horizontal scale. 1959 * @syscap SystemCapability.Graphics.Drawing 1960 * @since 12 1961 */ 1962 getScaleX(): number; 1963 /** 1964 * Gets font hinting pattern. 1965 * @returns { FontHinting } Font hinting level. 1966 * @syscap SystemCapability.Graphics.Drawing 1967 * @since 12 1968 */ 1969 getHinting(): FontHinting; 1970 /** 1971 * Gets font edge pixels pattern. 1972 * @returns { FontEdging } Edge pixels pattern. 1973 * @syscap SystemCapability.Graphics.Drawing 1974 * @since 12 1975 */ 1976 getEdging(): FontEdging; 1977 } 1978 1979 /** 1980 * Indicate when certain metrics are valid; the underline or strikeout metrics may be valid and zero. 1981 * Fonts with embedded bitmaps may not have valid underline or strikeout metrics. 1982 * @enum { number } 1983 * @syscap SystemCapability.Graphics.Drawing 1984 * @since 12 1985 */ 1986 enum FontMetricsFlags { 1987 /** 1988 * Set if underlineThickness of FontMetrics is valid. 1989 * @syscap SystemCapability.Graphics.Drawing 1990 * @since 12 1991 */ 1992 UNDERLINE_THICKNESS_VALID = 1 << 0, 1993 1994 /** 1995 * Set if underlinePosition of FontMetrics is valid. 1996 * @syscap SystemCapability.Graphics.Drawing 1997 * @since 12 1998 */ 1999 UNDERLINE_POSITION_VALID = 1 << 1, 2000 2001 /** 2002 * Set if strikethroughThickness of FontMetrics is valid. 2003 * @syscap SystemCapability.Graphics.Drawing 2004 * @since 12 2005 */ 2006 STRIKETHROUGH_THICKNESS_VALID = 1 << 2, 2007 2008 /** 2009 * Set if strikethroughPosition of FontMetrics is valid. 2010 * @syscap SystemCapability.Graphics.Drawing 2011 * @since 12 2012 */ 2013 STRIKETHROUGH_POSITION_VALID = 1 << 3, 2014 2015 /** 2016 * set if top, bottom, xMin, xMax of FontMetrics invalid. 2017 * @syscap SystemCapability.Graphics.Drawing 2018 * @since 12 2019 */ 2020 BOUNDS_INVALID = 1 << 4, 2021 } 2022 2023 /** 2024 * The metrics of an Font. 2025 * @typedef FontMetrics 2026 * @syscap SystemCapability.Graphics.Drawing 2027 * @since 11 2028 */ 2029 interface FontMetrics { 2030 /** 2031 * Indicating which metrics are valid. 2032 * @type { ?FontMetricsFlags } 2033 * @syscap SystemCapability.Graphics.Drawing 2034 * @since 12 2035 */ 2036 flags?: FontMetricsFlags; 2037 2038 /** 2039 * Maximum range above the glyph bounding box. 2040 * @type { number } 2041 * @syscap SystemCapability.Graphics.Drawing 2042 * @since 11 2043 */ 2044 top: number; 2045 /** 2046 * Distance Retained Above Baseline. 2047 * @type { number } 2048 * @syscap SystemCapability.Graphics.Drawing 2049 * @since 11 2050 */ 2051 ascent: number; 2052 /** 2053 * The distance that remains below the baseline. 2054 * @type { number } 2055 * @syscap SystemCapability.Graphics.Drawing 2056 * @since 11 2057 */ 2058 descent: number; 2059 /** 2060 * Maximum range below the glyph bounding box. 2061 * @type { number } 2062 * @syscap SystemCapability.Graphics.Drawing 2063 * @since 11 2064 */ 2065 bottom: number; 2066 /** 2067 * Line Spacing. 2068 * @type { number } 2069 * @syscap SystemCapability.Graphics.Drawing 2070 * @since 11 2071 */ 2072 leading: number; 2073 /** 2074 * Average character width, zero if unknown. 2075 * @type { ?number } 2076 * @syscap SystemCapability.Graphics.Drawing 2077 * @since 12 2078 */ 2079 avgCharWidth?: number; 2080 2081 /** 2082 * Maximum character width, zero if unknown. 2083 * @type { ?number } 2084 * @syscap SystemCapability.Graphics.Drawing 2085 * @since 12 2086 */ 2087 maxCharWidth?: number; 2088 2089 /** 2090 * Greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with variable fonts. 2091 * @type { ?number } 2092 * @syscap SystemCapability.Graphics.Drawing 2093 * @since 12 2094 */ 2095 xMin?: number; 2096 2097 /** 2098 * Greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with variable fonts. 2099 * @type { ?number } 2100 * @syscap SystemCapability.Graphics.Drawing 2101 * @since 12 2102 */ 2103 xMax?: number; 2104 2105 /** 2106 * Height of lower-case 'x', zero if unknown, typically negative. 2107 * @type { ?number } 2108 * @syscap SystemCapability.Graphics.Drawing 2109 * @since 12 2110 */ 2111 xHeight?: number; 2112 2113 /** 2114 * Height of an upper-case letter, zero if unknown, typically negative. 2115 * @type { ?number } 2116 * @syscap SystemCapability.Graphics.Drawing 2117 * @since 12 2118 */ 2119 capHeight?: number; 2120 2121 /** 2122 * Underline thickness. 2123 * @type { ?number } 2124 * @syscap SystemCapability.Graphics.Drawing 2125 * @since 12 2126 */ 2127 underlineThickness?: number; 2128 2129 /** 2130 * Distance from baseline to top of stroke, typically positive. 2131 * @type { ?number } 2132 * @syscap SystemCapability.Graphics.Drawing 2133 * @since 12 2134 */ 2135 underlinePosition?: number; 2136 2137 /** 2138 * Strikethrough thickness. 2139 * @type { ?number } 2140 * @syscap SystemCapability.Graphics.Drawing 2141 * @since 12 2142 */ 2143 strikethroughThickness?: number; 2144 2145 /** 2146 * Distance from baseline to bottom of stroke, typically negative. 2147 * @type { ?number } 2148 * @syscap SystemCapability.Graphics.Drawing 2149 * @since 12 2150 */ 2151 strikethroughPosition?: number; 2152 } 2153 2154 /** 2155 * Lattice is the class for dividing an image into grids. 2156 * @syscap SystemCapability.Graphics.Drawing 2157 * @since 12 2158 */ 2159 class Lattice { 2160 /** 2161 * Divide an image into a rectangular grid. Grid entries on even columns and even rows are fixed; 2162 * these entries are always drawn at their original size if the destination is large enough. If the destination 2163 * side is too small to hold the fixed entries, all fixed entries are scaled down to fit. 2164 * The grid entries not on even columns and rows are scaled to fit the remaining space, if any. 2165 * @param { Array<number> } xDivs - X coordinate of values used to divide the image. 2166 * @param { Array<number> } yDivs - Y coordinate of values used to divide the image. 2167 * @param { number } fXCount - Number of x coordinates. Must be >= 0. 2168 * @param { number } fYCount - Number of y coordinates. Must be >= 0. 2169 * @param { common2D.Rect | null } fBounds - Source bounds to draw from. The default value is null. 2170 * @param { Array<RectType> | null } fRectTypes - Array of fill types. The default value is null. 2171 * @param { Array<common2D.Color> | null } fColors - Array of colors. The default value is null. 2172 * @returns { Lattice } Lattice object. 2173 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2174 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2175 * @static 2176 * @syscap SystemCapability.Graphics.Drawing 2177 * @since 12 2178 */ 2179 static createImageLattice(xDivs: Array<number>, yDivs: Array<number>, fXCount: number, fYCount: number, 2180 fBounds?: common2D.Rect | null, fRectTypes?: Array<RectType> | null, fColors?: Array<common2D.Color> | null): Lattice; 2181 } 2182 2183 /** 2184 * Enumerate rect types. Optional setting per rectangular grid entry to make it transparent, 2185 * or to fill the grid entry with a color. only used in Lattice. 2186 * @enum { number } 2187 * @syscap SystemCapability.Graphics.Drawing 2188 * @since 12 2189 */ 2190 enum RectType { 2191 /** 2192 * Draws image into lattice rect. 2193 * @syscap SystemCapability.Graphics.Drawing 2194 * @since 12 2195 */ 2196 DEFAULT = 0, 2197 2198 /** 2199 * Skips lattice rect by making it transparent. 2200 * @syscap SystemCapability.Graphics.Drawing 2201 * @since 12 2202 */ 2203 TRANSPARENT = 1, 2204 2205 /** 2206 * Draws one of fColors into lattice rect. 2207 * @syscap SystemCapability.Graphics.Drawing 2208 * @since 12 2209 */ 2210 FIXEDCOLOR = 2 2211 } 2212 2213 /** 2214 * MaskFilter is the class for object that perform transformations on an alpha-channel mask before drawing it. 2215 * @syscap SystemCapability.Graphics.Drawing 2216 * @since 12 2217 */ 2218 class MaskFilter { 2219 /** 2220 * Makes a MaskFilter with a blur effect. 2221 * @param { BlurType } blurType - Indicates the blur type. 2222 * @param { number } sigma - Indicates the standard deviation of the Gaussian blur to apply. Must be > 0. 2223 * @returns { MaskFilter } MaskFilter object. 2224 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2225 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2226 * @static 2227 * @syscap SystemCapability.Graphics.Drawing 2228 * @since 12 2229 */ 2230 static createBlurMaskFilter(blurType: BlurType, sigma: number): MaskFilter; 2231 } 2232 2233 /** 2234 * Defines a PathEffect, which is used to affects stroked paths. 2235 * @syscap SystemCapability.Graphics.Drawing 2236 * @since 12 2237 */ 2238 class PathEffect { 2239 /** 2240 * Makes a dash PathEffect. 2241 * @param { Array<number> } intervals - Array of ON and OFF distances. Must contain an even number of entries (>=2), 2242 * with the even indices specifying the "on" intervals, and the odd indices specifying the "off" intervals. 2243 * @param { number } phase - Offset into the intervals array. 2244 * @returns { PathEffect } PathEffect object. 2245 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2246 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2247 * @static 2248 * @syscap SystemCapability.Graphics.Drawing 2249 * @since 12 2250 */ 2251 static createDashPathEffect(intervals: Array<number>, phase: number): PathEffect; 2252 2253 /** 2254 * Makes a corner PathEffect. 2255 * @param { number } radius - Indicates the radius of the tangent circle at the corners of the path. 2256 * The radius must be greater than 0. 2257 * @returns { PathEffect } PathEffect object. 2258 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2259 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2260 * @static 2261 * @syscap SystemCapability.Graphics.Drawing 2262 * @since 12 2263 */ 2264 static createCornerPathEffect(radius: number): PathEffect; 2265 } 2266 2267 /** 2268 * Describes a shader effect object. 2269 * @syscap SystemCapability.Graphics.Drawing 2270 * @since 12 2271 */ 2272 class ShaderEffect { 2273 /** 2274 * Creates an ShaderEffect object that generates a shader with single color. 2275 * @param { number } color - Indicates the color used by the shader. 2276 * @returns { ShaderEffect } Returns the shader with single color ShaderEffect object. 2277 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2278 * <br>2. Incorrect parameter types. 2279 * @syscap SystemCapability.Graphics.Drawing 2280 * @since 12 2281 */ 2282 static createColorShader(color: number): ShaderEffect; 2283 2284 /** 2285 * Creates an ShaderEffect object that generates a linear gradient between the two specified points. 2286 * @param { common2D.Point } startPt - Indicates the start point for the gradient. 2287 * @param { common2D.Point } endPt - Indicates the end point for the gradient. 2288 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2289 * @param { TileMode } mode - Indicates the tile mode. 2290 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2291 * <br> in the colors array. The default value is empty for uniform distribution. 2292 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2293 * @returns { ShaderEffect } Returns a linear gradient ShaderEffect object. 2294 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2295 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2296 * @syscap SystemCapability.Graphics.Drawing 2297 * @since 12 2298 */ 2299 static createLinearGradient(startPt: common2D.Point, endPt: common2D.Point, colors: Array<number>, 2300 mode: TileMode, pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 2301 2302 /** 2303 * Creates an ShaderEffect object that generates a radial gradient given the center and radius. 2304 * @param { common2D.Point } centerPt - Indicates the center of the circle for the gradient. 2305 * @param { number } radius - Indicates the radius of the circle for this gradient. 2306 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2307 * @param { TileMode } mode - Indicates the tile mode. 2308 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2309 * <br> in the colors array. The default value is empty for uniform distribution. 2310 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2311 * @returns { ShaderEffect } Returns a radial gradient ShaderEffect object. 2312 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2313 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2314 * @syscap SystemCapability.Graphics.Drawing 2315 * @since 12 2316 */ 2317 static createRadialGradient(centerPt: common2D.Point, radius: number, colors: Array<number>, 2318 mode: TileMode, pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 2319 2320 /** 2321 * Creates an ShaderEffect object that generates a sweep gradient given a center. 2322 * @param { common2D.Point } centerPt - Indicates the center of the circle for the gradient. 2323 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2324 * @param { TileMode } mode - Indicates the tile mode. 2325 * @param { number } startAngle - The starting angle of the gradient. 2326 * @param { number } endAngle - The ending angle of the gradient. 2327 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2328 * <br> in the colors array. The default value is empty for uniform distribution. 2329 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2330 * @returns { ShaderEffect } Returns a sweep gradient ShaderEffect object. 2331 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2332 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2333 * @syscap SystemCapability.Graphics.Drawing 2334 * @since 12 2335 */ 2336 static createSweepGradient(centerPt: common2D.Point, colors: Array<number>, 2337 mode: TileMode, startAngle: number, endAngle: number, pos?: Array<number> | null, 2338 matrix?: Matrix | null): ShaderEffect; 2339 2340 /** 2341 * Creates an ShaderEffect object that generates a conical gradient given two circles. 2342 * @param { common2D.Point } startPt - Indicates the center of the start circle for the gradient. 2343 * @param { number } startRadius - Indicates the radius of the start circle for this gradient. 2344 * @param { common2D.Point } endPt - Indicates the center of the end circle for the gradient. 2345 * @param { number } endRadius - Indicates the radius of the end circle for this gradient. 2346 * @param { Array<number> } colors - Indicates the colors to be distributed between the two points. 2347 * @param { TileMode } mode - Indicates the tile mode. 2348 * @param { Array<number> | null } pos - Indicates the relative position of each corresponding color 2349 * <br> in the colors array. The default value is empty for uniform distribution. 2350 * @param { Matrix | null } matrix - Indicates the Matrix object. The default value is null. 2351 * @returns { ShaderEffect } Returns a conical gradient ShaderEffect object. 2352 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2353 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2354 * @syscap SystemCapability.Graphics.Drawing 2355 * @since 12 2356 */ 2357 static createConicalGradient(startPt: common2D.Point, startRadius: number, endPt: common2D.Point, 2358 endRadius: number, colors: Array<number>, mode: TileMode, 2359 pos?: Array<number> | null, matrix?: Matrix | null): ShaderEffect; 2360 } 2361 2362 /** 2363 * Enumerates tile modes that describe an image or texture. 2364 * @enum { number } 2365 * @syscap SystemCapability.Graphics.Drawing 2366 * @since 12 2367 */ 2368 enum TileMode { 2369 /** 2370 * Replicate the edge color if the shader effect draws outside of its original bounds. 2371 * @syscap SystemCapability.Graphics.Drawing 2372 * @since 12 2373 */ 2374 CLAMP = 0, 2375 2376 /** 2377 * Repeat the shader effect image horizontally and vertically. 2378 * @syscap SystemCapability.Graphics.Drawing 2379 * @since 12 2380 */ 2381 REPEAT = 1, 2382 2383 /** 2384 * Repeat the shader effect image horizontally and vertically, alternating mirror images 2385 * so that adjacent images always seam. 2386 * @syscap SystemCapability.Graphics.Drawing 2387 * @since 12 2388 */ 2389 MIRROR = 2, 2390 2391 /** 2392 * Only draw within the original domain, return transparent-black everywhere else. 2393 * @syscap SystemCapability.Graphics.Drawing 2394 * @since 12 2395 */ 2396 DECAL = 3, 2397 } 2398 2399 /** 2400 * Defines a ShadowLayer, which is used to specify the color, blur radius, and offset of the shadow. 2401 * @syscap SystemCapability.Graphics.Drawing 2402 * @since 12 2403 */ 2404 class ShadowLayer { 2405 /** 2406 * Makes a new ShadowLayer. 2407 * 2408 * @param { number } blurRadius - The blur radius of the shadow. The blur radius must be greater than 0. 2409 * @param { number } x - The offset point on x-axis. 2410 * @param { number } y - The offset point on y-axis. 2411 * @param { common2D.Color } color - The shadow color. The range of color channels must be [0, 255]. 2412 * @returns { ShadowLayer } ShadowLayer object. 2413 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2414 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2415 * @static 2416 * @syscap SystemCapability.Graphics.Drawing 2417 * @since 12 2418 */ 2419 static create(blurRadius: number, x: number, y: number, color: common2D.Color): ShadowLayer; 2420 } 2421 2422 /** 2423 * ColorFilters are optional objects in the drawing pipeline. 2424 * 2425 * @syscap SystemCapability.Graphics.Drawing 2426 * @since 11 2427 */ 2428 class ColorFilter { 2429 /** 2430 * Makes a color filter with the given color and blend mode. 2431 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 2432 * @param { BlendMode } mode - BlendMode. 2433 * @returns { ColorFilter } Colorfilter object. 2434 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2435 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2436 * @static 2437 * @syscap SystemCapability.Graphics.Drawing 2438 * @since 11 2439 */ 2440 static createBlendModeColorFilter(color: common2D.Color, mode: BlendMode): ColorFilter; 2441 2442 /** 2443 * Create a color filter consisting of two filters. 2444 * @param { ColorFilter } outer - The filter is used next. 2445 * @param { ColorFilter } inner - The filter is used first. 2446 * @returns { ColorFilter } Colorfilter object. 2447 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2448 * <br>2. Incorrect parameter types. 2449 * @static 2450 * @syscap SystemCapability.Graphics.Drawing 2451 * @since 11 2452 */ 2453 static createComposeColorFilter(outer: ColorFilter, inner: ColorFilter): ColorFilter; 2454 2455 /** 2456 * Makes a color filter that converts between linear colors and sRGB colors. 2457 * @returns { ColorFilter } Colorfilter object. 2458 * @static 2459 * @syscap SystemCapability.Graphics.Drawing 2460 * @since 11 2461 */ 2462 static createLinearToSRGBGamma(): ColorFilter; 2463 2464 /** 2465 * Makes a color filter that converts between sRGB colors and linear colors. 2466 * @returns { ColorFilter } Colorfilter object. 2467 * @static 2468 * @syscap SystemCapability.Graphics.Drawing 2469 * @since 11 2470 */ 2471 static createSRGBGammaToLinear(): ColorFilter; 2472 2473 /** 2474 * Makes a color filter that multiplies the luma of its input into the alpha channel, 2475 * and sets the red, green, and blue channels to zero. 2476 * @returns { ColorFilter } Colorfilter. 2477 * @static 2478 * @syscap SystemCapability.Graphics.Drawing 2479 * @since 11 2480 */ 2481 static createLumaColorFilter(): ColorFilter; 2482 /** 2483 * Makes a color filter with a 5x4 color matrix 2484 * @param { Array<number> } matrix - Indicates the matrix, which is represented as a number array of length 20. 2485 * @returns { ColorFilter } Colorfilter object. 2486 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2487 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2488 * @static 2489 * @syscap SystemCapability.Graphics.Drawing 2490 * @since 12 2491 */ 2492 static createMatrixColorFilter(matrix: Array<number>): ColorFilter; 2493 } 2494 2495 /** 2496 * ImageFilters are optional objects in the drawing pipeline. 2497 * 2498 * @syscap SystemCapability.Graphics.Drawing 2499 * @since 12 2500 */ 2501 class ImageFilter { 2502 /** 2503 * Makes an ImageFilter object that blurs its input by the separate X and Y sigmas. 2504 * @param { number } sigmaX - Indicates the Gaussian sigma value for blurring along the X axis. Must be > 0. 2505 * @param { number } sigmaY - Indicates the Gaussian sigma value for blurring along the Y axis. Must be > 0. 2506 * @param { TileMode } tileMode - Indicates the tile mode applied at edges. 2507 * @param { ImageFilter | null } imageFilter - Indicates the input filter that is blurred, 2508 * uses source bitmap if this is null. 2509 * @returns { ImageFilter } ImageFilter object. 2510 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2511 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2512 * @static 2513 * @syscap SystemCapability.Graphics.Drawing 2514 * @since 12 2515 */ 2516 static createBlurImageFilter(sigmaX: number, sigmaY: number, 2517 tileMode: TileMode, imageFilter?: ImageFilter | null): ImageFilter; 2518 /** 2519 * Makes an ImageFilter object that applies the color filter to the input. 2520 * @param { ColorFilter } colorFilter - Indicates the color filter that transforms the input image. 2521 * @param { ImageFilter | null } imageFilter - Indicates the input filter, or uses the source bitmap if this is null. 2522 * @returns { ImageFilter } ImageFilter object. 2523 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2524 * <br>2. Incorrect parameter types. 2525 * @static 2526 * @syscap SystemCapability.Graphics.Drawing 2527 * @since 12 2528 */ 2529 static createFromColorFilter(colorFilter: ColorFilter, imageFilter?: ImageFilter | null): ImageFilter; 2530 } 2531 /** 2532 * Enumerate join styles. The join style defines the shape of the joins of a 2533 * polyline segment drawn by the pen. 2534 * @enum { number } 2535 * @syscap SystemCapability.Graphics.Drawing 2536 * @since 12 2537 */ 2538 enum JoinStyle { 2539 /** 2540 * Miter corner. If the angle of a polyline is small, its miter length may be inappropriate. 2541 * In this case, you need to use the miter limit to limit the miter length. 2542 * @syscap SystemCapability.Graphics.Drawing 2543 * @since 12 2544 */ 2545 MITER_JOIN = 0, 2546 2547 /** 2548 * Round corner. 2549 * @syscap SystemCapability.Graphics.Drawing 2550 * @since 12 2551 */ 2552 ROUND_JOIN = 1, 2553 2554 /** 2555 * Bevel corner. 2556 * @syscap SystemCapability.Graphics.Drawing 2557 * @since 12 2558 */ 2559 BEVEL_JOIN = 2 2560 } 2561 2562 /** 2563 * Enumerates cap styles of a pen. The cap style defines 2564 * the style of both ends of a segment drawn by the pen. 2565 * @enum { number } 2566 * @syscap SystemCapability.Graphics.Drawing 2567 * @since 12 2568 */ 2569 enum CapStyle { 2570 /** 2571 * No cap style. Both ends of the segment are cut off square. 2572 * @syscap SystemCapability.Graphics.Drawing 2573 * @since 12 2574 */ 2575 FLAT_CAP = 0, 2576 2577 /** 2578 * Square cap style. Both ends have a square, the height of which 2579 * is half of the width of the segment, with the same width. 2580 * @syscap SystemCapability.Graphics.Drawing 2581 * @since 12 2582 */ 2583 SQUARE_CAP = 1, 2584 2585 /** 2586 * Round cap style. Both ends have a semicircle centered, the diameter of which 2587 * is the same as the width of the segment. 2588 * @syscap SystemCapability.Graphics.Drawing 2589 * @since 12 2590 */ 2591 ROUND_CAP = 2 2592 } 2593 2594 /** 2595 * Enumerates blur type. 2596 * @enum { number } 2597 * @syscap SystemCapability.Graphics.Drawing 2598 * @since 12 2599 */ 2600 enum BlurType { 2601 /** 2602 * Fuzzy inside and outside. 2603 * @syscap SystemCapability.Graphics.Drawing 2604 * @since 12 2605 */ 2606 NORMAL = 0, 2607 2608 /** 2609 * Solid inside, fuzzy outside. 2610 * @syscap SystemCapability.Graphics.Drawing 2611 * @since 12 2612 */ 2613 SOLID = 1, 2614 2615 /** 2616 * Nothing inside, fuzzy outside. 2617 * @syscap SystemCapability.Graphics.Drawing 2618 * @since 12 2619 */ 2620 OUTER = 2, 2621 2622 /** 2623 * Fuzzy inside, nothing outside. 2624 * @syscap SystemCapability.Graphics.Drawing 2625 * @since 12 2626 */ 2627 INNER = 3 2628 } 2629 2630 /** 2631 * Provides settings for strokes during drawing. 2632 * @syscap SystemCapability.Graphics.Drawing 2633 * @since 11 2634 */ 2635 class Pen { 2636 /** 2637 * Constructor for the pen. 2638 * @syscap SystemCapability.Graphics.Drawing 2639 * @since 12 2640 */ 2641 constructor(); 2642 2643 /** 2644 * Constructor for the pen from an existing pen object pen. 2645 * @param { Pen } pen - Indicates the Pen object. 2646 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2647 * <br>2. Incorrect parameter types. 2648 * @syscap SystemCapability.Graphics.Drawing 2649 * @since 12 2650 */ 2651 constructor(pen: Pen); 2652 2653 /** 2654 * Sets the stroke miter limit for a polyline drawn by a pen. 2655 * @param { number } miter - Indicates a variable that describes the miter limit. 2656 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2657 * <br>2. Incorrect parameter types. 2658 * @syscap SystemCapability.Graphics.Drawing 2659 * @since 12 2660 */ 2661 setMiterLimit(miter: number): void; 2662 2663 /** 2664 * Obtains the stroke miter limit of a polyline drawn by a pen. 2665 * @returns { number } Returns the miter limit. 2666 * @syscap SystemCapability.Graphics.Drawing 2667 * @since 12 2668 */ 2669 getMiterLimit(): number; 2670 2671 /** 2672 * Sets the shaderEffect for a pen. 2673 * @param { ShaderEffect } shaderEffect - Indicates the ShaderEffect object. 2674 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2675 * <br>2. Incorrect parameter types. 2676 * @syscap SystemCapability.Graphics.Drawing 2677 * @since 12 2678 */ 2679 setShaderEffect(shaderEffect: ShaderEffect): void; 2680 2681 /** 2682 * Set the color of the pen. 2683 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 2684 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2685 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2686 * @syscap SystemCapability.Graphics.Drawing 2687 * @since 11 2688 */ 2689 setColor(color: common2D.Color): void; 2690 2691 /** 2692 * Set the AGRB color of the pen. 2693 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 2694 * @param { number } red - Red channel of color. The range of red must be [0, 255]. 2695 * @param { number } green - Green channel of color. The range of green must be [0, 255]. 2696 * @param { number } blue - Blue channel of color. The range of blue must be [0, 255]. 2697 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2698 * <br>2. Incorrect parameter types. 2699 * @syscap SystemCapability.Graphics.Drawing 2700 * @since 12 2701 */ 2702 setColor(alpha: number, red: number, green: number, blue: number): void; 2703 2704 /** 2705 * Obtains the color of a pen. The color is used by the pen to outline a shape. 2706 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 2707 * @syscap SystemCapability.Graphics.Drawing 2708 * @since 12 2709 */ 2710 getColor(): common2D.Color; 2711 2712 /** 2713 * Sets the thickness of the pen used by the paint to outline the shape. 2714 * 2715 * @param { number } width - Zero thickness for hairline; greater than zero for pen thickness. 2716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2717 * <br>2. Incorrect parameter types. 2718 * @syscap SystemCapability.Graphics.Drawing 2719 * @since 11 2720 */ 2721 setStrokeWidth(width: number): void; 2722 2723 /** 2724 * Obtains the thickness of a pen. This thickness determines the width of the outline of a shape. 2725 * @returns { number } Returns the thickness. 2726 * @syscap SystemCapability.Graphics.Drawing 2727 * @since 12 2728 */ 2729 getWidth(): number; 2730 2731 /** 2732 * Requests, but does not require, that edge pixels draw opaque or with partial transparency. 2733 * 2734 * @param { boolean } aa - Setting for antialiasing. 2735 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2736 * <br>2. Incorrect parameter types. 2737 * @syscap SystemCapability.Graphics.Drawing 2738 * @since 11 2739 */ 2740 setAntiAlias(aa: boolean): void; 2741 2742 /** 2743 * Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled, 2744 * edges will be drawn with partial transparency. 2745 * @returns { boolean } Returns true if the anti-aliasing is enabled; returns false otherwise. 2746 * @syscap SystemCapability.Graphics.Drawing 2747 * @since 12 2748 */ 2749 isAntiAlias(): boolean; 2750 2751 /** 2752 * Replaces alpha, leaving RGB 2753 * 2754 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 2755 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2756 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2757 * @syscap SystemCapability.Graphics.Drawing 2758 * @since 11 2759 */ 2760 setAlpha(alpha: number): void; 2761 2762 /** 2763 * Obtains the alpha of a pen. The alpha is used by the pen to outline a shape. 2764 * @returns { number } Returns a 8-bit variable that describes the alpha. 2765 * @syscap SystemCapability.Graphics.Drawing 2766 * @since 12 2767 */ 2768 getAlpha(): number; 2769 2770 /** 2771 * Sets ColorFilter to pen 2772 * 2773 * @param { ColorFilter } filter - ColorFilter to apply to subsequent draw. 2774 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2775 * <br>2. Incorrect parameter types. 2776 * @syscap SystemCapability.Graphics.Drawing 2777 * @since 11 2778 */ 2779 setColorFilter(filter: ColorFilter): void; 2780 /** 2781 * Gets ColorFilter of pen 2782 * @returns { ColorFilter } ColorFilter. 2783 * @syscap SystemCapability.Graphics.Drawing 2784 * @since 12 2785 */ 2786 getColorFilter(): ColorFilter; 2787 /** 2788 * Sets ImageFilter to pen 2789 * @param { ImageFilter | null } filter - ImageFilter to apply to subsequent draw. 2790 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2791 * <br>2. Incorrect parameter types. 2792 * @syscap SystemCapability.Graphics.Drawing 2793 * @since 12 2794 */ 2795 setImageFilter(filter: ImageFilter | null): void; 2796 /** 2797 * Sets MaskFilter to pen. 2798 * 2799 * @param { MaskFilter } filter - MaskFilter to apply to subsequent draw. 2800 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2801 * <br>2. Incorrect parameter types. 2802 * @syscap SystemCapability.Graphics.Drawing 2803 * @since 12 2804 */ 2805 setMaskFilter(filter: MaskFilter): void; 2806 2807 /** 2808 * Sets PathEffect to pen. 2809 * 2810 * @param { PathEffect } effect - PathEffect to apply to subsequent draw. 2811 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2812 * <br>2. Incorrect parameter types. 2813 * @syscap SystemCapability.Graphics.Drawing 2814 * @since 12 2815 */ 2816 setPathEffect(effect: PathEffect): void; 2817 2818 /** 2819 * Sets ShadowLayer to pen. 2820 * 2821 * @param { ShadowLayer } shadowLayer - ShadowLayer to apply to subsequent draw. 2822 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2823 * <br>2. Incorrect parameter types. 2824 * @syscap SystemCapability.Graphics.Drawing 2825 * @since 12 2826 */ 2827 setShadowLayer(shadowLayer: ShadowLayer): void; 2828 2829 /** 2830 * Sets a blender that implements the specified blendmode enum. 2831 * 2832 * @param { BlendMode } mode - Blendmode. 2833 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2834 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2835 * @syscap SystemCapability.Graphics.Drawing 2836 * @since 11 2837 */ 2838 setBlendMode(mode: BlendMode): void; 2839 2840 /** 2841 * Request color distribution error. 2842 * 2843 * @param { boolean } dither - Whether the color is distributed incorrectly. 2844 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2845 * <br>2. Incorrect parameter types. 2846 * @syscap SystemCapability.Graphics.Drawing 2847 * @since 11 2848 */ 2849 setDither(dither: boolean): void; 2850 2851 /** 2852 * Sets the JoinStyle for a pen. 2853 * 2854 * @param { JoinStyle } style - The JoinStyle. 2855 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2856 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2857 * @syscap SystemCapability.Graphics.Drawing 2858 * @since 12 2859 */ 2860 setJoinStyle(style: JoinStyle): void; 2861 2862 /** 2863 * Obtains the JoinStyle of a pen. 2864 * 2865 * @returns { JoinStyle } The JoinStyle. 2866 * @syscap SystemCapability.Graphics.Drawing 2867 * @since 12 2868 */ 2869 getJoinStyle(): JoinStyle; 2870 2871 /** 2872 * Sets the CapStyle for a pen. 2873 * 2874 * @param { CapStyle } style - The CapStyle. 2875 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2876 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2877 * @syscap SystemCapability.Graphics.Drawing 2878 * @since 12 2879 */ 2880 setCapStyle(style: CapStyle): void; 2881 2882 /** 2883 * Obtains the CapStyle of a pen. 2884 * 2885 * @returns { CapStyle } The CapStyle. 2886 * @syscap SystemCapability.Graphics.Drawing 2887 * @since 12 2888 */ 2889 getCapStyle(): CapStyle; 2890 2891 /** 2892 * Resets all pen contents to their initial values. 2893 * @syscap SystemCapability.Graphics.Drawing 2894 * @since 12 2895 */ 2896 reset(): void; 2897 /** 2898 * Obtains the filled equivalent of the src path. 2899 * 2900 * @param { Path } src - The path read to create a filled version. 2901 * @param { Path } dst - The resulting path (may be the same as src). 2902 * @returns { boolean } true if the path should be filled, or false if it should be drawn with a hairline (width == 0) 2903 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2904 * <br>2. Incorrect parameter types. 2905 * @syscap SystemCapability.Graphics.Drawing 2906 * @since 12 2907 */ 2908 getFillPath(src: Path, dst: Path): boolean; 2909 } 2910 2911 /** 2912 * Provides settings for brush fill when drawing. 2913 * @syscap SystemCapability.Graphics.Drawing 2914 * @since 11 2915 */ 2916 class Brush { 2917 /** 2918 * Constructor for the Brush. 2919 * @syscap SystemCapability.Graphics.Drawing 2920 * @since 12 2921 */ 2922 constructor(); 2923 2924 /** 2925 * Constructor for the Brush from an existing brush object brush. 2926 * @param { Brush } brush - Indicates the Brush object. 2927 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2928 * <br>2. Incorrect parameter types. 2929 * @syscap SystemCapability.Graphics.Drawing 2930 * @since 12 2931 */ 2932 constructor(brush: Brush); 2933 2934 /** 2935 * Set the color of the brush. 2936 * @param { common2D.Color } color - The range of color channels must be [0, 255]. 2937 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2938 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2939 * @syscap SystemCapability.Graphics.Drawing 2940 * @since 11 2941 */ 2942 setColor(color: common2D.Color): void; 2943 2944 /** 2945 * Set the ARGB color of the brush. 2946 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 2947 * @param { number } red - Red channel of color. The range of red must be [0, 255]. 2948 * @param { number } green - Green channel of color. The range of green must be [0, 255]. 2949 * @param { number } blue - Blue channel of color. The range of blue must be [0, 255]. 2950 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2951 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2952 * @syscap SystemCapability.Graphics.Drawing 2953 * @since 12 2954 */ 2955 setColor(alpha: number, red: number, green: number, blue: number): void; 2956 2957 /** 2958 * Obtains the color of a brush. The color is used by the brush to fill in a shape. 2959 * @returns { common2D.Color } Returns a 32-bit (ARGB) variable that describes the color. 2960 * @syscap SystemCapability.Graphics.Drawing 2961 * @since 12 2962 */ 2963 getColor(): common2D.Color; 2964 2965 /** 2966 * Requests, but does not require, that edge pixels draw opaque or with partial transparency. 2967 * @param { boolean } aa - Setting for antialiasing. 2968 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2969 * <br>2. Incorrect parameter types. 2970 * @syscap SystemCapability.Graphics.Drawing 2971 * @since 11 2972 */ 2973 setAntiAlias(aa: boolean): void; 2974 2975 /** 2976 * Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, 2977 * edges will be drawn with partial transparency. 2978 * @returns { boolean } Returns true if anti-aliasing is enabled; returns false otherwise. 2979 * @syscap SystemCapability.Graphics.Drawing 2980 * @since 12 2981 */ 2982 isAntiAlias(): boolean; 2983 2984 /** 2985 * Replaces alpha, leaving RGB 2986 * @param { number } alpha - Alpha channel of color. The range of alpha must be [0, 255]. 2987 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2988 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2989 * @syscap SystemCapability.Graphics.Drawing 2990 * @since 11 2991 */ 2992 setAlpha(alpha: number): void; 2993 2994 /** 2995 * Obtains the alpha of a brush. The alpha is used by the brush to fill in a shape. 2996 * @returns { number } Returns a 8-bit variable that describes the alpha. 2997 * @syscap SystemCapability.Graphics.Drawing 2998 * @since 12 2999 */ 3000 getAlpha(): number; 3001 3002 /** 3003 * Sets ColorFilter to brush 3004 * @param { ColorFilter } filter - ColorFilter to apply to subsequent draw. 3005 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3006 * <br>2. Incorrect parameter types. 3007 * @syscap SystemCapability.Graphics.Drawing 3008 * @since 11 3009 */ 3010 setColorFilter(filter: ColorFilter): void; 3011 3012 /** 3013 * Gets ColorFilter of brush 3014 * @returns { ColorFilter } ColorFilter. 3015 * @syscap SystemCapability.Graphics.Drawing 3016 * @since 12 3017 */ 3018 getColorFilter(): ColorFilter; 3019 /** 3020 * Sets ImageFilter to brush 3021 * @param { ImageFilter | null } filter - ImageFilter to apply to subsequent draw. 3022 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3023 * <br>2. Incorrect parameter types. 3024 * @syscap SystemCapability.Graphics.Drawing 3025 * @since 12 3026 */ 3027 setImageFilter(filter: ImageFilter | null): void; 3028 /** 3029 * Sets MaskFilter to brush. 3030 * @param { MaskFilter } filter - MaskFilter to apply to subsequent draw. 3031 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3032 * <br>2. Incorrect parameter types. 3033 * @syscap SystemCapability.Graphics.Drawing 3034 * @since 12 3035 */ 3036 setMaskFilter(filter: MaskFilter): void; 3037 3038 /** 3039 * Sets ShadowLayer to brush. 3040 * 3041 * @param { ShadowLayer } shadowLayer - ShadowLayer painting. 3042 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3043 * <br>2. Incorrect parameter types. 3044 * @syscap SystemCapability.Graphics.Drawing 3045 * @since 12 3046 */ 3047 setShadowLayer(shadowLayer: ShadowLayer): void; 3048 3049 /** 3050 * Sets the shaderEffect for a brush. 3051 * @param { ShaderEffect } shaderEffect - Indicates the ShaderEffect object. 3052 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3053 * <br>2. Incorrect parameter types. 3054 * @syscap SystemCapability.Graphics.Drawing 3055 * @since 12 3056 */ 3057 setShaderEffect(shaderEffect: ShaderEffect): void; 3058 3059 /** 3060 * Sets a blender that implements the specified blendmode enum. 3061 * @param { BlendMode } mode - Blendmode. 3062 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3063 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3064 * @syscap SystemCapability.Graphics.Drawing 3065 * @since 11 3066 */ 3067 setBlendMode(mode: BlendMode): void; 3068 3069 /** 3070 * Resets all brush contents to their initial values. 3071 * @syscap SystemCapability.Graphics.Drawing 3072 * @since 12 3073 */ 3074 reset(): void; 3075 } 3076 3077 /** 3078 * Declares functions related to the matrix object in the drawing module. 3079 * 3080 * @syscap SystemCapability.Graphics.Drawing 3081 * @since 12 3082 */ 3083 class Matrix { 3084 /** 3085 * Creates an identity matrix. 3086 * @syscap SystemCapability.Graphics.Drawing 3087 * @since 12 3088 */ 3089 constructor(); 3090 3091 /** 3092 * Sets matrix to rotate by degrees about a pivot point at (px, py). 3093 * @param { number } degree - Indicates the angle of axes relative to upright axes. 3094 * @param { number } px - Indicates the pivot on x-axis. 3095 * @param { number } py - Indicates the pivot on y-axis. 3096 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3097 * <br>2. Incorrect parameter types. 3098 * @syscap SystemCapability.Graphics.Drawing 3099 * @since 12 3100 */ 3101 setRotation(degree: number, px: number, py: number): void; 3102 3103 /** 3104 * Sets matrix to scale by sx and sy, about a pivot point at (px, py). 3105 * @param { number } sx - Indicates the horizontal scale factor. 3106 * @param { number } sy - Indicates the vertical scale factor. 3107 * @param { number } px - Indicates the pivot on x-axis. 3108 * @param { number } py - Indicates the pivot on y-axis. 3109 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3110 * <br>2. Incorrect parameter types. 3111 * @syscap SystemCapability.Graphics.Drawing 3112 * @since 12 3113 */ 3114 setScale(sx: number, sy: number, px: number, py: number): void; 3115 3116 /** 3117 * Sets matrix to translate by (dx, dy). 3118 * @param { number } dx - Indicates the horizontal translation. 3119 * @param { number } dy - Indicates the vertical translation. 3120 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3121 * <br>2. Incorrect parameter types. 3122 * @syscap SystemCapability.Graphics.Drawing 3123 * @since 12 3124 */ 3125 setTranslation(dx: number, dy: number): void; 3126 3127 /** 3128 * Sets the params for a matrix. 3129 * @param { Array<number> } values - Each value in the array represents the following parameters: 3130 * values[0] - horizontal scale factor to store. 3131 * values[1] - horizontal skew factor to store. 3132 * values[2] - horizontal translation to store. 3133 * values[3] - vertical skew factor to store. 3134 * values[4] - vertical scale factor to store. 3135 * values[5] - vertical translation to store. 3136 * values[6] - input x-axis values perspective factor to store. 3137 * values[7] - input y-axis values perspective factor to store. 3138 * values[8] - perspective scale factor to store. 3139 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3140 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3141 * @syscap SystemCapability.Graphics.Drawing 3142 * @since 12 3143 */ 3144 setMatrix(values: Array<number>): void; 3145 3146 /** 3147 * Sets matrix total to matrix a multiplied by matrix b. 3148 * @param { Matrix } matrix - Indicates the Matrix object. 3149 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3150 * <br>2. Incorrect parameter types. 3151 * @syscap SystemCapability.Graphics.Drawing 3152 * @since 12 3153 */ 3154 preConcat(matrix: Matrix): void; 3155 3156 /** 3157 * Returns true if the first matrix equals the second matrix. 3158 * @param { Matrix } matrix - Indicates the Matrix object. 3159 * @returns { Boolean } Returns true if the two matrices are equal; returns false otherwise. 3160 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3161 * <br>2. Incorrect parameter types. 3162 * @syscap SystemCapability.Graphics.Drawing 3163 * @since 12 3164 */ 3165 isEqual(matrix: Matrix): Boolean; 3166 3167 /** 3168 * Sets inverse to reciprocal matrix, returning true if matrix can be inverted. 3169 * @param { Matrix } matrix - Indicates the Matrix object. 3170 * @returns { Boolean } Returns true if matrix can be inverted; returns false otherwise. 3171 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3172 * <br>2. Incorrect parameter types. 3173 * @syscap SystemCapability.Graphics.Drawing 3174 * @since 12 3175 */ 3176 invert(matrix: Matrix): Boolean; 3177 3178 /** 3179 * Returns true if matrix is identity. 3180 * @returns { Boolean } Returns true if matrix is identity; returns false otherwise. 3181 * @syscap SystemCapability.Graphics.Drawing 3182 * @since 12 3183 */ 3184 isIdentity(): Boolean; 3185 3186 /** 3187 * Get one matrix value. Index is between the range of 0-8. 3188 * @param { number } index - one of 0-8 3189 * @returns { number } Returns value corresponding to index.Returns 0 if out of range. 3190 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3191 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3192 * @syscap SystemCapability.Graphics.Drawing 3193 * @since 12 3194 */ 3195 getValue(index: number): number; 3196 /** 3197 * Sets matrix to matrix multiplied by matrix constructed from rotating by degrees around pivot point (px, py). 3198 * This can be thought of as rotating around a pivot point after applying matrix. 3199 * @param { number } degree - Indicates the angle of axes relative to upright axes. 3200 * @param { number } px - Indicates the pivot on x-axis. 3201 * @param { number } py - Indicates the pivot on y-axis. 3202 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3203 * <br>2. Incorrect parameter types. 3204 * @syscap SystemCapability.Graphics.Drawing 3205 * @since 12 3206 */ 3207 postRotate(degree: number, px: number, py: number): void; 3208 /** 3209 * Sets matrix to matrix multiplied by matrix constructed from scaling by (sx, sy) relative to pivot point (px, py). 3210 * This can be thought of as scaling relative to a pivot point after applying matrix. 3211 * @param { number } sx - Indicates the horizontal scale factor. 3212 * @param { number } sy - Indicates the vertical scale factor. 3213 * @param { number } px - Indicates the pivot on x-axis. 3214 * @param { number } py - Indicates the pivot on y-axis. 3215 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3216 * <br>2. Incorrect parameter types. 3217 * @syscap SystemCapability.Graphics.Drawing 3218 * @since 12 3219 */ 3220 postScale(sx: number, sy: number, px: number, py: number): void; 3221 /** 3222 * Sets matrix to matrix multiplied by matrix constructed from translation (dx, dy). 3223 * This can be thought of as moving the point to be mapped after applying matrix. 3224 * @param { number } dx - Indicates the horizontal translation. 3225 * @param { number } dy - Indicates the vertical translation. 3226 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3227 * <br>2. Incorrect parameter types. 3228 * @syscap SystemCapability.Graphics.Drawing 3229 * @since 12 3230 */ 3231 postTranslate(dx: number, dy: number): void; 3232 /** 3233 * Sets matrix to matrix multiplied by matrix constructed from rotating by degrees around pivot point (px, py). 3234 * This can be thought of as rotating around a pivot point before applying matrix. 3235 * @param { number } degree - Indicates the angle of axes relative to upright axes. 3236 * @param { number } px - Indicates the pivot on x-axis. 3237 * @param { number } py - Indicates the pivot on y-axis. 3238 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3239 * <br>2. Incorrect parameter types. 3240 * @syscap SystemCapability.Graphics.Drawing 3241 * @since 12 3242 */ 3243 preRotate(degree: number, px: number, py: number): void; 3244 /** 3245 * Sets matrix to matrix multiplied by matrix constructed from scaling by (sx, sy) relative to pivot point (px, py). 3246 * This can be thought of as scaling relative to a pivot point before applying matrix. 3247 * @param { number } sx - Indicates the horizontal scale factor. 3248 * @param { number } sy - Indicates the vertical scale factor. 3249 * @param { number } px - Indicates the pivot on x-axis. 3250 * @param { number } py - Indicates the pivot on y-axis. 3251 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3252 * <br>2. Incorrect parameter types. 3253 * @syscap SystemCapability.Graphics.Drawing 3254 * @since 12 3255 */ 3256 preScale(sx: number, sy: number, px: number, py: number): void; 3257 /** 3258 * Sets matrix to matrix multiplied by matrix constructed from translation (dx, dy). 3259 * This can be thought of as moving the point to be mapped before applying matrix. 3260 * @param { number } dx - Indicates the horizontal translation. 3261 * @param { number } dy - Indicates the vertical translation. 3262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3263 * <br>2. Incorrect parameter types. 3264 * @syscap SystemCapability.Graphics.Drawing 3265 * @since 12 3266 */ 3267 preTranslate(dx: number, dy: number): void; 3268 /** 3269 * Reset matrix to identity. 3270 * @syscap SystemCapability.Graphics.Drawing 3271 * @since 12 3272 */ 3273 reset(): void; 3274 /** 3275 * Maps src array of length count to dst array of equal or greater length. 3276 * This can be thought of as moving the point to be mapped before applying matrix. 3277 * @param { Array<common2D.Point> } src - points to transform. 3278 * @returns { Array<common2D.Point> } Return mapped points array. 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 mapPoints(src: Array<common2D.Point>): Array<common2D.Point>; 3285 /** 3286 * Return nine scalar values contained by Matrix. 3287 * @returns { Array<number> } nine scalar values contained by Matrix. 3288 * @syscap SystemCapability.Graphics.Drawing 3289 * @since 12 3290 */ 3291 getAll(): Array<number>; 3292 /** 3293 * Sets dst to bounds of src corners mapped by matrix transformation. 3294 * @param { common2D.Rect } dst - Rect to map from. 3295 * @param { common2D.Rect } src - Rect to map to. 3296 * @returns { boolean } Returns true if the mapped src is equal to the dst; returns false is not equal. 3297 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3298 * <br>2. Incorrect parameter types. 3299 * @syscap SystemCapability.Graphics.Drawing 3300 * @since 12 3301 */ 3302 mapRect(dst: common2D.Rect, src: common2D.Rect): boolean; 3303 /** 3304 * Sets matrix to scale and translate src rect to dst rect. 3305 * @param { common2D.Rect } src - Rect to map from. 3306 * @param { common2D.Rect } dst - Rect to map to. 3307 * @param { ScaleToFit } scaleToFit - Describes how matrix is constructed to map one rect to another. 3308 * @returns { boolean } Returns true if dst is empty, and sets matrix to: 3309 | 0 0 0 | 3310 | 0 0 0 | 3311 | 0 0 1 |. 3312 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3313 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3314 * @syscap SystemCapability.Graphics.Drawing 3315 * @since 12 3316 */ 3317 setRectToRect(src: common2D.Rect, dst: common2D.Rect, scaleToFit: ScaleToFit): boolean; 3318 /** 3319 * Sets Matrix to map src to dst. Count must be zero or greater, and four or less. 3320 * @param { Array<common2D.Point> } src - Point to map from 3321 * @param { Array<common2D.Point> } dst - Point to map to 3322 * @param { number } count - Number of Point in src and dst 3323 * @returns { boolean } Returns true if Matrix was constructed successfully 3324 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3325 * <br>2. Incorrect parameter types. 3326 * @syscap SystemCapability.Graphics.Drawing 3327 * @since 12 3328 */ 3329 setPolyToPoly(src: Array<common2D.Point>, dst: Array<common2D.Point>, count: number): boolean; 3330 } 3331 3332 /** 3333 * Describes a scale-to-fit values. 3334 * @enum { number } 3335 * @syscap SystemCapability.Graphics.Drawing 3336 * @since 12 3337 */ 3338 enum ScaleToFit { 3339 /** 3340 * Scales in x and y to fill destination Rect. 3341 * @syscap SystemCapability.Graphics.Drawing 3342 * @since 12 3343 */ 3344 FILL_SCALE_TO_FIT = 0, 3345 3346 /** 3347 * Scales and aligns to left and top. 3348 * @syscap SystemCapability.Graphics.Drawing 3349 * @since 12 3350 */ 3351 START_SCALE_TO_FIT = 1, 3352 3353 /** 3354 * Scales and aligns to center. 3355 * @syscap SystemCapability.Graphics.Drawing 3356 * @since 12 3357 */ 3358 CENTER_SCALE_TO_FIT = 2, 3359 3360 /** 3361 * Scales and aligns to right and bottom. 3362 * @syscap SystemCapability.Graphics.Drawing 3363 * @since 12 3364 */ 3365 END_SCALE_TO_FIT = 3 3366 } 3367 3368 /** 3369 * Describes a region object. 3370 * @syscap SystemCapability.Graphics.Drawing 3371 * @since 12 3372 */ 3373 class Region { 3374 /** 3375 * Determines whether the test point is in the region. 3376 * @param { number } x - Indicates the x coordinate of the point. The parameter must be an integer. 3377 * @param { number } y - Indicates the y coordinate of the point. The parameter must be an integer. 3378 * @returns { boolean } Returns true if (x, y) is inside region; returns false otherwise. 3379 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3380 * <br>2. Incorrect parameter types. 3381 * @syscap SystemCapability.Graphics.Drawing 3382 * @since 12 3383 */ 3384 isPointContained(x: number, y:number): boolean; 3385 3386 /** 3387 * Determines whether other region is in the region. 3388 * @param { Region } other - Other region object. 3389 * @returns { boolean } Returns true if other region is completely inside the region object; 3390 * <br>returns false otherwise. 3391 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3392 * <br>2. Incorrect parameter types. 3393 * @syscap SystemCapability.Graphics.Drawing 3394 * @since 12 3395 */ 3396 isRegionContained(other: Region): boolean; 3397 3398 /** 3399 * Replaces region with the result of region op region. 3400 * @param { Region } region - Region object. 3401 * @param { RegionOp } regionOp - Operation type. 3402 * @returns { boolean } Returns true if replaced region is not empty; returns false otherwise. 3403 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3404 * <br>2. Incorrect parameter types. 3405 * @syscap SystemCapability.Graphics.Drawing 3406 * @since 12 3407 */ 3408 op(region: Region, regionOp: RegionOp): boolean; 3409 3410 /** 3411 * Determines whether rect and region does not intersect. 3412 * @param { number } left - Left position of rectangle. The parameter must be an integer. 3413 * @param { number } top - Top position of rectangle. The parameter must be an integer. 3414 * @param { number } right - Right position of rectangle. The parameter must be an integer. 3415 * @param { number } bottom - Bottom position of rectangle. The parameter must be an integer. 3416 * @returns { boolean } Returns true if rect and region is not intersect; returns false otherwise. 3417 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3418 * <br>2. Incorrect parameter types. 3419 * @syscap SystemCapability.Graphics.Drawing 3420 * @since 12 3421 */ 3422 quickReject(left: number, top: number, right: number, bottom: number): boolean; 3423 3424 /** 3425 * Sets the region to match outline of path within clip. 3426 * @param { Path } path - Providing outline. 3427 * @param { Region } clip - Region object. 3428 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 3429 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3430 * <br>2. Incorrect parameter types. 3431 * @syscap SystemCapability.Graphics.Drawing 3432 * @since 12 3433 */ 3434 setPath(path: Path, clip: Region): boolean; 3435 3436 /** 3437 * Sets a rect to region. 3438 * @param { number } left - Left position of rectangle. The parameter must be an integer. 3439 * @param { number } top - Top position of rectangle. The parameter must be an integer. 3440 * @param { number } right - Right position of rectangle. The parameter must be an integer. 3441 * @param { number } bottom - Bottom position of rectangle. The parameter must be an integer. 3442 * @returns { boolean } Returns true if constructed region is not empty; returns false otherwise. 3443 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 3444 * <br>2. Incorrect parameter types. 3445 * @syscap SystemCapability.Graphics.Drawing 3446 * @since 12 3447 */ 3448 setRect(left: number, top: number, right: number, bottom: number): boolean; 3449 } 3450 3451 /** 3452 * Enumerates of operations when two regions are combined. 3453 * @enum { number } 3454 * @syscap SystemCapability.Graphics.Drawing 3455 * @since 12 3456 */ 3457 enum RegionOp { 3458 /** 3459 * Difference operation. 3460 * @syscap SystemCapability.Graphics.Drawing 3461 * @since 12 3462 */ 3463 DIFFERENCE = 0, 3464 3465 /** 3466 * Intersect operation. 3467 * @syscap SystemCapability.Graphics.Drawing 3468 * @since 12 3469 */ 3470 INTERSECT = 1, 3471 3472 /** 3473 * Union operation. 3474 * @syscap SystemCapability.Graphics.Drawing 3475 * @since 12 3476 */ 3477 UNION = 2, 3478 3479 /** 3480 * Xor operation. 3481 * @syscap SystemCapability.Graphics.Drawing 3482 * @since 12 3483 */ 3484 XOR = 3, 3485 3486 /** 3487 * Reverse difference operation. 3488 * @syscap SystemCapability.Graphics.Drawing 3489 * @since 12 3490 */ 3491 REVERSE_DIFFERENCE = 4, 3492 3493 /** 3494 * Replace operation. 3495 * @syscap SystemCapability.Graphics.Drawing 3496 * @since 12 3497 */ 3498 REPLACE = 5 3499 } 3500 3501 /** 3502 * Enumerates of corner radius position. 3503 * 3504 * @enum { number } 3505 * @syscap SystemCapability.Graphics.Drawing 3506 * @since 12 3507 */ 3508 enum CornerPos { 3509 /** 3510 * Index of top-left corner radius. 3511 * @syscap SystemCapability.Graphics.Drawing 3512 * @since 12 3513 */ 3514 TOP_LEFT_POS = 0, 3515 3516 /** 3517 * Index of top-right corner radius. 3518 * @syscap SystemCapability.Graphics.Drawing 3519 * @since 12 3520 */ 3521 TOP_RIGHT_POS = 1, 3522 3523 /** 3524 * Index of bottom-right corner radius. 3525 * @syscap SystemCapability.Graphics.Drawing 3526 * @since 12 3527 */ 3528 BOTTOM_RIGHT_POS = 2, 3529 3530 /** 3531 * Index of bottom-left corner radius. 3532 * @syscap SystemCapability.Graphics.Drawing 3533 * @since 12 3534 */ 3535 BOTTOM_LEFT_POS = 3 3536 } 3537 3538 /** 3539 * Enumeration defines the constraint type. 3540 * 3541 * @enum { number } 3542 * @syscap SystemCapability.Graphics.Drawing 3543 * @since 12 3544 */ 3545 enum SrcRectConstraint { 3546 3547 /** 3548 * Using sampling only inside bounds in a slower manner. 3549 * 3550 * @syscap SystemCapability.Graphics.Drawing 3551 * @since 12 3552 */ 3553 STRICT = 0, 3554 3555 /** 3556 * Using sampling outside bounds in a faster manner. 3557 * 3558 * @syscap SystemCapability.Graphics.Drawing 3559 * @since 12 3560 */ 3561 FAST = 1 3562 } 3563} 3564 3565export default drawing; 3566