mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Fixed sprite scaling history bug
This commit is contained in:
@@ -11,13 +11,11 @@ let infoBox = document.getElementById('editor-mode-info');
|
|||||||
let currentSplashButton = document.getElementById("sp-mode-palette").children[0].children[1];
|
let currentSplashButton = document.getElementById("sp-mode-palette").children[0].children[1];
|
||||||
|
|
||||||
function splashMode(mouseEvent, mode) {
|
function splashMode(mouseEvent, mode) {
|
||||||
console.log("UE");
|
|
||||||
if (currentSplashButton == undefined) {
|
if (currentSplashButton == undefined) {
|
||||||
currentSplashButton = mouseEvent.target.parentElement;
|
currentSplashButton = mouseEvent.target.parentElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode !== pixelEditorMode) {
|
if (mode !== pixelEditorMode) {
|
||||||
console.log("Mode target: " + mouseEvent.target);
|
|
||||||
// Remove selected class to old button
|
// Remove selected class to old button
|
||||||
currentSplashButton.classList.remove("sp-interface-selected");
|
currentSplashButton.classList.remove("sp-interface-selected");
|
||||||
// Add selected class to new button
|
// Add selected class to new button
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ function HistoryStateResizeSprite(xRatio, yRatio, algo, oldData) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.redo = function() {
|
this.redo = function() {
|
||||||
|
console.log("REDOOOO");
|
||||||
|
console.log("Ratio: " + this.xRatio + "," + this.yRatio);
|
||||||
currentAlgo = algo;
|
currentAlgo = algo;
|
||||||
resizeSprite(null, [this.xRatio, this.yRatio]);
|
resizeSprite(null, [this.xRatio, this.yRatio]);
|
||||||
undoStates.push(this);
|
undoStates.push(this);
|
||||||
@@ -58,7 +60,6 @@ function HistoryStateResizeCanvas(newSize, oldSize, imageDatas, trim) {
|
|||||||
|
|
||||||
this.undo = function() {
|
this.undo = function() {
|
||||||
let dataIndex = 0;
|
let dataIndex = 0;
|
||||||
console.log("breakpoint");
|
|
||||||
// Resizing the canvas
|
// Resizing the canvas
|
||||||
resizeCanvas(null, oldSize, null, false);
|
resizeCanvas(null, oldSize, null, false);
|
||||||
// Putting the image datas
|
// Putting the image datas
|
||||||
@@ -73,7 +74,6 @@ function HistoryStateResizeCanvas(newSize, oldSize, imageDatas, trim) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.redo = function() {
|
this.redo = function() {
|
||||||
console.log("trim: " + this.trim);
|
|
||||||
if (!this.trim) {
|
if (!this.trim) {
|
||||||
resizeCanvas(null, newSize, null, false);
|
resizeCanvas(null, newSize, null, false);
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,6 @@ function HistoryStateFlattenTwoVisibles(belowImageData, afterAbove, layerIndex,
|
|||||||
this.belowImageData = belowImageData;
|
this.belowImageData = belowImageData;
|
||||||
|
|
||||||
this.undo = function() {
|
this.undo = function() {
|
||||||
console.log(afterAbove.menuEntry);
|
|
||||||
canvasView.append(aboveLayer.canvas);
|
canvasView.append(aboveLayer.canvas);
|
||||||
layerList.insertBefore(aboveLayer.menuEntry, afterAbove);
|
layerList.insertBefore(aboveLayer.menuEntry, afterAbove);
|
||||||
|
|
||||||
@@ -314,7 +313,6 @@ function HistoryStateAddLayer(layerData, index) {
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
|
|
||||||
this.undo = function() {
|
this.undo = function() {
|
||||||
console.log("uo");
|
|
||||||
|
|
||||||
redoStates.push(this);
|
redoStates.push(this);
|
||||||
if (layers.length - nAppLayers > this.index + 1) {
|
if (layers.length - nAppLayers > this.index + 1) {
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ function resizeCanvas(event, size, customData, saveHistory = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Saving the history only if I'm not already undoing or redoing
|
// Saving the history only if I'm not already undoing or redoing
|
||||||
if (saveHistory) {
|
if (saveHistory && event != null) {
|
||||||
// Saving history
|
// Saving history
|
||||||
new HistoryStateResizeCanvas(
|
new HistoryStateResizeCanvas(
|
||||||
{x: parseInt(layers[0].canvasSize[0]) + rcBorders.left + rcBorders.right,
|
{x: parseInt(layers[0].canvasSize[0]) + rcBorders.left + rcBorders.right,
|
||||||
@@ -194,9 +194,6 @@ function resizeCanvas(event, size, customData, saveHistory = true) {
|
|||||||
layers[i].context.putImageData(imageDatas[copiedDataIndex], leftOffset, topOffset);
|
layers[i].context.putImageData(imageDatas[copiedDataIndex], leftOffset, topOffset);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("sgancio " + layers[i].canvasSize + ", [" +
|
|
||||||
customData[copiedDataIndex].width + "," + customData[copiedDataIndex].height
|
|
||||||
+ "]");
|
|
||||||
layers[i].context.putImageData(customData[copiedDataIndex], 0, 0);
|
layers[i].context.putImageData(customData[copiedDataIndex], 0, 0);
|
||||||
}
|
}
|
||||||
layers[i].updateLayerPreview();
|
layers[i].updateLayerPreview();
|
||||||
|
|||||||
@@ -116,8 +116,9 @@ function resizeSprite(event, ratio) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ratio is null when the user is undoing
|
// event is null when the user is undoing
|
||||||
if (ratio == null) {
|
if (event != null) {
|
||||||
|
console.log("AO SALVO LA CRONOLOGIA");
|
||||||
// Copying the image data
|
// Copying the image data
|
||||||
imageDatasCopy = rsImageDatas.slice();
|
imageDatasCopy = rsImageDatas.slice();
|
||||||
// Saving the history
|
// Saving the history
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ let coverImage = document.getElementById('editor-logo');
|
|||||||
let authorLink = coverImage.getElementsByTagName('a')[0];
|
let authorLink = coverImage.getElementsByTagName('a')[0];
|
||||||
let chosenImage = images[Math.round(Math.random() * (images.length - 1))];
|
let chosenImage = images[Math.round(Math.random() * (images.length - 1))];
|
||||||
|
|
||||||
console.log ("Path: " + '/pixel-editor/' + chosenImage.path + '.png');
|
|
||||||
|
|
||||||
coverImage.style.backgroundImage = 'url("/pixel-editor/' + chosenImage.path + '.png")';
|
coverImage.style.backgroundImage = 'url("/pixel-editor/' + chosenImage.path + '.png")';
|
||||||
authorLink.setAttribute('href', chosenImage.link);
|
authorLink.setAttribute('href', chosenImage.link);
|
||||||
authorLink.innerHTML = 'Art by ' + chosenImage.author;
|
authorLink.innerHTML = 'Art by ' + chosenImage.author;
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
ajax('https://api.github.com/repos/lospec/pixel-editor/contributors', response => {
|
ajax('https://api.github.com/repos/lospec/pixel-editor/contributors', response => {
|
||||||
console.log(response)
|
|
||||||
|
|
||||||
if (Array.isArray(response)) {
|
if (Array.isArray(response)) {
|
||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ quite a lot of things. Let's go through all them, starting from this page.
|
|||||||
<h2>Splash page</h2>
|
<h2>Splash page</h2>
|
||||||
|
|
||||||
The editor now has a splash page! Besides a fancy cover image with beautiful art, on the bottom
|
The editor now has a splash page! Besides a fancy cover image with beautiful art, on the bottom
|
||||||
right of the page you'll be able to create a new custom pixel. You can also use the quickstart
|
left of the page you'll be able to create a new custom pixel. You can also use the quickstart
|
||||||
menu to quickly select a preset or load an existing file. It was designed by <a href="https://twitter.com/skeddles">Skeddles</a> himself!
|
menu to quickly select a preset or load an existing file. It was designed by <a href="https://twitter.com/skeddles">Skeddles</a> himself!
|
||||||
|
|
||||||
<img src="/pixel-editor/splash.gif"/>
|
<img src="/pixel-editor/splash.gif"/>
|
||||||
@@ -69,8 +69,6 @@ P.S.: we're always looking for contributors! Join the <a href="https://discord.c
|
|||||||
<!--
|
<!--
|
||||||
TODO:
|
TODO:
|
||||||
- Fix sprite scaling input bug (when a parameter is changed, the other one isn't)
|
- Fix sprite scaling input bug (when a parameter is changed, the other one isn't)
|
||||||
- Only happens when a canvas has not a 1:1 ratio
|
|
||||||
- Percentage values are wrong, but size values are correct
|
|
||||||
- Redo problem, the canvas contents aren't copied correctly
|
- Redo problem, the canvas contents aren't copied correctly
|
||||||
- Add hex input to colour picker
|
- Add hex input to colour picker
|
||||||
-->
|
-->
|
||||||
Reference in New Issue
Block a user