[ACCEPTED]-HTML5 Canvas changes colors of all lines-canvas
Accepted answer
Just add a closePath()
call (as well as beginPath
) where you 8 draw your line, like this:
ctx.beginPath();
ctx.moveTo(start,start2);
ctx.lineTo(finish,finish2);
ctx.stroke();
ctx.closePath();
Otherwise instead 7 of drawing only the newest line, you're 6 gonna draw all the previous lines again 5 because the open path is still the same, thus 4 causing the effect of the lines changing 3 color and width when what you're looking 2 at is actually new lines being drawn over 1 them.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.