Skip to content

直线

PropertyDescriptionTypeRequiredDefault
x1x 轴起点numbertrue0
y1y 轴起点numbertrue0
x2x 轴终点numbertrue0
y2y 轴终点numbertrue0
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: 'line',
      x1: 0,
      y1: 100,
      x2: 300,
      y2: 200,
    },
    {
      type: 'line',
      x1: 200,
      y1: 50,
      x2: 300,
      y2: 300,
    },
  ],
})