画"X"字用画布HTML

Dar*_*ght 8 html html5

当我点击时,我用画布在鼠标位置画"X"字,但是当我画出新的"X"字时,旧的"X"是"BOLD".

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

你对我有什么建议吗?谢谢!!!

Ste*_*ler 11

在开始绘制线条之前,请致电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();
}
Run Code Online (Sandbox Code Playgroud)

关于jsFiddle的更新代码:http://jsfiddle.net/h4JvJ/23/