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 () { 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_];
}; };

View File

@ -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);
}; };
})(); })();