Implemented eraser tool. Must move and resize layers at the same time.

Signed-off-by: npalomba <nicola.palomba@studenti.galileilivorno.gov.it>
This commit is contained in:
npalomba
2019-03-31 16:32:49 +02:00
parent 42a8ce3c4a
commit a9d380ec1d
17 changed files with 83 additions and 71 deletions

View File

@@ -10,9 +10,9 @@ function line(x0,y0,x1,y1) {
while (true) {
//set pixel
if (currentTool == 'pencil') {
context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize);
currentLayer.context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize);
} else if (currentTool == 'eraser') {
context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize);
currentLayer.context.clearRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), eraserSize, eraserSize);
}
//if we've reached the end goal, exit the loop