mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
parent
94add8f3f7
commit
3b8dbb5151
@ -67,7 +67,7 @@ const Startup = (() => {
|
||||
if (fileContent != null) {
|
||||
loadFromLPE(fileContent);
|
||||
// Deleting the default layer
|
||||
//deleteLayer(false);
|
||||
deleteLayer(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,54 +80,69 @@ const Startup = (() => {
|
||||
// Creating the first layer
|
||||
currentLayer = new Layer(width, height, canvas, layerListEntry);
|
||||
currentLayer.canvas.style.zIndex = 2;
|
||||
|
||||
// Adding the checkerboard behind it
|
||||
checkerBoard = new Layer(width, height, checkerBoardCanvas);
|
||||
VFXLayer = new Layer(width, height, VFXCanvas);
|
||||
TMPLayer = new Layer(width, height, TMPCanvas);
|
||||
pixelGrid = new Layer(width, height, pixelGridCanvas);
|
||||
|
||||
// Setting the general canvasSize
|
||||
canvasSize = currentLayer.canvasSize;
|
||||
|
||||
// Cloning the entry so that when I change something on the first layer, those changes aren't propagated to the other ones
|
||||
layerListEntry = layerListEntry.cloneNode(true);
|
||||
|
||||
// Adding the first layer and the checkerboard to the list of layers
|
||||
layers.push(checkerBoard);
|
||||
layers.push(currentLayer);
|
||||
layers.push(VFXLayer);
|
||||
layers.push(TMPLayer);
|
||||
layers.push(pixelGrid);
|
||||
}
|
||||
else {
|
||||
// Deleting all the extra layers and canvases, leaving only one, (nAppLayers=3)
|
||||
const nLayers = layers.length;
|
||||
for (let i=2; i < nLayers - nAppLayers; i++) {
|
||||
const currentEntry = layers[i].menuEntry;
|
||||
// Deleting all the extra layers and canvases, leaving only one
|
||||
let nLayers = layers.length;
|
||||
for (let i=2; i < layers.length - nAppLayers; i++) {
|
||||
let currentEntry = layers[i].menuEntry;
|
||||
let associatedLayer;
|
||||
|
||||
if (currentEntry != null) {
|
||||
// Getting the associated layer
|
||||
associatedLayer = getLayerByID(currentEntry.id);
|
||||
|
||||
// Deleting its canvas
|
||||
associatedLayer.canvas.remove();
|
||||
|
||||
// Adding the id to the unused ones
|
||||
unusedIDs.push(currentEntry.id);
|
||||
// Removing the entry from the menu
|
||||
currentEntry.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Removing the old layers from the list
|
||||
for (let i=2; i<nLayers - nAppLayers; i++) {
|
||||
layers.splice(2, 1);
|
||||
}
|
||||
|
||||
// Setting up the current layer
|
||||
layers[1] = new Layer(width, height, canvas, layerListEntry);
|
||||
layers[1] = new Layer(width, height, layers[1].canvas, layers[1].menuEntry);
|
||||
currentLayer = layers[1];
|
||||
currentLayer.canvas.style.zIndex = 9;
|
||||
currentLayer.canvas.style.zIndex = 2;
|
||||
|
||||
// Updating canvas size to the new size
|
||||
for (let i=0; i<nLayers; i++) {
|
||||
layers[i].canvasSize = [width, height];
|
||||
}
|
||||
}
|
||||
|
||||
// Adding the checkerboard behind it
|
||||
checkerBoard = new Layer(width, height, checkerBoardCanvas);
|
||||
|
||||
// Creating the vfx layer on top of everything
|
||||
VFXLayer = new Layer(width, height, VFXCanvas);
|
||||
|
||||
// Tmp layer to draw previews on
|
||||
TMPLayer = new Layer(width, height, TMPCanvas);
|
||||
|
||||
// Pixel grid
|
||||
pixelGrid = new Layer(width, height, pixelGridCanvas);
|
||||
// Setting the general canvasSize
|
||||
canvasSize = currentLayer.canvasSize;
|
||||
|
||||
if (firstPixel) {
|
||||
// Cloning the entry so that when I change something on the first layer, those changes aren't
|
||||
// propagated to the other ones
|
||||
layerListEntry = layerListEntry.cloneNode(true);
|
||||
// Adding the first layer and the checkerboard to the list of layers
|
||||
layers.push(checkerBoard);
|
||||
layers.push(currentLayer);
|
||||
layers.push(VFXLayer);
|
||||
layers.push(TMPLayer);
|
||||
layers.push(pixelGrid);
|
||||
}
|
||||
}
|
||||
|
||||
function initPalette() {
|
||||
|
Loading…
Reference in New Issue
Block a user