From d0661d6c587aced68a68e36a5ec4e81f8a2096e8 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 23 Feb 2012 16:57:55 -0800 Subject: bug fixes for canvas 2d shape drawing. --- js/tools/LineTool.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/tools') diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 233316a5..0a7c0534 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -42,7 +42,10 @@ exports.LineTool = Montage.create(ShapeTool, { } this._strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units, null); - this._strokeColor = this.application.ninja.colorController.colorToolbar.stroke.color.css; + if (this.application.ninja.colorController.colorToolbar.stroke.color) + this._strokeColor = this.application.ninja.colorController.colorToolbar.stroke.color.css; + else + this._strokeColor = [0,0,0,1]; this.startDraw(event); } }, -- cgit v1.2.3 From b194efa0556806593b29eb197250df462e89fcc4 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 27 Feb 2012 14:03:11 -0800 Subject: Enable shift key constraint for Pan Tool. --- js/tools/PanTool.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'js/tools') diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 71301d46..0537a27b 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -81,6 +81,14 @@ exports.PanTool = Montage.create(toolBase, { this._altKeyDown = true; } + else if (event.shiftKey) + { + if (!this._shiftKeyDown) + { + this._shiftKeyDown = true; + this._shiftPt = this._lastGPt.slice(); + } + } } }, @@ -90,6 +98,10 @@ exports.PanTool = Montage.create(toolBase, { this._altKeyDown = false; } + else if (event.keyCode === Keyboard.SHIFT) + { + this._shiftKeyDown = false; + } } }, @@ -221,6 +233,7 @@ exports.PanTool = Montage.create(toolBase, var tmpLocal = MathUtils.transformAndDivideHomogeneousPoint( this._globalPt, globalToLocalMat ); this._lastGPt = this._globalPt.slice(); + this._shiftPt = this._lastGPt.slice(); this._lastY = this._lastGPt[1]; // set up the matrices we will be needing @@ -285,6 +298,16 @@ exports.PanTool = Montage.create(toolBase, this._globalPt[2] += dy; gPt = [this._lastGPt[0], this._lastGPt[1], this._globalPt[2]]; } + else if (this._shiftKeyDown) + { + var dx = Math.abs( this._shiftPt[0] - gPt[0] ), + dy = Math.abs( this._shiftPt[1] - gPt[1] ); + + if (dx >= dy) + gPt[1] = this._shiftPt[1]; + else + gPt[0] = this._shiftPt[0]; + } // update the scrollbars var deltaGPt = VecUtils.vecSubtract(2, gPt, this._lastGPt); -- cgit v1.2.3