}
down(x, y) {
+ this.state.pixelEditor.pushState();
let targetColor = this.state.pixelEditor.getPixel(x, y);
if (targetColor == this.state.palette.color) {
// Filling a color on top of itself is a no-op
}
}
up(x, y) {
- this.state.pixelEditor.popState();
- this.state.pixelEditor.drawLine(this.begin.x, this.begin.y, x, y);
this.begin = null;
}
}
}
down(x, y) {
+ this.state.pixelEditor.pushState();
this.previous = {x, y};
this.state.pixelEditor.drawPixel(x, y);
}
}
}
up(x, y) {
- const x0 = x > this.begin.x ? this.begin.x : x;
- const y0 = y > this.begin.y ? this.begin.y : y;
- const w = Math.abs(x - this.begin.x) + 1;
- const h = Math.abs(y - this.begin.y) + 1;
-
- this.state.pixelEditor.popState();
- this.state.pixelEditor.setHLine(x0, this.begin.y, w);
- this.state.pixelEditor.setHLine(x0, y, w);
- this.state.pixelEditor.setVLine(this.begin.x, y0 + 1, h - 2);
- this.state.pixelEditor.setVLine(x, y0 + 1, h - 2);
- this.state.pixelEditor.redraw();
- this.state.pixelEditor.refresh();
this.begin = null;
}
}
down(x, y) {
this.penIsDown = true;
+ this.state.pixelEditor.pushState();
this.state.pixelEditor.drawPixel(x, y, this.randomColor());
}
move(x, y) {
<div class="global-actions">
<button onclick="savePNG()">Save</button>
<button onclick="loadFile()">Load</button>
+ <button onclick="undo()">Undo</button>
<button onclick="toggleGrid()" id="button-grid" class="active">Grid</button>
<div id="size-flyout" class="size-flyout">
<button onclick="selectSize(8)">8x8</button>
loader.click();
}
+window.undo = function() {
+ appState.pixelEditor.popState();
+ appState.pixelEditor.redraw();
+ appState.pixelEditor.refresh();
+}
+
window.nextPalette = function() {
appState.palette.nextPalette();
appState.pixelEditor.paletteChanged();