From b811c800095fbb99507954f32013acdbb5f662cb Mon Sep 17 00:00:00 2001 From: awesomeuser Date: Fri, 4 Aug 2023 19:00:11 +0000 Subject: [PATCH] implement currentTool --- index.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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() {