I make several strokes in a HTML5 canvas. To make animation with stroke, I clear the previous like this :
// Notice : canvasWidth, canvasHeight, context are in a parent scope
function echoLine( posLeftX, posLeftY, posRightX, posRightY) {
context.beginPath();
context.moveTo(posLeftX, posLeftY);
context.clearRect(0, 0, canvasWidth, canvasHeight);
context.bezierCurveTo(posLeftX, posLeftY, posRightX, posLeftY, posRightX, posRightY);
context.stroke();
context.closePath();
}
My problem is when I want to do several animated lines, context.clearRect() will remove all and I did not find a other way to remove the specific stroke.
Is there a way to clear a specific stroke without workaround, or should I make context by stroke ?