mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Enhancement : Move tool: shift out of bound pixels
When holding shift and using the move tool,pixels normally exiting the frame will now be redrawn on the other end of the frame. Makes it easy to perform sliding animations.
This commit is contained in:
parent
7cbf2b2794
commit
2aa8bf578b
@ -30,15 +30,23 @@
|
|||||||
|
|
||||||
ns.Move.prototype.moveToolAt = function(col, row, color, frame, overlay, event) {
|
ns.Move.prototype.moveToolAt = function(col, row, color, frame, overlay, event) {
|
||||||
var colDiff = col - this.startCol, rowDiff = row - this.startRow;
|
var colDiff = col - this.startCol, rowDiff = row - this.startRow;
|
||||||
this.shiftFrame(colDiff, rowDiff, frame, this.frameClone);
|
this.shiftFrame(colDiff, rowDiff, frame, this.frameClone, event);
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.Move.prototype.shiftFrame = function (colDiff, rowDiff, frame, reference) {
|
ns.Move.prototype.shiftFrame = function (colDiff, rowDiff, frame, reference, event) {
|
||||||
var color;
|
var color;
|
||||||
for (var col = 0 ; col < frame.getWidth() ; col++) {
|
var w = frame.getWidth();
|
||||||
for (var row = 0 ; row < frame.getHeight() ; row++) {
|
var h = frame.getHeight();
|
||||||
if (reference.containsPixel(col - colDiff, row - rowDiff)) {
|
for (var col = 0 ; col < w ; col++) {
|
||||||
color = reference.getPixel(col - colDiff, row - rowDiff);
|
for (var row = 0 ; row < h ; row++) {
|
||||||
|
var x = col - colDiff;
|
||||||
|
var y = row - rowDiff;
|
||||||
|
if (event.shiftKey) {
|
||||||
|
x = (x + w) % w;
|
||||||
|
y = (y + h) % h;
|
||||||
|
}
|
||||||
|
if (reference.containsPixel(x, y)) {
|
||||||
|
color = reference.getPixel(x, y);
|
||||||
} else {
|
} else {
|
||||||
color = Constants.TRANSPARENT_COLOR;
|
color = Constants.TRANSPARENT_COLOR;
|
||||||
}
|
}
|
||||||
@ -51,15 +59,19 @@
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
ns.Move.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
|
ns.Move.prototype.releaseToolAt = function(col, row, color, frame, overlay, event) {
|
||||||
this.moveToolAt(col, row, color, frame, overlay);
|
this.moveToolAt(col, row, color, frame, overlay, event);
|
||||||
|
|
||||||
this.raiseSaveStateEvent({
|
this.raiseSaveStateEvent({
|
||||||
colDiff : col - this.startCol,
|
colDiff : col - this.startCol,
|
||||||
rowDiff : row - this.startRow
|
rowDiff : row - this.startRow,
|
||||||
|
shiftKey : event.shiftKey
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.Move.prototype.replay = function(frame, replayData) {
|
ns.Move.prototype.replay = function(frame, replayData) {
|
||||||
this.shiftFrame(replayData.colDiff, replayData.rowDiff, frame, frame.clone());
|
var event = {
|
||||||
|
shiftKey : replayData.shiftKey
|
||||||
|
};
|
||||||
|
this.shiftFrame(replayData.colDiff, replayData.rowDiff, frame, frame.clone(), event);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user