矩形 | 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]

继承属性

图层属性 Layer

布局属性 Layout

填充样式 Fill

描边样式 stroke

圆角样式 corner

特效样式 Effect

继承

UI > Leaf