多边形
Property | Description | Type | Required | Default |
---|---|---|---|---|
points | 点坐标 | {x: number, y: number}[] | true | - |
stroke | 描边颜色 | string | - | |
fill | 填充颜色 | string | Gradient | false | - |
stroke | 描边颜色 | string | false | - |
strokeWidth | 描边宽度 | number | false | 1 |
strokeDashArray | 描边点划线 | number[] | false | - |
strokeDashOffset | 描边点划线偏移 | number | false | 0 |
strokeLineCap | 开放自路径两端的形状 | CanvasLineCap | false | - |
strokeLineJoin | 转角处形状 | CanvasLineJoin | false | - |
strokeMiterLimit | 转角最大距离 | number | false | 4 |
示例
Source Code
js
const rubbing = new Rubbing({
selector: '#canvas',
background: '#fff',
width: 300,
height: 300,
})
await rubbing.init()
rubbing.loadFrom({
objects: [
{
type: 'polygon',
fill: '#7c3aed',
points: [
{ x: 0, y: 100 },
{ x: 200, y: 50 },
{ x: 300, y: 200 },
{ x: 100, y: 100 },
{ x: 0, y: 100 },
],
},
],
})