implement currentTool

This commit is contained in:
awesomeuser 2023-08-04 19:00:11 +00:00
parent 773dab7b75
commit b811c80009

View file

@ -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() {