fix polyline bug
This commit is contained in:
parent
653ca26de6
commit
002e0de26d
|
@ -15,17 +15,15 @@ export function drawLine (ctx, lineBegin, lineEnd, lineWidth = 2, lineColor = '#
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function drawPolyline (ctx, points, lineWidth = 2, lineColor = '#000', close = false, dashArray = [10, 10]) {
|
export function drawPolyline (ctx, points, lineWidth = 2, lineColor = '#000', close = false, dashArray = [10, 0]) {
|
||||||
if (!ctx || !points.length) return
|
if (!ctx || !points.length) return
|
||||||
|
|
||||||
ctx.beginPath()
|
ctx.beginPath()
|
||||||
|
|
||||||
points.forEach((point, i) => i === 0 ? ctx.moveTo(...point) : ctx.LineTo(...point))
|
points.forEach((point, i) => i === 0 ? ctx.moveTo(...point) : ctx.lineTo(...point))
|
||||||
|
|
||||||
close && ctx.lineTo(...points[0])
|
close && ctx.lineTo(...points[0])
|
||||||
|
|
||||||
ctx.closePath()
|
|
||||||
|
|
||||||
ctx.lineWidth = lineWidth
|
ctx.lineWidth = lineWidth
|
||||||
ctx.strokeStyle = lineColor
|
ctx.strokeStyle = lineColor
|
||||||
ctx.setLineDash(dashArray)
|
ctx.setLineDash(dashArray)
|
||||||
|
|
Loading…
Reference in New Issue