Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw "X" word use canvas HTML

Tags:

html

I used canvas to draw "X" word at a mouse position when I clicked, but when I draw new "X" word, the old "X" was "BOLD".

http://jsfiddle.net/darklight27/h4JvJ/

Do you have any suggestion for me? Thank you!!!

like image 275
Dark Light Avatar asked Oct 11 '12 08:10

Dark Light


1 Answers

Before you begin to draw your lines, call beginPath():

function drawX(x, y) {
    ctx.beginPath();

    ctx.moveTo(x - 20, y - 20);
    ctx.lineTo(x + 20, y + 20);

    ctx.moveTo(x + 20, y - 20);
    ctx.lineTo(x - 20, y + 20);
    ctx.stroke();
}

Updated code on jsFiddle: http://jsfiddle.net/h4JvJ/23/

like image 189
Stefan Fandler Avatar answered Sep 23 '22 13:09

Stefan Fandler