diff --git a/index.php b/index.php index 35be080..b7859de 100644 --- a/index.php +++ b/index.php @@ -155,6 +155,8 @@ eraser.data[i+3] = 0; } + var currentTool = pen; + var drawing = false; canvas.onmousedown = function() { drawing = true; } document.onmouseup = function() { @@ -183,15 +185,15 @@ var posX = e.offsetX * canvas.width / canvas.offsetWidth - 1; var posY = e.offsetY * canvas.height / canvas.offsetHeight - 1; - ctx.putImageData(pen, posX, posY); + ctx.putImageData(currentTool, posX, posY); } function setPen() { - alert("pen"); + currentTool = pen; } function setEraser() { - alert("eras"); + currentTool = eraser; } function clearCanvas() {