diff options
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 19 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 12 |
2 files changed, 27 insertions, 4 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 752aa2a3..dd201f33 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -5,6 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var ShapeTool = require("js/tools/ShapeTool").ShapeTool; | 7 | var ShapeTool = require("js/tools/ShapeTool").ShapeTool; |
8 | var ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; | ||
8 | var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; | 9 | var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; |
9 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; | 10 | var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; |
10 | var Montage = require("montage/core/core").Montage; | 11 | var Montage = require("montage/core/core").Montage; |
@@ -69,12 +70,24 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
69 | if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ | 70 | if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ |
70 | this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); | 71 | this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); |
71 | } | 72 | } |
73 | if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){ | ||
74 | this._selectedBrushStroke.setSecondStrokeColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor); | ||
75 | } | ||
72 | //add this point to the brush stroke in case the user does a mouse up before doing a mouse move | 76 | //add this point to the brush stroke in case the user does a mouse up before doing a mouse move |
73 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); | 77 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); |
74 | this._selectedBrushStroke.addPoint(currMousePos); | 78 | this._selectedBrushStroke.addPoint(currMousePos); |
75 | 79 | ||
76 | //TODO get these values from the options | 80 | var strokeSize = 1; |
77 | this._selectedBrushStroke.setStrokeWidth(20); | 81 | if (this.options.strokeSize) { |
82 | strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units); | ||
83 | } | ||
84 | this._selectedBrushStroke.setStrokeWidth(strokeSize); | ||
85 | |||
86 | var strokeHardness = 100; | ||
87 | if (this.options.strokeHardness){ | ||
88 | strokeHardness = ShapesController.GetValueInPixels(this.options.strokeHardness.value, this.options.strokeHardness.units); | ||
89 | } | ||
90 | this._selectedBrushStroke.setStrokeHardness(strokeHardness); | ||
78 | } | 91 | } |
79 | NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); | 92 | NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); |
80 | } //value: function (event) { | 93 | } //value: function (event) { |
@@ -114,7 +127,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
114 | 127 | ||
115 | if (this._isDrawing) { | 128 | if (this._isDrawing) { |
116 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); | 129 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); |
117 | if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<100){ | 130 | if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<1000){ |
118 | this._selectedBrushStroke.addPoint(currMousePos); | 131 | this._selectedBrushStroke.addPoint(currMousePos); |
119 | } | 132 | } |
120 | this.ShowCurrentBrushStrokeOnStage(); | 133 | this.ShowCurrentBrushStrokeOnStage(); |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 71a91870..6897c003 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -278,6 +278,9 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
278 | this.application.ninja.stage.clearDrawingCanvas(); | 278 | this.application.ninja.stage.clearDrawingCanvas(); |
279 | this._hoveredAnchorIndex = -1; | 279 | this._hoveredAnchorIndex = -1; |
280 | 280 | ||
281 | //set the cursor to be the default cursor | ||
282 | this.application.ninja.stage.drawingCanvas.style.cursor = "auto"; | ||
283 | |||
281 | if (this._isDrawing) { | 284 | if (this._isDrawing) { |
282 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); | 285 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); |
283 | //go through the drawing toolbase to get the position of the mouse | 286 | //go through the drawing toolbase to get the position of the mouse |
@@ -348,6 +351,14 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
348 | var selAnchor = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); | 351 | var selAnchor = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); |
349 | if (selAnchor >=0) { | 352 | if (selAnchor >=0) { |
350 | this._hoveredAnchorIndex = selAnchor; | 353 | this._hoveredAnchorIndex = selAnchor; |
354 | } else { | ||
355 | //detect if the current mouse position will hit the path | ||
356 | var pathHitTestData = this._selectedSubpath.pathHitTest(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); | ||
357 | if (pathHitTestData[0]!==-1){ | ||
358 | //change the cursor | ||
359 | var cursor = "url('images/cursors/penAdd.png') 10 10,default"; | ||
360 | this.application.ninja.stage.drawingCanvas.style.cursor = cursor; | ||
361 | } | ||
351 | } | 362 | } |
352 | } | 363 | } |
353 | } //else of if (this._isDrawing) { | 364 | } //else of if (this._isDrawing) { |
@@ -356,7 +367,6 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
356 | if (this._selectedSubpath){ | 367 | if (this._selectedSubpath){ |
357 | this.DrawSubpathAnchors(this._selectedSubpath); | 368 | this.DrawSubpathAnchors(this._selectedSubpath); |
358 | } | 369 | } |
359 | |||
360 | }//value: function(event) | 370 | }//value: function(event) |
361 | },//HandleMouseMove | 371 | },//HandleMouseMove |
362 | 372 | ||