Started refactoring the code

- Can now zoom without selecting the zom tool
- Moved updateCursor to the tool class, deleted _updateCursor.js
- Removed as many references to canvas as possible, removed every global reference to context
- Added methods in Tool class to move the brush preview
This commit is contained in:
unsettledgames
2020-07-21 16:01:00 +02:00
parent 03ba3fe245
commit 466eb0580c
9 changed files with 77 additions and 103 deletions

View File

@ -8,9 +8,8 @@ function newPixel (width, height, editorMode, fileContent = null) {
layerList = document.getElementById("layers-menu");
layerListEntry = layerList.firstElementChild;
// Setting up the current layer
currentLayer = new Layer(width, height, canvas, layerListEntry);
canvas.style.zIndex = 2;
currentLayer.canvas.style.zIndex = 2;
}
else {
let nLayers = layers.length;
@ -41,9 +40,7 @@ function newPixel (width, height, editorMode, fileContent = null) {
layers[1] = new Layer(width, height, layers[1].canvas, layers[1].menuEntry);
currentLayer = layers[1];
canvas = currentLayer.canvas;
context = currentLayer.context;
canvas.style.zIndex = 2;
currentLayer.canvas.style.zIndex = 2;
}
// Adding the checkerboard behind it