From 9c68e541d9ba95ad4bb77a217588439fe37abe17 Mon Sep 17 00:00:00 2001 From: unsettledgames <47360416+unsettledgames@users.noreply.github.com> Date: Tue, 22 Sep 2020 14:17:31 +0200 Subject: [PATCH] Added history management for sprite scaling --- js/_history.js | 27 ++++++++++++++++++++----- js/_resizeSprite.js | 48 +++++++++++++++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/js/_history.js b/js/_history.js index 132e7f3..4cea20e 100644 --- a/js/_history.js +++ b/js/_history.js @@ -3,19 +3,36 @@ var redoStates = []; const undoLogStyle = 'background: #87ff1c; color: black; padding: 5px;'; -function HistoryStateResizeSprite(newPercs, oldPercs, algo) { - this.newPercs = newPercs; - this.oldPercs = oldPercs; +function HistoryStateResizeSprite(xRatio, yRatio, algo, oldData) { + this.xRatio = xRatio; + this.yRatio = yRatio; this.algo = algo; + this.oldData = oldData; this.undo = function() { + let layerIndex = 0; + currentAlgo = algo; + resizeSprite(null, [1 / this.xRatio, 1 / this.yRatio]); + + // Also putting the old data + for (let i=0; i