mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Added history states for canvas resizing
Must fix bug that happens when creating a new layer after resizing the canvas
This commit is contained in:
@@ -3,6 +3,35 @@ var redoStates = [];
|
||||
|
||||
const undoLogStyle = 'background: #87ff1c; color: black; padding: 5px;';
|
||||
|
||||
function HistoryStateResizeCanvas(newSize, oldSize, imageDatas) {
|
||||
this.oldSize = oldSize;
|
||||
this.newSize = newSize;
|
||||
this.imageDatas = imageDatas;
|
||||
|
||||
this.undo = function() {
|
||||
let dataIndex = 0;
|
||||
console.log("breakpoint");
|
||||
// Resizing the canvas
|
||||
resizeCanvas(null, oldSize);
|
||||
// Putting the image datas
|
||||
for (let i=0; i<imageDatas.length; i++) {
|
||||
if (layers[i].menuEntry != null) {
|
||||
layers[i].context.putImageData(imageDatas[dataIndex], 0, 0);
|
||||
dataIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
redoStates.push(this);
|
||||
};
|
||||
|
||||
this.redo = function() {
|
||||
resizeCanvas(null, newSize);
|
||||
undoStates.push(this);
|
||||
};
|
||||
|
||||
saveHistoryState(this);
|
||||
}
|
||||
|
||||
function HistoryStateFlattenVisible(flattened) {
|
||||
this.nFlattened = flattened;
|
||||
|
||||
|
Reference in New Issue
Block a user