mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Fix ColorSwap and Bucket tool
This commit is contained in:
parent
ac3e43bf61
commit
fa716d7a6c
@ -28,7 +28,6 @@
|
||||
|
||||
var allLayers = pskl.utils.UserAgent.isMac ? event.metaKey : event.ctrlKey;
|
||||
var allFrames = event.shiftKey;
|
||||
|
||||
this.swapColors_(oldColor, newColor, allLayers, allFrames);
|
||||
|
||||
this.raiseSaveStateEvent({
|
||||
@ -56,8 +55,10 @@
|
||||
};
|
||||
|
||||
ns.ColorSwap.prototype.applyToolOnFrame_ = function (frame, oldColor, newColor) {
|
||||
oldColor = pskl.utils.colorToInt(oldColor);
|
||||
newColor = pskl.utils.colorToInt(newColor);
|
||||
frame.forEachPixel(function (color, col, row) {
|
||||
if (color && color == oldColor) {
|
||||
if (color !== null && color == oldColor) {
|
||||
frame.setPixel(col, row, newColor);
|
||||
}
|
||||
});
|
||||
|
@ -146,6 +146,10 @@
|
||||
* 13. Continue looping until Q is exhausted.
|
||||
* 14. Return.
|
||||
*/
|
||||
if (typeof replacementColor == 'string') {
|
||||
replacementColor = pskl.utils.colorToInt(replacementColor);
|
||||
}
|
||||
|
||||
var targetColor;
|
||||
try {
|
||||
targetColor = frame.getPixel(col, row);
|
||||
@ -153,7 +157,7 @@
|
||||
// Frame out of bound exception.
|
||||
}
|
||||
|
||||
if (targetColor == replacementColor) {
|
||||
if (targetColor === null || targetColor == replacementColor) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -162,7 +166,7 @@
|
||||
row : row
|
||||
};
|
||||
var paintedPixels = pskl.PixelUtils.visitConnectedPixels(startPixel, frame, function (pixel) {
|
||||
if (frame.containsPixel(pixel.col, pixel.row) && frame.getPixel(pixel.col, pixel.row) == targetColor) {
|
||||
if (frame.getPixel(pixel.col, pixel.row) == targetColor) {
|
||||
frame.setPixel(pixel.col, pixel.row, replacementColor);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user