mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Applying review comments for dithering tool
This commit is contained in:
parent
63449b2694
commit
d0acb625cf
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
ns.SelectedColorsService.prototype.getColors = function () {
|
ns.SelectedColorsService.prototype.getColors = function () {
|
||||||
if (this.primaryColor_ === null || this.secondaryColor_ === null) {
|
if (this.primaryColor_ === null || this.secondaryColor_ === null) {
|
||||||
throw 'SelectedColorsService not properly intialized.';
|
throw 'SelectedColorsService not properly initialized.';
|
||||||
}
|
}
|
||||||
return [this.primaryColor_, this.secondaryColor_];
|
return [this.primaryColor_, this.secondaryColor_];
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,14 +17,15 @@
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
ns.DitheringTool.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
ns.DitheringTool.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
|
||||||
var ditheringColor;
|
// Use primary selected color on cell with either an odd col or row.
|
||||||
var currentColors = pskl.app.selectedColorsService.getColors();
|
// Use secondary color otherwise.
|
||||||
// XOR on either row or col parity.
|
// When using the right mouse button, invert the above behavior to allow quick corrections.
|
||||||
if ((col % 2 === 0 && row % 2 !== 0) || (col % 2 !== 0 && row % 2 === 0)) {
|
var usePrimaryColor = (col + row) % 2;
|
||||||
ditheringColor = currentColors[0];
|
var invertColors = event.button === Constants.RIGHT_BUTTON;
|
||||||
} else {
|
usePrimaryColor = invertColors ? !usePrimaryColor : usePrimaryColor;
|
||||||
ditheringColor = currentColors[1];
|
|
||||||
}
|
var selectedColors = pskl.app.selectedColorsService.getColors();
|
||||||
|
var ditheringColor = usePrimaryColor ? selectedColors[0] : selectedColors[1];
|
||||||
this.superclass.applyToolAt.call(this, col, row, ditheringColor, frame, overlay, event);
|
this.superclass.applyToolAt.call(this, col, row, ditheringColor, frame, overlay, event);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user