矩形 | Rect
用于绘制矩形、圆角矩形。
关键属性
cornerRadius: number | number[]
圆角大小。
const rect = new Rect({
width: 100,
height: 100,
fill: 'rgb(50,205,121)',
cornerRadius: 20,
})
分别设置 4 个圆角。
rect.cornerRadius = [20, 10, 20, 10] // [topLeft, topRight, bottomRight, bottomLeft]
rect.cornerRadius = [20, 10, 20] // [topLeft, (topRight-bottomRight), bottomLeft]
rect.cornerRadius = [20, 10] // [ (topLeft-bottomRight), (topRight-bottomLeft)]
strokeWidth?: number | number[]
边框宽度。
rect.strokeWidth = 20
分别设置 4 个边框。
// top left bottom right
rect.strokeWidth = [2, 1, 2, 1] // [top, left, bottom, right]
rect.strokeWidth = [2, 1, 1] // [top, left-right, bottom]
rect.strokeWidth = [2, 1] // = [top-bottom, left-right]