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

@@ -1,9 +1,12 @@
function newPixel (width, height, palette) {
var main = new Canvas(width, height, canvas);
main.initialize();
currentLayer = new Canvas(width, height, canvas);
currentLayer.initialize();
canvasSize = main.canvasSize;
checkerBoard = new Canvas(width, height, checkerBoard);
checkerBoard.initialize();
canvasSize = currentLayer.canvasSize;
//remove current palette
colors = document.getElementsByClassName('color-button');
while (colors.length > 0) {
@@ -40,14 +43,14 @@ function newPixel (width, height, palette) {
//fill background of canvas with bg color
fillCheckerboard();
/*
context.fillStyle = '#'+defaultBackgroundColor;
context.fillRect(0, 0, canvasSize[0], canvasSize[1]);
currentLayer.context.fillStyle = '#'+defaultBackgroundColor;
currentLayer.context.fillRect(0, 0, canvasSize[0], canvasSize[1]);
console.log('#'+defaultBackgroundColor)
*/
//set current drawing color as foreground color
context.fillStyle = '#'+defaultForegroundColor;
currentLayer.context.fillStyle = '#'+defaultForegroundColor;
selectedPalette = 'none';
}