“95fe318e3ee19004419eb5aff09bca7ddaacad46”上不存在“git@gitcode.net:paddlepaddle/PaddleDetection.git”
ts-drawing-components-rect.md 2.6 KB
Newer Older
Z
zengyawen 已提交
1
# Rect
Z
zengyawen 已提交
2

Z
zengyawen 已提交
3

Mr-YX's avatar
Mr-YX 已提交
4
> **NOTE**<br>
Z
zengyawen 已提交
5
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
Z
zengyawen 已提交
6

Z
zengyawen 已提交
7

8
The **<Rect\>** component is used to draw a rectangle.
Z
zengyawen 已提交
9 10 11


## Required Permissions
Z
zengyawen 已提交
12 13 14

None

Z
zengyawen 已提交
15 16

## Child Components
Z
zengyawen 已提交
17 18 19 20

None


Z
zengyawen 已提交
21 22 23 24 25
## APIs

Rect(value:{options?: {width: Length,height: Length,radius?: Length | Array&lt;Length&gt;} | {width: Length,height: Length,radiusWidth?: Length,radiusHeight?: Length}})

- Parameters
Mr-YX's avatar
Mr-YX 已提交
26
  | Name | Type | Mandatory | Default Value | Description | 
Z
zengyawen 已提交
27
  | -------- | -------- | -------- | -------- | -------- |
28
  | options | Object | No | - | Options of the rectangle to draw. For details, see the **options** parameters. | 
Z
zengyawen 已提交
29 30

- options parameters
Mr-YX's avatar
Mr-YX 已提交
31
  | Name | Type | Mandatory | Default Value | Description | 
Z
zengyawen 已提交
32
  | -------- | -------- | -------- | -------- | -------- |
33 34 35
  | width | Length | Yes | - | Width of the rectangle. | 
  | height | Length | Yes | - | Height of the rectangle. | 
  | radius | Length \| Array&lt;Length&gt; | No | 0 | Radius of the rounded corner. You can set the radius of four rounded corners. | 
E
esterzhou 已提交
36 37
  | radiusWidth | Length | No | 0 | Width of the rounded corner. | 
  | radiusHeight | Length | No | 0 | Height of the rounded corner. | 
Z
zengyawen 已提交
38 39 40 41


## Attributes

Mr-YX's avatar
Mr-YX 已提交
42
| Name | Type | Default Value | Mandatory | Description | 
Z
zengyawen 已提交
43
| -------- | -------- | -------- | -------- | -------- |
44 45 46
| width | Length | 0 | No | Width of the rectangle. | 
| height | Length | 0 | No | Height of the rectangle. | 
| radiusWidth | Length | 0 | No | Width of the rounded corner. The width and height are the same when only the width is set. | 
E
esterzhou 已提交
47
| radiusHeight | Length | 0 | No | Height of the rounded corner. The width and height are the same only when the height is set. | 
48
| radius | Length \| Array&lt;Length&gt; | 0 | No | Radius of the rounded corner. | 
Z
zengyawen 已提交
49 50 51 52 53


## Example

  
Mr-YX's avatar
Mr-YX 已提交
54
```ts
Z
zengyawen 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
@Entry
@Component
struct RectExample {
  build() {
    Column({ space: 5 }) {
      Text('normal').fontSize(9).fontColor(0xCCCCCC).width('90%')
      // Draw a 90% x 50 rectangle.
      Rect({ width: '90%', height: 50 })
      // Draw a 90% x 50 rectangle.
      Rect().width('90%').height(50)

      Text('with rounded corners').fontSize(9).fontColor(0xCCCCCC).width('90%')
      // Draw a 90% x 50 rectangle with the width and height of the rounded corner being 20.
      Rect({ width: '90%', height: 50 }).radiusHeight(20).radiusWidth(20)
      // Draw a 90% x 50 rectangle with the width and height of the rounded corner being 20.
      Rect({ width: '90%', height: 50 }).radius(20)
    }.width('100%').margin({ top: 5 })
  }
}
```

Mr-YX's avatar
Mr-YX 已提交
76
![en-us_image_0000001212218454](figures/en-us_image_0000001212218454.png)