Skip to content

折线

PropertyDescriptionTypeRequiredDefault
points点坐标{x: number, y: number}[]true-
fill填充颜色string | Gradientfalse-
stroke描边颜色stringfalse-
strokeWidth描边宽度numberfalse1
strokeDashArray描边点划线number[]false-
strokeDashOffset描边点划线偏移numberfalse0
strokeLineCap开放自路径两端的形状CanvasLineCapfalse-
strokeLineJoin转角处形状CanvasLineJoinfalse-
strokeMiterLimit转角最大距离numberfalse4

示例

Source Code
js
const rubbing = new Rubbing({
  selector: '#canvas',
  background: '#fff',
  width: 300,
  height: 300,
})
await rubbing.init()
rubbing.loadFrom({
  objects: [
    {
      type: 'polyline',
      fill: '#7c3aed',
      points: [
        { x: 0, y: 100 },
        { x: 200, y: 50 },
        { x: 300, y: 200 },
        { x: 100, y: 230 },
      ],
    },
  ],
})