Applying review comments for dithering tool

This commit is contained in:
grosbouddha 2015-09-14 23:40:16 +02:00
parent 63449b2694
commit d0acb625cf
2 changed files with 10 additions and 9 deletions

View File

@ -13,7 +13,7 @@
ns.SelectedColorsService.prototype.getColors = function () {
if (this.primaryColor_ === null || this.secondaryColor_ === null) {
throw 'SelectedColorsService not properly intialized.';
throw 'SelectedColorsService not properly initialized.';
}
return [this.primaryColor_, this.secondaryColor_];
};

View File

@ -17,14 +17,15 @@
* @override
*/
ns.DitheringTool.prototype.applyToolAt = function(col, row, color, frame, overlay, event) {
var ditheringColor;
var currentColors = pskl.app.selectedColorsService.getColors();
// XOR on either row or col parity.
if ((col % 2 === 0 && row % 2 !== 0) || (col % 2 !== 0 && row % 2 === 0)) {
ditheringColor = currentColors[0];
} else {
ditheringColor = currentColors[1];
}
// Use primary selected color on cell with either an odd col or row.
// Use secondary color otherwise.
// When using the right mouse button, invert the above behavior to allow quick corrections.
var usePrimaryColor = (col + row) % 2;
var invertColors = event.button === Constants.RIGHT_BUTTON;
usePrimaryColor = invertColors ? !usePrimaryColor : usePrimaryColor;
var selectedColors = pskl.app.selectedColorsService.getColors();
var ditheringColor = usePrimaryColor ? selectedColors[0] : selectedColors[1];
this.superclass.applyToolAt.call(this, col, row, ditheringColor, frame, overlay, event);
};
})();