• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Graphics
2
3The **Graphics** module provides APIs for defining attributes of a custom node.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { DrawContext, Size, Offset, Position, Pivot, Scale, Translation, Matrix4, Rotation, Frame, LengthMetricsUnit } from "@kit.ArkUI";
13```
14
15## Size
16
17Returns the width and height of the component. The default unit is vp, but APIs that use the Size type may specify a different unit, in which case the unit specified by the API takes precedence.
18
19**Atomic service API**: This API can be used in atomic services since API version 12.
20
21**System capability**: SystemCapability.ArkUI.ArkUI.Full
22
23| Name  | Type  | Readable| Writable| Description                  |
24| ------ | ------ | ---- | ---- | ---------------------- |
25| width  | number | Yes  | Yes  | Width of the component.<br>Unit: vp.<br>Value range: [0, +∞).|
26| height | number | Yes  | Yes  | Height of the component.<br>Unit: vp.<br>Value range: [0, +∞).|
27
28## Position
29
30type Position = Vector2
31
32Sets or returns the position of the component.
33
34**Atomic service API**: This API can be used in atomic services since API version 12.
35
36**System capability**: SystemCapability.ArkUI.ArkUI.Full
37
38| Type               | Description                               |
39| ------------------- | ----------------------------------- |
40| [Vector2](#vector2) | A vector that contains two values: x and y.<br>Unit: vp.|
41
42## PositionT<sup>12+</sup>
43
44type PositionT\<T> = Vector2T\<T>
45
46Sets or returns the position of the component.
47
48**Atomic service API**: This API can be used in atomic services since API version 12.
49
50**System capability**: SystemCapability.ArkUI.ArkUI.Full
51
52| Type                        | Description                               |
53| ---------------------------- | ----------------------------------- |
54| [Vector2T\<T>](#vector2tt12) | A vector that contains two values: x and y.<br>Unit: vp.|
55
56## Frame
57
58Sets or returns the layout size and position of the component.
59
60**Atomic service API**: This API can be used in atomic services since API version 12.
61
62**System capability**: SystemCapability.ArkUI.ArkUI.Full
63
64| Name  | Type  | Read Only| Optional| Description                       |
65| ------ | ------ | ---- | ---- | --------------------------- |
66| x      | number | Yes  | Yes  | Horizontal position.<br>Unit: vp.<br>Value range: (-∞, +∞).|
67| y      | number | Yes  | Yes  | Vertical position.<br>Unit: vp.<br>Value range: (-∞, +∞).|
68| width  | number | Yes  | Yes  | Component width.<br>Unit: vp.<br>Value range: [0, +∞).  |
69| height | number | Yes  | Yes  | Component height.<br>Unit: vp.<br>Value range: [0, +∞).  |
70
71## Pivot
72
73type Pivot = Vector2
74
75Sets the pivot of the component. As the rotation or scaling center of the component, the pivot affects the rotation and scaling effects.
76
77**Atomic service API**: This API can be used in atomic services since API version 12.
78
79**System capability**: SystemCapability.ArkUI.ArkUI.Full
80
81| Type               | Description                                                        |
82| ------------------- | ------------------------------------------------------------ |
83| [Vector2](#vector2) | X and Y coordinates of the pivot. The value is a floating point number in the range [0.0, 1.0], and the default value is **0.5**.|
84
85## Scale
86
87type Scale = Vector2
88
89Sets the scale factor of the component.
90
91**Atomic service API**: This API can be used in atomic services since API version 12.
92
93**System capability**: SystemCapability.ArkUI.ArkUI.Full
94
95| Type               | Description                                           |
96| ------------------- | ----------------------------------------------- |
97| [Vector2](#vector2) | Scale factor along the x- and y-axis. The value is a floating point number, and the default value is **1.0**.|
98
99## Translation
100
101type Translation = Vector2
102
103Sets the translation amount of the component.
104
105**Atomic service API**: This API can be used in atomic services since API version 12.
106
107**System capability**: SystemCapability.ArkUI.ArkUI.Full
108
109| Type               | Description                         |
110| ------------------- | ----------------------------- |
111| [Vector2](#vector2) | Translation amount along the x- and y-axis.<br>Unit: px|
112
113## Rotation
114
115type Rotation = Vector3
116
117Sets the rotation angle of the component.
118
119**Atomic service API**: This API can be used in atomic services since API version 12.
120
121**System capability**: SystemCapability.ArkUI.ArkUI.Full
122
123| Type               | Description                                  |
124| ------------------- | -------------------------------------- |
125| [Vector3](#vector3) | Rotation angle along the x- and y-axis.<br>Unit: degree|
126
127## Offset
128
129type Offset = Vector2
130
131Sets the offset of the component or effect.
132
133**Atomic service API**: This API can be used in atomic services since API version 12.
134
135**System capability**: SystemCapability.ArkUI.ArkUI.Full
136
137| Type               | Description                             |
138| ------------------- | --------------------------------- |
139| [Vector2](#vector2) | Offset along the x- and y-axis.<br>Unit: vp.|
140
141## Matrix4
142
143type Matrix4 = [number,number,number,number,number,number,number,number,number,number,number,number,number,number,number,number]
144
145Sets a 4x4 matrix.
146
147**Atomic service API**: This API can be used in atomic services since API version 12.
148
149**System capability**: SystemCapability.ArkUI.ArkUI.Full
150
151| Type                                                        | Description                                |
152| ------------------------------------------------------------ | ------------------------------------ |
153| [number,number,number,number,<br>number,number,number,number,<br>number,number,number,number,<br>number,number,number,number] | A 16-element array representing a 4x4 matrix.<br>Value range of each number: (-∞, +∞)|
154
155The **Matrix4** type is used to set transformation information for components. The following is an example:
156```ts
157const transform: Matrix4 = [
158  1, 0, 45, 0,
159  0, 1,  0, 0,
160  0, 0,  1, 0,
161  0, 0,  0, 1
162]
163```
164
165## Vector2
166
167Defines a vector that contains the x and y coordinate values.
168
169**Atomic service API**: This API can be used in atomic services since API version 12.
170
171**System capability**: SystemCapability.ArkUI.ArkUI.Full
172
173| Name| Type  | Read Only| Optional| Description             |
174| ---- | ------ | ---- | ---- | ----------------- |
175| x    | number | No  | No  | X coordinate value of the vector.<br>Value range: (-∞, +∞).|
176| y    | number | No  | No  | Y coordinate value of the vector.<br>Value range: (-∞, +∞).|
177
178## Vector3
179
180Represents a vector including three values: x, y, and z.
181
182**Atomic service API**: This API can be used in atomic services since API version 12.
183
184**System capability**: SystemCapability.ArkUI.ArkUI.Full
185
186| Name| Type  | Read Only| Optional| Description               |
187| ---- | ------ | ---- | ---- | ------------------- |
188| x    | number | No  | No  | Rotation angle along the x-axis.<br>Value range: (-∞, +∞).|
189| y    | number | No  | No  | Rotation angle along the y-axis.<br>Value range: (-∞, +∞).|
190| z    | number | No  | No  | Rotation angle along the z-axis.<br>Value range: (-∞, +∞).|
191
192## Vector2T\<T><sup>12+</sup>
193
194Represents a vector of the T type that contains two values: x and y.
195
196**Atomic service API**: This API can be used in atomic services since API version 12.
197
198**System capability**: SystemCapability.ArkUI.ArkUI.Full
199
200| Name| Type  | Read Only| Optional| Description             |
201| ---- | ------ | ---- | ---- | ----------------- |
202| x    | T | No | No | X coordinate value of the vector.|
203| y    | T | No | No | Y coordinate value of the vector.|
204
205## DrawContext
206
207Graphics drawing context, which provides the canvas width and height required for drawing.
208
209### size
210
211get size(): Size
212
213Obtains the width and height of the canvas.
214
215**Atomic service API**: This API can be used in atomic services since API version 12.
216
217**System capability**: SystemCapability.ArkUI.ArkUI.Full
218
219**Return value**
220
221| Type         | Description            |
222| ------------- | ---------------- |
223| [Size](#size) | Width and height of the canvas.|
224
225### sizeInPixel<sup>12+</sup>
226
227get sizeInPixel(): Size
228
229Obtains the width and height of the canvas in px.
230
231**Atomic service API**: This API can be used in atomic services since API version 12.
232
233**System capability**: SystemCapability.ArkUI.ArkUI.Full
234
235**Return value**
236
237| Type         | Description            |
238| ------------- | ---------------- |
239| [Size](#size) | Width and height of the canvas, in px.|
240
241### canvas
242
243get canvas(): drawing.Canvas
244
245Obtains the canvas used for drawing.
246
247**Atomic service API**: This API can be used in atomic services since API version 12.
248
249**System capability**: SystemCapability.ArkUI.ArkUI.Full
250
251**Return value**
252
253| Type         | Description            |
254| ------------- | ---------------- |
255| [drawing.Canvas](../apis-arkgraphics2d/js-apis-graphics-drawing.md#canvas) | Canvas for drawing.|
256
257**Example**
258
259```ts
260import { RenderNode, FrameNode, NodeController, DrawContext } from "@kit.ArkUI";
261
262class MyRenderNode extends RenderNode {
263  flag: boolean = false;
264
265  draw(context: DrawContext) {
266    const size = context.size;
267    const canvas = context.canvas;
268    const sizeInPixel = context.sizeInPixel;
269  }
270}
271
272const renderNode = new MyRenderNode();
273renderNode.frame = { x: 0, y: 0, width: 100, height: 100 };
274renderNode.backgroundColor = 0xffff0000;
275
276class MyNodeController extends NodeController {
277  private rootNode: FrameNode | null = null;
278
279  makeNode(uiContext: UIContext): FrameNode | null {
280    this.rootNode = new FrameNode(uiContext);
281
282    const rootRenderNode = this.rootNode.getRenderNode();
283    if (rootRenderNode !== null) {
284      rootRenderNode.appendChild(renderNode);
285    }
286
287    return this.rootNode;
288  }
289}
290
291@Entry
292@Component
293struct Index {
294  private myNodeController: MyNodeController = new MyNodeController();
295
296  build() {
297    Row() {
298      NodeContainer(this.myNodeController)
299    }
300  }
301}
302```
303
304## Edges\<T><sup>12+</sup>
305
306Describes the edges.
307
308**Atomic service API**: This API can be used in atomic services since API version 12.
309
310**System capability**: SystemCapability.ArkUI.ArkUI.Full
311
312| Name  | Type| Readable| Writable| Description            |
313| ------ | ---- | ---- | ---- | ---------------- |
314| left   | T    | Yes  | Yes  | Left edge.|
315| top    | T    | Yes  | Yes  | Top edge.|
316| right  | T    | Yes  | Yes  | Right edge.|
317| bottom | T    | Yes  | Yes  | Bottom edge.|
318
319## LengthUnit<sup>12+</sup>
320
321Enumerates length units.
322
323**Atomic service API**: This API can be used in atomic services since API version 12.
324
325**System capability**: SystemCapability.ArkUI.ArkUI.Full
326
327| Name| Value| Description|
328| -------- | -------- | -------- |
329| PX | 0 | Length in px.|
330| VP | 1 | Length in vp.|
331| FP | 2 | Length in fp.|
332| PERCENT | 3 | Length in percentage.|
333| LPX | 4 | Length in lpx.|
334
335## SizeT\<T><sup>12+</sup>
336
337Sets the width and height attributes.
338
339**Atomic service API**: This API can be used in atomic services since API version 12.
340
341**System capability**: SystemCapability.ArkUI.ArkUI.Full
342
343| Name  | Type| Readable| Writable| Description            |
344| ------ | ---- | ---- | ---- | ---------------- |
345| width   | T    | Yes  | Yes  | Width.|
346| height    | T    | Yes  | Yes  | Height.|
347
348## LengthMetricsUnit<sup>12+</sup>
349
350Enumerates length units.
351
352**Atomic service API**: This API can be used in atomic services since API version 12.
353
354**System capability**: SystemCapability.ArkUI.ArkUI.Full
355
356| Name| Value| Description|
357| -------- | -------- | -------- |
358| DEFAULT | 0 | Length in vp.|
359| PX | 1 | Length in px.|
360
361## LengthMetrics<sup>12+</sup>
362
363Defines the length properties. When the length unit is PERCENT, the value **1** indicates 100%.
364
365### Properties
366
367**Atomic service API**: This API can be used in atomic services since API version 12.
368
369**System capability**: SystemCapability.ArkUI.ArkUI.Full
370
371| Name  | Type| Readable| Writable| Description            |
372| ------------ | ---------------------------------------- | ---- | ---- | ------ |
373| value       | number | Yes  | Yes  | Value of the length property.  |
374| unit | [LengthUnit](#lengthunit12)                                   | Yes  | Yes  | Unit of the length property. The default value is VP.|
375
376### constructor<sup>12+</sup>
377
378constructor(value: number, unit?: LengthUnit)
379
380A constructor used to create a **LengthMetrics** instance. If the **unit** parameter is omitted or explicitly set to **undefined**, the default unit VP is used. If it is set to a value that is not of the LengthUnit type, the default value 0 VP is used.
381
382**Atomic service API**: This API can be used in atomic services since API version 12.
383
384**System capability**: SystemCapability.ArkUI.ArkUI.Full
385
386**Parameters**
387
388| Name| Type         | Mandatory| Description        |
389| ------ | ------------- | ---- | ------------ |
390| value   | number | Yes  | Value of the length property.<br>Value range: [0, +∞).|
391| unit   | [LengthUnit](#lengthunit12) | No  | Unit of the length property.|
392
393### px<sup>12+</sup>
394
395static px(value: number): LengthMetrics
396
397Creates a length property in px.
398
399**Atomic service API**: This API can be used in atomic services since API version 12.
400
401**System capability**: SystemCapability.ArkUI.ArkUI.Full
402
403**Parameters**
404
405| Name| Type         | Mandatory| Description        |
406| ------ | ------------- | ---- | ------------ |
407| value   | number | Yes  | Value of the length property.<br>Value range: (-∞, +∞).|
408
409**Return value**
410
411| Type         | Description            |
412| ------------- | ---------------- |
413| [LengthMetrics](#lengthmetrics12) | Instance of the **LengthMetrics** class.|
414
415### vp<sup>12+</sup>
416
417static vp(value: number): LengthMetrics
418
419Creates a length property in vp.
420
421**Atomic service API**: This API can be used in atomic services since API version 12.
422
423**System capability**: SystemCapability.ArkUI.ArkUI.Full
424
425**Parameters**
426
427| Name| Type         | Mandatory| Description        |
428| ------ | ------------- | ---- | ------------ |
429| value   | number | Yes  | Value of the length property.<br>Value range: (-∞, +∞).|
430
431**Return value**
432
433| Type         | Description            |
434| ------------- | ---------------- |
435| [LengthMetrics](#lengthmetrics12) | Instance of the **LengthMetrics** class.|
436
437### fp<sup>12+</sup>
438
439static fp(value: number): LengthMetrics
440
441Creates a length property in fp.
442
443**Atomic service API**: This API can be used in atomic services since API version 12.
444
445**System capability**: SystemCapability.ArkUI.ArkUI.Full
446
447**Parameters**
448
449| Name| Type         | Mandatory| Description        |
450| ------ | ------------- | ---- | ------------ |
451| value   | number | Yes  | Value of the length property.<br>Value range: (-∞, +∞).|
452
453**Return value**
454
455| Type         | Description            |
456| ------------- | ---------------- |
457| [LengthMetrics](#lengthmetrics12) | Instance of the **LengthMetrics** class.|
458
459### percent<sup>12+</sup>
460
461static percent(value: number): LengthMetrics
462
463Creates a length property in percent. The value **1** indicates 100%.
464
465**Atomic service API**: This API can be used in atomic services since API version 12.
466
467**System capability**: SystemCapability.ArkUI.ArkUI.Full
468
469**Parameters**
470
471| Name| Type         | Mandatory| Description        |
472| ------ | ------------- | ---- | ------------ |
473| value   | number | Yes  | Value of the length property.<br>Value range: [0, 1].|
474
475**Return value**
476
477| Type         | Description            |
478| ------------- | ---------------- |
479| [LengthMetrics](#lengthmetrics12) | Instance of the **LengthMetrics** class.|
480
481### lpx<sup>12+</sup>
482
483static lpx(value: number): LengthMetrics
484
485Creates a length property in lpx.
486
487**Atomic service API**: This API can be used in atomic services since API version 12.
488
489**System capability**: SystemCapability.ArkUI.ArkUI.Full
490
491**Parameters**
492
493| Name| Type         | Mandatory| Description        |
494| ------ | ------------- | ---- | ------------ |
495| value   | number | Yes  | Value of the length property.<br>Value range: (-∞, +∞).|
496
497**Return value**
498
499| Type         | Description            |
500| ------------- | ---------------- |
501| [LengthMetrics](#lengthmetrics12) | Instance of the **LengthMetrics** class.|
502
503### resource<sup>12+</sup>
504
505static resource(value: Resource): LengthMetrics
506
507Represents the length of a resource of the Resource type.
508
509**Atomic service API**: This API can be used in atomic services since API version 12.
510
511**System capability**: SystemCapability.ArkUI.ArkUI.Full
512
513**Parameters**
514
515| Name| Type         | Mandatory| Description        |
516| ------ | ------------- | ---- | ------------ |
517| value   | Resource | Yes  | Value of the length property.|
518
519**Return value**
520
521| Type         | Description            |
522| ------------- | ---------------- |
523| [LengthMetrics](#lengthmetrics12) | Instance of the **LengthMetrics** class.|
524
525**Error codes**
526
527For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [System Resource Error Codes](errorcode-system-resource.md).
528
529| ID| Error Message                                  |
530| -------- | ------------------------------------------ |
531| 180001   | System resources does not exist.           |
532| 180002   | The type of system resources is incorrect. |
533
534## ColorMetrics<sup>12+</sup>
535
536Used to mix colors.
537
538**System capability**: SystemCapability.ArkUI.ArkUI.Full
539
540### numeric<sup>12+</sup>
541
542static numeric(value: number): ColorMetrics
543
544Instantiates the **ColorMetrics** class using a color in HEX format.
545
546**Atomic service API**: This API can be used in atomic services since API version 12.
547
548**System capability**: SystemCapability.ArkUI.ArkUI.Full
549
550**Parameters**
551
552| Name| Type         | Mandatory| Description        |
553| ------ | ------------- | ---- | ------------ |
554| value   | number | Yes  | Color in HEX format.<br>RGB and ARGB color values are supported.|
555
556**Return value**
557
558| Type         | Description            |
559| ------------- | ---------------- |
560| [ColorMetrics](#colormetrics12) | Instance of the **ColorMetrics** class.|
561
562### rgba<sup>12+</sup>
563
564static rgba(red: number, green: number, blue: number, alpha?: number): ColorMetrics
565
566Instantiates the **ColorMetrics** class using colors in RGB or RGBA format.
567
568**Atomic service API**: This API can be used in atomic services since API version 12.
569
570**System capability**: SystemCapability.ArkUI.ArkUI.Full
571
572**Parameters**
573
574| Name| Type         | Mandatory| Description        |
575| ------ | ------------- | ---- | ------------ |
576| red   | number | Yes  | Red component of the color. The value is an integer ranging from 0 to 255.|
577| green | number | Yes  | Green component of the color. The value is an integer ranging from 0 to 255.|
578| blue  | number | Yes  | Blue component of the color. The value is an integer ranging from 0 to 255.|
579| alpha | number | No  | Alpha component of the color. The value is a floating point number ranging from 0.0 to 1.0. The default value is **1.0** (fully opaque).|
580
581**Return value**
582
583| Type         | Description            |
584| ------------- | ---------------- |
585| [ColorMetrics](#colormetrics12) | Instance of the **ColorMetrics** class.|
586
587### colorWithSpace<sup>20+</sup>
588
589static colorWithSpace(colorSpace: ColorSpace, red: number, green: number, blue: number, alpha?: number): ColorMetrics
590
591Creates a **ColorMetrics** instance using specified [ColorSpace](./arkui-ts/ts-appendix-enums.md) and RGBA values. Only certain attributes support color configuration in the display-p3 color space.
592
593**Atomic service API**: This API can be used in atomic services since API version 20.
594
595**System capability**: SystemCapability.ArkUI.ArkUI.Full
596
597**Parameters**
598
599| Name| Type         | Mandatory| Description        |
600| ------ | ------------- | ---- | ------------ |
601| colorSpace   | [ColorSpace](./arkui-ts/ts-appendix-enums.md) | Yes  | Color space used to specify the color. To use **ColorSpace.DISPLAY_P3**, the corresponding window must be set to wide color gamut mode using [setWindowColorSpace](./js-apis-window.md#setwindowcolorspace9-1).|
602| red   | number | Yes  | Red component of the color. The value is a floating point number ranging from 0 to 1.|
603| green | number | Yes  | Green component of the color. The value is a floating point number ranging from 0 to 1.|
604| blue  | number | Yes  | Blue component of the color. The value is a floating point number ranging from 0 to 1.|
605| alpha | number | No  | Alpha component of the color. The value is a floating point number ranging from 0.0 to 1.0. The default value is **1.0** (fully opaque).|
606
607**Return value**
608
609| Type         | Description            |
610| ------------- | ---------------- |
611| [ColorMetrics](#colormetrics12) | Instance of the **ColorMetrics** class.|
612
613### resourceColor<sup>12+</sup>
614
615static resourceColor(color: ResourceColor): ColorMetrics
616
617Instantiates the **ColorMetrics** class using a color in resource reference format.
618
619**Atomic service API**: This API can be used in atomic services since API version 12.
620
621**System capability**: SystemCapability.ArkUI.ArkUI.Full
622
623**Parameters**
624
625| Name| Type         | Mandatory| Description        |
626| ------ | ------------- | ---- | ------------ |
627| color | [ResourceColor](arkui-ts/ts-types.md#resourcecolor) | Yes| Color in resource reference format.|
628
629**Return value**
630
631| Type         | Description            |
632| ------------- | ---------------- |
633| [ColorMetrics](#colormetrics12) | Instance of the **ColorMetrics** class.|
634
635**Error codes**
636
637For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [System Resource Error Codes](errorcode-system-resource.md).
638
639| ID| Error Message|
640| -------- | ---------------------------------------- |
641| 401   | Parameter error. Possible cause:1.The type of the input color parameter is not ResourceColor;2.The format of the input color string is not RGB or RGBA.             |
642| 180003   | Failed to obtain the color resource.         |
643
644### blendColor<sup>12+</sup>
645
646blendColor(overlayColor: ColorMetrics): ColorMetrics
647
648Blends colors.
649
650**Atomic service API**: This API can be used in atomic services since API version 12.
651
652**System capability**: SystemCapability.ArkUI.ArkUI.Full
653
654**Parameters**
655
656| Name| Type         | Mandatory| Description        |
657| ------ | ------------- | ---- | ------------ |
658| overlayColor | [ColorMetrics](#colormetrics12) | Yes| Instance of the **ColorMetrics** class for overlaying colors.|
659
660**Return value**
661
662| Type         | Description            |
663| ------------- | ---------------- |
664| [ColorMetrics](#colormetrics12) | Instance of the **ColorMetrics** class after color blending.|
665
666**Error codes**
667
668For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
669
670| ID| Error Message|
671| -------- | ---------------------------------------- |
672| 401   | Parameter error. The type of the input parameter is not ColorMetrics.                |
673
674### color<sup>12+</sup>
675
676get color(): string
677
678Obtains the color of **ColorMetrics**. The return value is a string indicating an RGBA color value.
679
680**Atomic service API**: This API can be used in atomic services since API version 12.
681
682**System capability**: SystemCapability.ArkUI.ArkUI.Full
683
684**Return value**
685
686| Type         | Description            |
687| ------------- | ---------------- |
688| string | String indicating an RGBA color value. Example: **'rgba(255, 100, 255, 0.5)'**|
689
690### red<sup>12+</sup>
691
692get red(): number
693
694Obtains the red component of the ColorMetrics color.
695
696**Atomic service API**: This API can be used in atomic services since API version 12.
697
698**System capability**: SystemCapability.ArkUI.ArkUI.Full
699
700**Return value**
701
702| Type         | Description            |
703| ------------- | ---------------- |
704| number | Red component of the color. The value is an integer ranging from 0 to 255.|
705
706### green<sup>12+</sup>
707
708get green(): number
709
710Obtains the green component of the ColorMetrics color.
711
712**Atomic service API**: This API can be used in atomic services since API version 12.
713
714**System capability**: SystemCapability.ArkUI.ArkUI.Full
715
716**Return value**
717
718| Type         | Description            |
719| ------------- | ---------------- |
720| number | Green component of the color. The value is an integer ranging from 0 to 255.|
721
722### blue<sup>12+</sup>
723
724get blue(): number
725
726Obtains the blue component of the ColorMetrics color.
727
728**Atomic service API**: This API can be used in atomic services since API version 12.
729
730**System capability**: SystemCapability.ArkUI.ArkUI.Full
731
732**Return value**
733
734| Type         | Description            |
735| ------------- | ---------------- |
736| number | Blue component of the color. The value is an integer ranging from 0 to 255.|
737
738### alpha<sup>12+</sup>
739
740get alpha(): number
741
742Obtains the alpha component of the ColorMetrics color.
743
744**Atomic service API**: This API can be used in atomic services since API version 12.
745
746**System capability**: SystemCapability.ArkUI.ArkUI.Full
747
748**Return value**
749
750| Type         | Description            |
751| ------------- | ---------------- |
752| number | Alpha component of the color. The value is an integer ranging from 0 to 255.|
753
754**Example**
755
756```ts
757import { ColorMetrics } from '@kit.ArkUI';
758import { BusinessError } from '@kit.BasicServicesKit';
759
760function getBlendColor(baseColor: ResourceColor): ColorMetrics {
761  let sourceColor: ColorMetrics;
762  try {
763    // When resourceColor and blendColor of ColorMetrics are used, add exception handling.
764    // Error codes 401 and 180003 of the ArkUI subsystem may be returned.
765    sourceColor = ColorMetrics.resourceColor(baseColor).blendColor(ColorMetrics.resourceColor("#19000000"));
766  } catch (error) {
767    console.error("getBlendColor failed, code = " + (error as BusinessError).code + ", message = " +
768    (error as BusinessError).message);
769    sourceColor = ColorMetrics.resourceColor("#19000000");
770  }
771  return sourceColor;
772}
773
774@Entry
775@Component
776struct ColorMetricsSample {
777  build() {
778    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
779      Button("ColorMetrics")
780        .width('80%')
781        .align(Alignment.Center)
782        .height(50)
783        .backgroundColor(getBlendColor(Color.Red).color)
784    }
785    .width('100%')
786    .height('100%')
787  }
788}
789```
790## Corners\<T><sup>12+</sup>
791
792Describes the four corners.
793
794**Atomic service API**: This API can be used in atomic services since API version 12.
795
796**System capability**: SystemCapability.ArkUI.ArkUI.Full
797
798| Name       | Type| Readable| Writable| Description                  |
799| ----------- | ---- | ---- | ---- | ---------------------- |
800| topLeft     | T    | Yes  | Yes  | Radius of the upper left corner.  |
801| topRight    | T    | Yes  | Yes  | Radius of the upper right corner.|
802| bottomLeft  | T    | Yes  | Yes  | Radius of the lower left corner.  |
803| bottomRight | T    | Yes  | Yes  | Radius of the lower right corner.  |
804
805## CornerRadius<sup>12+</sup>
806
807type CornerRadius = Corners\<Vector2>
808
809Sets the radius for the four corners.
810
811**Atomic service API**: This API can be used in atomic services since API version 12.
812
813**System capability**: SystemCapability.ArkUI.ArkUI.Full
814
815| Type                                        | Description              |
816| -------------------------------------------- | ------------------ |
817| [Corners](#cornerst12)[\<Vector2>](#vector2) | Radius of the four corners.|
818
819## BorderRadiuses<sup>12+</sup>
820
821type BorderRadiuses = Corners\<number>
822
823Sets the radius for the four border corners.
824
825**Atomic service API**: This API can be used in atomic services since API version 12.
826
827**System capability**: SystemCapability.ArkUI.ArkUI.Full
828
829| Type                           | Description              |
830| ------------------------------- | ------------------ |
831| [Corners\<number>](#cornerst12) | Radius of the four border corners.|
832
833## Rect<sup>12+</sup>
834
835type Rect = common2D.Rect
836
837Describes a rectangle.
838
839**Atomic service API**: This API can be used in atomic services since API version 12.
840
841**System capability**: SystemCapability.ArkUI.ArkUI.Full
842
843| Type                                                        | Description      |
844| ------------------------------------------------------------ | ---------- |
845| [common2D.Rect](../apis-arkgraphics2d/js-apis-graphics-common2D.md#rect) | Rectangle.|
846
847## RoundRect<sup>12+</sup>
848
849Describes a rectangle with rounded corners.
850
851**Atomic service API**: This API can be used in atomic services since API version 12.
852
853**System capability**: SystemCapability.ArkUI.ArkUI.Full
854
855| Name   | Type                         | Readable| Writable| Description            |
856| ------- | ----------------------------- | ---- | ---- | ---------------- |
857| rect    | [Rect](#rect12)                 | Yes  | Yes  | Attributes of the rectangle.|
858| corners | [CornerRadius](#cornerradius12) | Yes  | Yes  | Attributes of rounded corners.|
859
860## Circle<sup>12+</sup>
861
862Describes a circle.
863
864**Atomic service API**: This API can be used in atomic services since API version 12.
865
866**System capability**: SystemCapability.ArkUI.ArkUI.Full
867
868| Name   | Type  | Readable| Writable| Description                     |
869| ------- | ------ | ---- | ---- | ------------------------- |
870| centerX | number | Yes  | Yes  | X coordinate of the center of the circle, in px.|
871| centerY | number | Yes  | Yes  | Y coordinate of the center of the circle, in px.|
872| radius  | number | Yes  | Yes  | Radius of the circle, in px.<br> Value range: [0, +∞).  |
873
874## CommandPath<sup>12+</sup>
875
876Describes the command for drawing a path.
877
878**Atomic service API**: This API can be used in atomic services since API version 12.
879
880**System capability**: SystemCapability.ArkUI.ArkUI.Full
881
882| Name                                                        | Type  | Readable| Writable| Description                                                        |
883| ------------------------------------------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
884| [commands](./arkui-ts/ts-drawing-components-path.md#commands) | string | Yes  | Yes  | Commands for drawing a path. For details about how to convert the pixel unit, see [Pixel Unit Conversion](./arkui-ts/ts-pixel-units.md#pixel-unit-conversion).<br>Unit: px|
885
886## ShapeMask<sup>12+</sup>
887
888Describes the shape mask.
889
890### constructor<sup>12+</sup>
891
892constructor()
893
894A constructor used to create a **ShapeMask** instance.
895
896**Atomic service API**: This API can be used in atomic services since API version 12.
897
898**System capability**: SystemCapability.ArkUI.ArkUI.Full
899
900### setRectShape<sup>12+</sup>
901
902setRectShape(rect: Rect): void
903
904Sets a rectangle mask.
905
906**Atomic service API**: This API can be used in atomic services since API version 12.
907
908**System capability**: SystemCapability.ArkUI.ArkUI.Full
909
910**Parameters**
911
912| Name| Type         | Mandatory| Description        |
913| ------ | ------------- | ---- | ------------ |
914| rect   | [Rect](#rect12) | Yes  | Shape of the rectangle.|
915
916**Example**
917
918```ts
919import { RenderNode, FrameNode, NodeController, ShapeMask } from '@kit.ArkUI';
920
921class MyNodeController extends NodeController {
922  private rootNode: FrameNode | null = null;
923
924  makeNode(uiContext: UIContext): FrameNode | null {
925    this.rootNode = new FrameNode(uiContext);
926
927    const mask = new ShapeMask();
928    mask.setRectShape({ left: 0, right: uiContext.vp2px(150), top: 0, bottom: uiContext.vp2px(150) });
929    mask.fillColor = 0X55FF0000;
930
931    const renderNode = new RenderNode();
932    renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
933    renderNode.backgroundColor = 0XFF00FF00;
934    renderNode.shapeMask = mask;
935
936    const rootRenderNode = this.rootNode.getRenderNode();
937    if (rootRenderNode !== null) {
938      rootRenderNode.appendChild(renderNode);
939    }
940
941    return this.rootNode;
942  }
943}
944
945@Entry
946@Component
947struct Index {
948  private myNodeController: MyNodeController = new MyNodeController();
949
950  build() {
951    Row() {
952      NodeContainer(this.myNodeController)
953    }
954  }
955}
956```
957
958### setRoundRectShape<sup>12+</sup>
959
960setRoundRectShape(roundRect: RoundRect): void
961
962Sets the mask in the shape of a rectangle with rounded corners.
963
964**Atomic service API**: This API can be used in atomic services since API version 12.
965
966**System capability**: SystemCapability.ArkUI.ArkUI.Full
967
968**Parameters**
969
970| Name   | Type                   | Mandatory| Description            |
971| --------- | ----------------------- | ---- | ---------------- |
972| roundRect | [RoundRect](#roundrect12) | Yes  | Shape of the rectangle with rounded corners.|
973
974**Example**
975
976```ts
977import { RenderNode, FrameNode, NodeController, ShapeMask,RoundRect} from '@kit.ArkUI';
978
979class MyNodeController extends NodeController {
980  private rootNode: FrameNode | null = null;
981
982  makeNode(uiContext: UIContext): FrameNode | null {
983    this.rootNode = new FrameNode(uiContext);
984
985    const mask = new ShapeMask();
986    const roundRect: RoundRect = {
987      rect: { left: 0, top: 0, right: uiContext.vp2px(150), bottom: uiContext.vp2px(150) },
988      corners: {
989        topLeft: { x: 32, y: 32 },
990        topRight: { x: 32, y: 32 },
991        bottomLeft: { x: 32, y: 32 },
992        bottomRight: { x: 32, y: 32 }
993      }
994    }
995    mask.setRoundRectShape(roundRect);
996    mask.fillColor = 0X55FF0000;
997
998    const renderNode = new RenderNode();
999    renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1000    renderNode.backgroundColor = 0XFF00FF00;
1001    renderNode.shapeMask = mask;
1002
1003    const rootRenderNode = this.rootNode.getRenderNode();
1004    if (rootRenderNode !== null) {
1005      rootRenderNode.appendChild(renderNode);
1006    }
1007
1008    return this.rootNode;
1009  }
1010}
1011
1012@Entry
1013@Component
1014struct Index {
1015  private myNodeController: MyNodeController = new MyNodeController();
1016
1017  build() {
1018    Row() {
1019      NodeContainer(this.myNodeController)
1020    }
1021  }
1022}
1023```
1024
1025### setCircleShape<sup>12+</sup>
1026
1027setCircleShape(circle: Circle): void
1028
1029Sets a round mask.
1030
1031**Atomic service API**: This API can be used in atomic services since API version 12.
1032
1033**System capability**: SystemCapability.ArkUI.ArkUI.Full
1034
1035**Parameters**
1036
1037| Name| Type             | Mandatory| Description        |
1038| ------ | ----------------- | ---- | ------------ |
1039| circle | [Circle](#circle12) | Yes  | Round shape.|
1040
1041**Example**
1042
1043```ts
1044import { RenderNode, FrameNode, NodeController, ShapeMask } from '@kit.ArkUI';
1045
1046class MyNodeController extends NodeController {
1047  private rootNode: FrameNode | null = null;
1048
1049  makeNode(uiContext: UIContext): FrameNode | null {
1050    this.rootNode = new FrameNode(uiContext);
1051
1052    const mask = new ShapeMask();
1053    mask.setCircleShape({ centerY: uiContext.vp2px(75), centerX: uiContext.vp2px(75), radius: uiContext.vp2px(75) });
1054    mask.fillColor = 0X55FF0000;
1055
1056    const renderNode = new RenderNode();
1057    renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1058    renderNode.backgroundColor = 0XFF00FF00;
1059    renderNode.shapeMask = mask;
1060
1061    const rootRenderNode = this.rootNode.getRenderNode();
1062    if (rootRenderNode !== null) {
1063      rootRenderNode.appendChild(renderNode);
1064    }
1065
1066    return this.rootNode;
1067  }
1068}
1069
1070@Entry
1071@Component
1072struct Index {
1073  private myNodeController: MyNodeController = new MyNodeController();
1074
1075  build() {
1076    Row() {
1077      NodeContainer(this.myNodeController)
1078    }
1079  }
1080}
1081```
1082
1083### setOvalShape<sup>12+</sup>
1084
1085setOvalShape(oval: Rect): void
1086
1087Sets an oval mask.
1088
1089**Atomic service API**: This API can be used in atomic services since API version 12.
1090
1091**System capability**: SystemCapability.ArkUI.ArkUI.Full
1092
1093**Parameters**
1094
1095| Name| Type         | Mandatory| Description          |
1096| ------ | ------------- | ---- | -------------- |
1097| oval   | [Rect](#rect12) | Yes  | Oval shape.|
1098
1099**Example**
1100
1101```ts
1102import { RenderNode, FrameNode, NodeController, ShapeMask } from '@kit.ArkUI';
1103
1104class MyNodeController extends NodeController {
1105  private rootNode: FrameNode | null = null;
1106
1107  makeNode(uiContext: UIContext): FrameNode | null {
1108    this.rootNode = new FrameNode(uiContext);
1109
1110    const mask = new ShapeMask();
1111    mask.setOvalShape({ left: 0, right: uiContext.vp2px(150), top: 0, bottom: uiContext.vp2px(100) });
1112    mask.fillColor = 0X55FF0000;
1113
1114    const renderNode = new RenderNode();
1115    renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1116    renderNode.backgroundColor = 0XFF00FF00;
1117    renderNode.shapeMask = mask;
1118
1119    const rootRenderNode = this.rootNode.getRenderNode();
1120    if (rootRenderNode !== null) {
1121      rootRenderNode.appendChild(renderNode);
1122    }
1123
1124    return this.rootNode;
1125  }
1126}
1127
1128@Entry
1129@Component
1130struct Index {
1131  private myNodeController: MyNodeController = new MyNodeController();
1132
1133  build() {
1134    Row() {
1135      NodeContainer(this.myNodeController)
1136    }
1137  }
1138}
1139```
1140
1141### setCommandPath<sup>12+</sup>
1142
1143setCommandPath(path: CommandPath): void
1144
1145Sets the command for drawing a path.
1146
1147**Atomic service API**: This API can be used in atomic services since API version 12.
1148
1149**System capability**: SystemCapability.ArkUI.ArkUI.Full
1150
1151**Parameters**
1152
1153| Name| Type                       | Mandatory| Description          |
1154| ------ | --------------------------- | ---- | -------------- |
1155| path   | [CommandPath](#commandpath12) | Yes  | Command for drawing a path.|
1156
1157**Example**
1158
1159```ts
1160import { RenderNode, FrameNode, NodeController, ShapeMask } from '@kit.ArkUI';
1161
1162const mask = new ShapeMask();
1163mask.setCommandPath({ commands: "M100 0 L0 100 L50 200 L150 200 L200 100 Z" });
1164mask.fillColor = 0X55FF0000;
1165
1166const renderNode = new RenderNode();
1167renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1168renderNode.backgroundColor = 0XFF00FF00;
1169renderNode.shapeMask = mask;
1170
1171
1172class MyNodeController extends NodeController {
1173  private rootNode: FrameNode | null = null;
1174
1175  makeNode(uiContext: UIContext): FrameNode | null {
1176    this.rootNode = new FrameNode(uiContext);
1177
1178    const rootRenderNode = this.rootNode.getRenderNode();
1179    if (rootRenderNode !== null) {
1180      rootRenderNode.appendChild(renderNode);
1181    }
1182
1183    return this.rootNode;
1184  }
1185}
1186
1187@Entry
1188@Component
1189struct Index {
1190  private myNodeController: MyNodeController = new MyNodeController();
1191
1192  build() {
1193    Row() {
1194      NodeContainer(this.myNodeController)
1195    }
1196  }
1197}
1198```
1199
1200### fillColor<sup>12+</sup>
1201
1202fillColor: number
1203
1204Describes the fill color of the mask, in ARGB format. The default value is **0XFF000000**.
1205
1206**Atomic service API**: This API can be used in atomic services since API version 12.
1207
1208**System capability**: SystemCapability.ArkUI.ArkUI.Full
1209
1210**Example**
1211
1212```ts
1213import { RenderNode, FrameNode, NodeController, ShapeMask } from '@kit.ArkUI';
1214
1215const mask = new ShapeMask();
1216mask.setRectShape({ left: 0, right: 150, top: 0, bottom: 150 });
1217mask.fillColor = 0X55FF0000;
1218
1219const renderNode = new RenderNode();
1220renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1221renderNode.backgroundColor = 0XFF00FF00;
1222renderNode.shapeMask = mask;
1223
1224
1225class MyNodeController extends NodeController {
1226  private rootNode: FrameNode | null = null;
1227
1228  makeNode(uiContext: UIContext): FrameNode | null {
1229    this.rootNode = new FrameNode(uiContext);
1230
1231    const rootRenderNode = this.rootNode.getRenderNode();
1232    if (rootRenderNode !== null) {
1233      rootRenderNode.appendChild(renderNode);
1234    }
1235
1236    return this.rootNode;
1237  }
1238}
1239
1240@Entry
1241@Component
1242struct Index {
1243  private myNodeController: MyNodeController = new MyNodeController();
1244
1245  build() {
1246    Row() {
1247      NodeContainer(this.myNodeController)
1248    }
1249  }
1250}
1251```
1252
1253### strokeColor<sup>12+</sup>
1254
1255strokeColor: number
1256
1257Sets the stroke color for the mask, in ARGB format. The default value is **0XFF000000**.
1258
1259**Atomic service API**: This API can be used in atomic services since API version 12.
1260
1261**System capability**: SystemCapability.ArkUI.ArkUI.Full
1262
1263**Example**
1264
1265```ts
1266import { RenderNode, FrameNode, NodeController, ShapeMask } from '@kit.ArkUI';
1267
1268const mask = new ShapeMask();
1269mask.setRectShape({ left: 0, right: 150, top: 0, bottom: 150 });
1270mask.strokeColor = 0XFFFF0000;
1271mask.strokeWidth = 24;
1272
1273const renderNode = new RenderNode();
1274renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1275renderNode.backgroundColor = 0XFF00FF00;
1276renderNode.shapeMask = mask;
1277
1278
1279class MyNodeController extends NodeController {
1280  private rootNode: FrameNode | null = null;
1281
1282  makeNode(uiContext: UIContext): FrameNode | null {
1283    this.rootNode = new FrameNode(uiContext);
1284
1285    const rootRenderNode = this.rootNode.getRenderNode();
1286    if (rootRenderNode !== null) {
1287      rootRenderNode.appendChild(renderNode);
1288    }
1289
1290    return this.rootNode;
1291  }
1292}
1293
1294@Entry
1295@Component
1296struct Index {
1297  private myNodeController: MyNodeController = new MyNodeController();
1298
1299  build() {
1300    Row() {
1301      NodeContainer(this.myNodeController)
1302    }
1303  }
1304}
1305```
1306
1307### strokeWidth<sup>12+</sup>
1308
1309strokeWidth: number
1310
1311Sets the stroke width for the mask, in px. The default value is **0**.
1312
1313**Atomic service API**: This API can be used in atomic services since API version 12.
1314
1315**System capability**: SystemCapability.ArkUI.ArkUI.Full
1316
1317**Example**
1318
1319```ts
1320import { RenderNode, FrameNode, NodeController, ShapeMask } from '@kit.ArkUI';
1321
1322const mask = new ShapeMask();
1323mask.setRectShape({ left: 0, right: 150, top: 0, bottom: 150 });
1324mask.strokeColor = 0XFFFF0000;
1325mask.strokeWidth = 24;
1326
1327const renderNode = new RenderNode();
1328renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1329renderNode.backgroundColor = 0XFF00FF00;
1330renderNode.shapeMask = mask;
1331
1332
1333class MyNodeController extends NodeController {
1334  private rootNode: FrameNode | null = null;
1335
1336  makeNode(uiContext: UIContext): FrameNode | null {
1337    this.rootNode = new FrameNode(uiContext);
1338
1339    const rootRenderNode = this.rootNode.getRenderNode();
1340    if (rootRenderNode !== null) {
1341      rootRenderNode.appendChild(renderNode);
1342    }
1343
1344    return this.rootNode;
1345  }
1346}
1347
1348@Entry
1349@Component
1350struct Index {
1351  private myNodeController: MyNodeController = new MyNodeController();
1352
1353  build() {
1354    Row() {
1355      NodeContainer(this.myNodeController)
1356    }
1357  }
1358}
1359```
1360
1361## ShapeClip<sup>12+</sup>
1362
1363Sets the clipping shape.
1364
1365### constructor<sup>12+</sup>
1366
1367constructor()
1368
1369A constructor used to create a **ShapeClip** object.
1370
1371**System capability**: SystemCapability.ArkUI.ArkUI.Full
1372
1373**Atomic service API**: This API can be used in atomic services since API version 12.
1374
1375### setRectShape<sup>12+</sup>
1376
1377setRectShape(rect: Rect): void
1378
1379Sets a rectangle as the clipping shape.
1380
1381**System capability**: SystemCapability.ArkUI.ArkUI.Full
1382
1383**Atomic service API**: This API can be used in atomic services since API version 12.
1384
1385**Parameters**
1386
1387| Name| Type         | Mandatory| Description        |
1388| ------ | ------------- | ---- | ------------ |
1389| rect   | [Rect](#rect12) | Yes  | Shape of the rectangle.|
1390
1391**Example**
1392
1393```ts
1394import { RenderNode, FrameNode, NodeController, ShapeClip } from '@kit.ArkUI';
1395
1396const clip = new ShapeClip();
1397clip.setCommandPath({ commands: "M100 0 L0 100 L50 200 L150 200 L200 100 Z" });
1398
1399const renderNode = new RenderNode();
1400renderNode.frame = {
1401  x: 0,
1402  y: 0,
1403  width: 150,
1404  height: 150
1405};
1406renderNode.backgroundColor = 0XFF00FF00;
1407renderNode.shapeClip = clip;
1408const shapeClip = renderNode.shapeClip;
1409
1410class MyNodeController extends NodeController {
1411  private rootNode: FrameNode | null = null;
1412
1413  makeNode(uiContext: UIContext): FrameNode | null {
1414    this.rootNode = new FrameNode(uiContext);
1415
1416    const rootRenderNode = this.rootNode.getRenderNode();
1417    if (rootRenderNode !== null) {
1418      rootRenderNode.appendChild(renderNode);
1419    }
1420
1421    return this.rootNode;
1422  }
1423}
1424
1425@Entry
1426@Component
1427struct Index {
1428  private myNodeController: MyNodeController = new MyNodeController();
1429
1430  build() {
1431    Column() {
1432      NodeContainer(this.myNodeController)
1433        .borderWidth(1)
1434      Button("setRectShape")
1435        .onClick(() => {
1436          shapeClip.setRectShape({
1437            left: 0,
1438            right: 150,
1439            top: 0,
1440            bottom: 150
1441          });
1442          renderNode.shapeClip = shapeClip;
1443        })
1444    }
1445  }
1446}
1447```
1448
1449### setRoundRectShape<sup>12+</sup>
1450
1451setRoundRectShape(roundRect: RoundRect): void
1452
1453Sets a rectangle with rounded corners for shape clipping.
1454
1455**System capability**: SystemCapability.ArkUI.ArkUI.Full
1456
1457**Atomic service API**: This API can be used in atomic services since API version 12.
1458
1459**Parameters**
1460
1461| Name   | Type                   | Mandatory| Description            |
1462| --------- | ----------------------- | ---- | ---------------- |
1463| roundRect | [RoundRect](#roundrect12) | Yes  | Shape of the rectangle with rounded corners.|
1464
1465**Example**
1466```ts
1467import { RenderNode, FrameNode, NodeController, ShapeClip } from '@kit.ArkUI';
1468
1469const clip = new ShapeClip();
1470clip.setCommandPath({ commands: "M100 0 L0 100 L50 200 L150 200 L200 100 Z" });
1471
1472const renderNode = new RenderNode();
1473renderNode.frame = {
1474  x: 0,
1475  y: 0,
1476  width: 150,
1477  height: 150
1478};
1479renderNode.backgroundColor = 0XFF00FF00;
1480renderNode.shapeClip = clip;
1481
1482class MyNodeController extends NodeController {
1483  private rootNode: FrameNode | null = null;
1484
1485  makeNode(uiContext: UIContext): FrameNode | null {
1486    this.rootNode = new FrameNode(uiContext);
1487
1488    const rootRenderNode = this.rootNode.getRenderNode();
1489    if (rootRenderNode !== null) {
1490      rootRenderNode.appendChild(renderNode);
1491    }
1492
1493    return this.rootNode;
1494  }
1495}
1496
1497@Entry
1498@Component
1499struct Index {
1500  private myNodeController: MyNodeController = new MyNodeController();
1501
1502  build() {
1503    Column() {
1504      NodeContainer(this.myNodeController)
1505        .borderWidth(1)
1506      Button("setRoundRectShape")
1507        .onClick(() => {
1508          renderNode.shapeClip.setRoundRectShape({
1509            rect: {
1510              left: 0,
1511              top: 0,
1512              right: this.getUIContext().vp2px(150),
1513              bottom: this.getUIContext().vp2px(150)
1514            },
1515            corners: {
1516              topLeft: { x: 32, y: 32 },
1517              topRight: { x: 32, y: 32 },
1518              bottomLeft: { x: 32, y: 32 },
1519              bottomRight: { x: 32, y: 32 }
1520            }
1521          });
1522          renderNode.shapeClip = renderNode.shapeClip;
1523        })
1524    }
1525  }
1526}
1527```
1528
1529### setCircleShape<sup>12+</sup>
1530
1531setCircleShape(circle: Circle): void
1532
1533Sets a circle as the clipping shape.
1534
1535**System capability**: SystemCapability.ArkUI.ArkUI.Full
1536
1537**Atomic service API**: This API can be used in atomic services since API version 12.
1538
1539**Parameters**
1540
1541| Name| Type             | Mandatory| Description        |
1542| ------ | ----------------- | ---- | ------------ |
1543| circle | [Circle](#circle12) | Yes  | Round shape.|
1544
1545**Example**
1546
1547```ts
1548import { RenderNode, FrameNode, NodeController, ShapeClip } from '@kit.ArkUI';
1549
1550const clip = new ShapeClip();
1551clip.setCommandPath({ commands: "M100 0 L0 100 L50 200 L150 200 L200 100 Z" });
1552
1553const renderNode = new RenderNode();
1554renderNode.frame = {
1555  x: 0,
1556  y: 0,
1557  width: 150,
1558  height: 150
1559};
1560renderNode.backgroundColor = 0XFF00FF00;
1561renderNode.shapeClip = clip;
1562
1563class MyNodeController extends NodeController {
1564  private rootNode: FrameNode | null = null;
1565
1566  makeNode(uiContext: UIContext): FrameNode | null {
1567    this.rootNode = new FrameNode(uiContext);
1568
1569    const rootRenderNode = this.rootNode.getRenderNode();
1570    if (rootRenderNode !== null) {
1571      rootRenderNode.appendChild(renderNode);
1572    }
1573
1574    return this.rootNode;
1575  }
1576}
1577
1578@Entry
1579@Component
1580struct Index {
1581  private myNodeController: MyNodeController = new MyNodeController();
1582
1583  build() {
1584    Column() {
1585      NodeContainer(this.myNodeController)
1586        .borderWidth(1)
1587      Button("setCircleShape")
1588        .onClick(() => {
1589          renderNode.shapeClip.setCircleShape({ centerY: 75, centerX: 75, radius: 75 });
1590          renderNode.shapeClip = renderNode.shapeClip;
1591
1592        })
1593    }
1594  }
1595}
1596```
1597
1598### setOvalShape<sup>12+</sup>
1599
1600setOvalShape(oval: Rect): void
1601
1602Sets an oval shape as the clipping shape.
1603
1604**System capability**: SystemCapability.ArkUI.ArkUI.Full
1605
1606**Atomic service API**: This API can be used in atomic services since API version 12.
1607
1608**Parameters**
1609
1610| Name| Type         | Mandatory| Description          |
1611| ------ | ------------- | ---- | -------------- |
1612| oval   | [Rect](#rect12) | Yes  | Oval shape.|
1613
1614**Example**
1615
1616```ts
1617import { RenderNode, FrameNode, NodeController, ShapeClip } from '@kit.ArkUI';
1618
1619const clip = new ShapeClip();
1620clip.setCommandPath({ commands: "M100 0 L0 100 L50 200 L150 200 L200 100 Z" });
1621
1622const renderNode = new RenderNode();
1623renderNode.frame = {
1624  x: 0,
1625  y: 0,
1626  width: 150,
1627  height: 150
1628};
1629renderNode.backgroundColor = 0XFF00FF00;
1630renderNode.shapeClip = clip;
1631
1632class MyNodeController extends NodeController {
1633  private rootNode: FrameNode | null = null;
1634
1635  makeNode(uiContext: UIContext): FrameNode | null {
1636    this.rootNode = new FrameNode(uiContext);
1637
1638    const rootRenderNode = this.rootNode.getRenderNode();
1639    if (rootRenderNode !== null) {
1640      rootRenderNode.appendChild(renderNode);
1641    }
1642
1643    return this.rootNode;
1644  }
1645}
1646
1647@Entry
1648@Component
1649struct Index {
1650  private myNodeController: MyNodeController = new MyNodeController();
1651
1652  build() {
1653    Column() {
1654      NodeContainer(this.myNodeController)
1655        .borderWidth(1)
1656      Button("setOvalShape")
1657        .onClick(() => {
1658          renderNode.shapeClip.setOvalShape({
1659            left: 0,
1660            right: this.getUIContext().vp2px(150),
1661            top: 0,
1662            bottom: this.getUIContext().vp2px(100)
1663          });
1664          renderNode.shapeClip = renderNode.shapeClip;
1665        })
1666    }
1667  }
1668}
1669```
1670
1671### setCommandPath<sup>12+</sup>
1672
1673setCommandPath(path: CommandPath): void
1674
1675Sets the command for drawing a path.
1676
1677**System capability**: SystemCapability.ArkUI.ArkUI.Full
1678
1679**Atomic service API**: This API can be used in atomic services since API version 12.
1680
1681**Parameters**
1682
1683| Name| Type                       | Mandatory| Description          |
1684| ------ | --------------------------- | ---- | -------------- |
1685| path   | [CommandPath](#commandpath12) | Yes  | Command for drawing a path.|
1686
1687**Example**
1688
1689```ts
1690import { RenderNode, FrameNode, NodeController, ShapeClip } from '@kit.ArkUI';
1691
1692const clip = new ShapeClip();
1693clip.setCommandPath({ commands: "M100 0 L0 100 L50 200 L150 200 L200 100 Z" });
1694
1695const renderNode = new RenderNode();
1696renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1697renderNode.backgroundColor = 0XFF00FF00;
1698renderNode.shapeClip = clip;
1699
1700class MyNodeController extends NodeController {
1701  private rootNode: FrameNode | null = null;
1702
1703  makeNode(uiContext: UIContext): FrameNode | null {
1704    this.rootNode = new FrameNode(uiContext);
1705
1706    const rootRenderNode = this.rootNode.getRenderNode();
1707    if (rootRenderNode !== null) {
1708      rootRenderNode.appendChild(renderNode);
1709    }
1710
1711    return this.rootNode;
1712  }
1713}
1714
1715@Entry
1716@Component
1717struct Index {
1718  private myNodeController: MyNodeController = new MyNodeController();
1719
1720  build() {
1721    Column() {
1722      NodeContainer(this.myNodeController)
1723        .borderWidth(1)
1724      Button("setCommandPath")
1725        .onClick(()=>{
1726          renderNode.shapeClip.setCommandPath({ commands: "M100 0 L0 100 L50 200 L150 200 L200 100 Z" });
1727          renderNode.shapeClip = renderNode.shapeClip;
1728        })
1729    }
1730  }
1731}
1732```
1733
1734## edgeColors<sup>12+</sup>
1735
1736edgeColors(all: number): Edges\<number>
1737
1738Generates an **edgeColors** object with the specified edge color for all edges.
1739
1740**Atomic service API**: This API can be used in atomic services since API version 12.
1741
1742**System capability**: SystemCapability.ArkUI.ArkUI.Full
1743
1744**Parameters**
1745
1746| Name| Type  | Mandatory| Description                |
1747| ------ | ------ | ---- | -------------------- |
1748| all    | number | Yes  | Edge color, in ARGB format, for example, **0xffff00ff**.<br>Value range: [0, 0xffffffff]|
1749
1750**Return value**
1751
1752| Type                    | Description                                  |
1753| ------------------------ | -------------------------------------- |
1754| [Edges\<number>](#edgest12) | **edgeColors** object whose edge colors are all at the specified value.|
1755
1756**Example**
1757
1758```ts
1759import { RenderNode, FrameNode, NodeController, edgeColors } from '@kit.ArkUI';
1760
1761const renderNode = new RenderNode();
1762renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1763renderNode.backgroundColor = 0XFF00FF00;
1764renderNode.borderWidth = { left: 8, top: 8, right: 8, bottom: 8 };
1765renderNode.borderColor = edgeColors(0xFF0000FF);
1766
1767
1768class MyNodeController extends NodeController {
1769  private rootNode: FrameNode | null = null;
1770
1771  makeNode(uiContext: UIContext): FrameNode | null {
1772    this.rootNode = new FrameNode(uiContext);
1773
1774    const rootRenderNode = this.rootNode.getRenderNode();
1775    if (rootRenderNode !== null) {
1776      rootRenderNode.appendChild(renderNode);
1777    }
1778
1779    return this.rootNode;
1780  }
1781}
1782
1783@Entry
1784@Component
1785struct Index {
1786  private myNodeController: MyNodeController = new MyNodeController();
1787
1788  build() {
1789    Row() {
1790      NodeContainer(this.myNodeController)
1791    }
1792  }
1793}
1794```
1795
1796## edgeWidths<sup>12+</sup>
1797
1798edgeWidths(all: number): Edges\<number>
1799
1800Generates an **edgeWidths** object with the specified edge width for all edges.
1801
1802**Atomic service API**: This API can be used in atomic services since API version 12.
1803
1804**System capability**: SystemCapability.ArkUI.ArkUI.Full
1805
1806**Parameters**
1807
1808| Name| Type  | Mandatory| Description                |
1809| ------ | ------ | ---- | -------------------- |
1810| all    | number | Yes  | Edge width, in vp.<br>Value range: [0, +∞).|
1811
1812**Return value**
1813
1814| Type                    | Description                                  |
1815| ------------------------ | -------------------------------------- |
1816| [Edges\<number>](#edgest12) | **edgeWidths** object whose edge widths are all at the specified value.|
1817
1818**Example**
1819
1820```ts
1821import { RenderNode, FrameNode, NodeController, edgeWidths } from '@kit.ArkUI';
1822
1823const renderNode = new RenderNode();
1824renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1825renderNode.backgroundColor = 0XFF00FF00;
1826renderNode.borderWidth = edgeWidths(8);
1827renderNode.borderColor = { left: 0xFF0000FF, top: 0xFF0000FF, right: 0xFF0000FF, bottom: 0xFF0000FF };
1828
1829
1830class MyNodeController extends NodeController {
1831  private rootNode: FrameNode | null = null;
1832
1833  makeNode(uiContext: UIContext): FrameNode | null {
1834    this.rootNode = new FrameNode(uiContext);
1835
1836    const rootRenderNode = this.rootNode.getRenderNode();
1837    if (rootRenderNode !== null) {
1838      rootRenderNode.appendChild(renderNode);
1839    }
1840
1841    return this.rootNode;
1842  }
1843}
1844
1845@Entry
1846@Component
1847struct Index {
1848  private myNodeController: MyNodeController = new MyNodeController();
1849
1850  build() {
1851    Row() {
1852      NodeContainer(this.myNodeController)
1853    }
1854  }
1855}
1856```
1857
1858## borderStyles<sup>12+</sup>
1859
1860borderStyles(all: BorderStyle): Edges\<BorderStyle>
1861
1862Generates a **borderStyles** object with the specified border style color for all borders.
1863
1864**Atomic service API**: This API can be used in atomic services since API version 12.
1865
1866**System capability**: SystemCapability.ArkUI.ArkUI.Full
1867
1868**Parameters**
1869
1870| Name| Type                                                      | Mandatory| Description      |
1871| ------ | ---------------------------------------------------------- | ---- | ---------- |
1872| all    | [BorderStyle](./arkui-ts/ts-appendix-enums.md#borderstyle) | Yes  | Border style.|
1873
1874**Return value**
1875
1876| Type                                                                       | Description                                  |
1877| --------------------------------------------------------------------------- | -------------------------------------- |
1878| [Edges](#edgest12)<[BorderStyle](./arkui-ts/ts-appendix-enums.md#borderstyle)> | **borderStyles** object whose borders are all in the specified style.|
1879
1880**Example**
1881
1882```ts
1883import { RenderNode, FrameNode, NodeController, borderStyles } from '@kit.ArkUI';
1884
1885const renderNode = new RenderNode();
1886renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1887renderNode.backgroundColor = 0XFF00FF00;
1888renderNode.borderWidth = { left: 8, top: 8, right: 8, bottom: 8 };
1889renderNode.borderColor = { left: 0xFF0000FF, top: 0xFF0000FF, right: 0xFF0000FF, bottom: 0xFF0000FF };
1890renderNode.borderStyle = borderStyles(BorderStyle.Dotted);
1891
1892
1893class MyNodeController extends NodeController {
1894  private rootNode: FrameNode | null = null;
1895
1896  makeNode(uiContext: UIContext): FrameNode | null {
1897    this.rootNode = new FrameNode(uiContext);
1898
1899    const rootRenderNode = this.rootNode.getRenderNode();
1900    if (rootRenderNode !== null) {
1901      rootRenderNode.appendChild(renderNode);
1902    }
1903
1904    return this.rootNode;
1905  }
1906}
1907
1908@Entry
1909@Component
1910struct Index {
1911  private myNodeController: MyNodeController = new MyNodeController();
1912
1913  build() {
1914    Row() {
1915      NodeContainer(this.myNodeController)
1916    }
1917  }
1918}
1919```
1920
1921## borderRadiuses<sup>12+</sup>
1922
1923borderRadiuses(all: number): BorderRadiuses
1924
1925Generates a **borderRadiuses** object with the specified radius for all border corners.
1926
1927**Atomic service API**: This API can be used in atomic services since API version 12.
1928
1929**System capability**: SystemCapability.ArkUI.ArkUI.Full
1930
1931**Parameters**
1932
1933| Name| Type  | Mandatory| Description      |
1934| ------ | ------ | ---- | ---------- |
1935| all    | number | Yes  | Radius of border corners.<br>Unit: vp.<br>Value range: [0, +∞).|
1936
1937**Return value**
1938
1939| Type                             | Description                                  |
1940| --------------------------------- | -------------------------------------- |
1941| [BorderRadiuses](#borderradiuses12) | **borderRadiuses** object whose border corners all have the specified radius.|
1942
1943**Example**
1944
1945```ts
1946import { RenderNode, FrameNode, NodeController, borderRadiuses }  from '@kit.ArkUI';
1947
1948const renderNode = new RenderNode();
1949renderNode.frame = { x: 0, y: 0, width: 150, height: 150 };
1950renderNode.backgroundColor = 0XFF00FF00;
1951renderNode.borderRadius = borderRadiuses(32);
1952
1953
1954class MyNodeController extends NodeController {
1955  private rootNode: FrameNode | null = null;
1956
1957  makeNode(uiContext: UIContext): FrameNode | null {
1958    this.rootNode = new FrameNode(uiContext);
1959
1960    const rootRenderNode = this.rootNode.getRenderNode();
1961    if (rootRenderNode !== null) {
1962      rootRenderNode.appendChild(renderNode);
1963    }
1964
1965    return this.rootNode;
1966  }
1967}
1968
1969@Entry
1970@Component
1971struct Index {
1972  private myNodeController: MyNodeController = new MyNodeController();
1973
1974  build() {
1975    Row() {
1976      NodeContainer(this.myNodeController)
1977    }
1978  }
1979}
1980```
1981