Only send tool events when the pixel location changes
Also fix some redraw/refresh ordering issues that were masked by the
more frequent updates.
right--;
this.state.pixelEditor.setHLine(left, y, right - left + 1);
- //this.state.pixelEditor.redraw(left, y, right - left + 1, 1);
for (let i = left; i <= right; i++) {
if (this.state.pixelEditor.getPixel(i, y - 1) == targetColor) {
this.fill(i, y - 1, targetColor);
if (this.begin) {
this.state.pixelEditor.resetState();
this.state.pixelEditor.setLine(this.begin.x, this.begin.y, x, y);
- this.state.pixelEditor.refresh();
this.state.pixelEditor.redraw();
+ this.state.pixelEditor.refresh();
}
}
up(x, y) {
this.node.addEventListener('mousemove', event => this.penMove(event));
this.node.addEventListener('mouseup', event => this.penUp(event));
+ this.lastMoveLocation = {x: null, y: null};
this.saveStack = [];
this.gridShowing = true;
this.setSize(16, 16);
}
penMove(event) {
let { x, y } = this.getPixelCoords(event);
- this.state.toolbox.getTool().move(x, y);
+ if (x != this.lastMoveLocation.x || y != this.lastMoveLocation.y) {
+ this.state.toolbox.getTool().move(x, y);
+ this.lastMoveLocation.x = x;
+ this.lastMoveLocation.y = y;
+ }
}
penUp(event) {
let { x, y } = this.getPixelCoords(event);
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.refresh();
this.state.pixelEditor.redraw();
+ this.state.pixelEditor.refresh();
}
}
up(x, y) {
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.refresh();
this.state.pixelEditor.redraw();
+ this.state.pixelEditor.refresh();
this.begin = null;
}
}