From 31d2f90bfeb5851dbef448ae30eac5782892452b Mon Sep 17 00:00:00 2001 From: Vince Date: Sun, 16 Sep 2012 15:35:30 +0200 Subject: [PATCH 1/3] highlight target tool pixel - intial commit --- js/Constants.js | 2 ++ js/drawingtools/BaseTool.js | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/js/Constants.js b/js/Constants.js index 1f676f0e..c9440a27 100644 --- a/js/Constants.js +++ b/js/Constants.js @@ -8,6 +8,8 @@ var Constants = { * strokes and rectangles: */ SELECTION_TRANSPARENT_COLOR: 'rgba(255, 255, 255, 0.6)', + + TOOL_TARGET_HIGHLIGHT_COLOR: 'rgba(255, 255, 255, 0.2)', /* * Default entry point for piskel web service: diff --git a/js/drawingtools/BaseTool.js b/js/drawingtools/BaseTool.js index d2fd9477..ec12092d 100644 --- a/js/drawingtools/BaseTool.js +++ b/js/drawingtools/BaseTool.js @@ -12,7 +12,24 @@ 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 (this.previouslyHighlightedPixelCol && + this.previouslyHighlightedPixelRow && + (this.previouslyHighlightedPixelRow != row || + this.previouslyHighlightedPixelCol != 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.previouslyHighlightedPixelCol = col; + this.previouslyHighlightedPixelRow = row; + } + }; ns.BaseTool.prototype.releaseToolAt = function(col, row, color, frame, overlay) {}; From 6369fb4656408feb362f045dae81236cafd8ee89 Mon Sep 17 00:00:00 2001 From: Vince Date: Sun, 16 Sep 2012 15:47:39 +0200 Subject: [PATCH 2/3] adding comments --- js/Constants.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/Constants.js b/js/Constants.js index c9440a27..1290e5e9 100644 --- a/js/Constants.js +++ b/js/Constants.js @@ -9,6 +9,10 @@ var Constants = { */ 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)', /* From e519eb1feb40ebd271d7d7966e45f95819e927b8 Mon Sep 17 00:00:00 2001 From: Vince Date: Sun, 16 Sep 2012 16:42:21 +0200 Subject: [PATCH 3/3] =?UTF-8?q?renaming=20+=20bug=20fixing=20(0=20consider?= =?UTF-8?q?ed=20as=20false=20=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/drawingtools/BaseTool.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/drawingtools/BaseTool.js b/js/drawingtools/BaseTool.js index ec12092d..b0c1dba5 100644 --- a/js/drawingtools/BaseTool.js +++ b/js/drawingtools/BaseTool.js @@ -14,10 +14,10 @@ ns.BaseTool.prototype.moveUnactiveToolAt = function(col, row, color, frame, overlay) { if (overlay.containsPixel(col, row)) { - if (this.previouslyHighlightedPixelCol && - this.previouslyHighlightedPixelRow && - (this.previouslyHighlightedPixelRow != row || - this.previouslyHighlightedPixelCol != col)) { + if (!isNaN(this.highlightedPixelCol) && + !isNaN(this.highlightedPixelRow) && + (this.highlightedPixelRow != row || + this.highlightedPixelCol != col)) { // Clean the previously highlighted pixel: overlay.clear(); @@ -26,8 +26,8 @@ // Show the current pixel targeted by the tool: overlay.setPixel(col, row, Constants.TOOL_TARGET_HIGHLIGHT_COLOR); - this.previouslyHighlightedPixelCol = col; - this.previouslyHighlightedPixelRow = row; + this.highlightedPixelCol = col; + this.highlightedPixelRow = row; } };