implement currentTool
This commit is contained in:
parent
773dab7b75
commit
b811c80009
1 changed files with 5 additions and 3 deletions
|
@ -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() {
|
||||
|
|
Reference in a new issue