optmization
This commit is contained in:
parent
c72e378c29
commit
ecbdbe0446
|
@ -41,16 +41,23 @@ export function drawPolyline (ctx, points, lineWidth = 2, lineColor = '#000', cl
|
||||||
}
|
}
|
||||||
|
|
||||||
export function drawSmoothlinePath (ctx, points, close = false, newPath = false, moveTo = false) {
|
export function drawSmoothlinePath (ctx, points, close = false, newPath = false, moveTo = false) {
|
||||||
if (!ctx || points.length < 3) return
|
|
||||||
|
|
||||||
const canDrawPoints = filterNull(points)
|
const canDrawPoints = filterNull(points)
|
||||||
|
|
||||||
|
if (!ctx || canDrawPoints.length < 2) return
|
||||||
|
|
||||||
close && canDrawPoints.push(canDrawPoints[0])
|
close && canDrawPoints.push(canDrawPoints[0])
|
||||||
|
|
||||||
const lastPointIndex = canDrawPoints.length - 1
|
|
||||||
|
|
||||||
newPath && ctx.beginPath()
|
newPath && ctx.beginPath()
|
||||||
|
|
||||||
|
if (canDrawPoints.length === 2) {
|
||||||
|
ctx.moveTo(...canDrawPoints[0])
|
||||||
|
ctx.lineTo(...canDrawPoints[1])
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastPointIndex = canDrawPoints.length - 1
|
||||||
|
|
||||||
moveTo && ctx.moveTo(...canDrawPoints[0])
|
moveTo && ctx.moveTo(...canDrawPoints[0])
|
||||||
|
|
||||||
canDrawPoints.forEach((t, i) =>
|
canDrawPoints.forEach((t, i) =>
|
||||||
|
|
Loading…
Reference in New Issue