Rect
绘制矩形、圆角矩形。
关键属性
width: number
宽度。
height: number
高度。
圆角属性
cornerRadius: number
| number
[]
圆角大小,可以分别设置 4 个圆角。
ts
cornerRadius: [20, 10, 20, 10] // [topLeft, topRight, bottomRight, bottomLeft]
cornerRadius: [20, 10, 20] // [topLeft, (topRight-bottomLeft), bottomRight]
cornerRadius: [20, 10] // [ (topLeft-bottomRight), (topRight-bottomLeft)]
cornerRadius: 20 // all
继承元素
UI
示例
绘制矩形
ts
import { Leafer, Rect } from 'leafer-ui'
const leafer = new Leafer({ view: window })
const rect = new Rect({
width: 100,
height: 100,
fill: 'rgb(50,205,121)'
})
leafer.add(rect)
绘制圆角矩形
ts
import { Leafer, Rect } from 'leafer-ui'
const leafer = new Leafer({ view: window })
const rect = new Rect({
width: 100,
height: 100,
fill: 'rgb(50,205,121)',
cornerRadius: 20
})
leafer.add(rect)
绘制不同圆角的矩形
ts
import { Leafer, Rect } from 'leafer-ui'
const leafer = new Leafer({ view: window })
const rect = new Rect({
width: 100,
height: 100,
fill: 'rgb(50,205,121)',
cornerRadius: [0, 40, 20, 40]
})
leafer.add(rect)