Merge pull request #89 from grosbouddha/highlight-tool-pixels
Highlight tool target pixel
This commit is contained in:
commit
8fc65e7a85
2 changed files with 24 additions and 1 deletions
|
@ -9,6 +9,12 @@ var Constants = {
|
||||||
*/
|
*/
|
||||||
SELECTION_TRANSPARENT_COLOR: 'rgba(255, 255, 255, 0.6)',
|
SELECTION_TRANSPARENT_COLOR: 'rgba(255, 255, 255, 0.6)',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When a tool is hovering the drawing canvas, we highlight the eventual
|
||||||
|
* pixel target with this color:
|
||||||
|
*/
|
||||||
|
TOOL_TARGET_HIGHLIGHT_COLOR: 'rgba(255, 255, 255, 0.2)',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default entry point for piskel web service:
|
* Default entry point for piskel web service:
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,7 +12,24 @@
|
||||||
|
|
||||||
ns.BaseTool.prototype.moveToolAt = function(col, row, color, frame, overlay) {};
|
ns.BaseTool.prototype.moveToolAt = function(col, row, color, frame, overlay) {};
|
||||||
|
|
||||||
ns.BaseTool.prototype.moveUnactiveToolAt = function(col, row, color, frame, overlay) {};
|
ns.BaseTool.prototype.moveUnactiveToolAt = function(col, row, color, frame, overlay) {
|
||||||
|
if (overlay.containsPixel(col, row)) {
|
||||||
|
if (!isNaN(this.highlightedPixelCol) &&
|
||||||
|
!isNaN(this.highlightedPixelRow) &&
|
||||||
|
(this.highlightedPixelRow != row ||
|
||||||
|
this.highlightedPixelCol != col)) {
|
||||||
|
|
||||||
|
// Clean the previously highlighted pixel:
|
||||||
|
overlay.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the current pixel targeted by the tool:
|
||||||
|
overlay.setPixel(col, row, Constants.TOOL_TARGET_HIGHLIGHT_COLOR);
|
||||||
|
|
||||||
|
this.highlightedPixelCol = col;
|
||||||
|
this.highlightedPixelRow = row;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ns.BaseTool.prototype.releaseToolAt = function(col, row, color, frame, overlay) {};
|
ns.BaseTool.prototype.releaseToolAt = function(col, row, color, frame, overlay) {};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue