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 fec89eb2..8b0f60bb 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; |
@@ -67,12 +68,24 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
67 | if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ | 68 | if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ |
68 | this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); | 69 | this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); |
69 | } | 70 | } |
71 | if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){ | ||
72 | this._selectedBrushStroke.setSecondStrokeColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor); | ||
73 | } | ||
70 | //add this point to the brush stroke in case the user does a mouse up before doing a mouse move | 74 | //add this point to the brush stroke in case the user does a mouse up before doing a mouse move |
71 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); | 75 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); |
72 | this._selectedBrushStroke.addPoint(currMousePos); | 76 | this._selectedBrushStroke.addPoint(currMousePos); |
73 | 77 | ||
74 | //TODO get these values from the options | 78 | var strokeSize = 1; |
75 | this._selectedBrushStroke.setStrokeWidth(20); | 79 | if (this.options.strokeSize) { |
80 | strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units); | ||
81 | } | ||
82 | this._selectedBrushStroke.setStrokeWidth(strokeSize); | ||
83 | |||
84 | var strokeHardness = 100; | ||
85 | if (this.options.strokeHardness){ | ||
86 | strokeHardness = ShapesController.GetValueInPixels(this.options.strokeHardness.value, this.options.strokeHardness.units); | ||
87 | } | ||
88 | this._selectedBrushStroke.setStrokeHardness(strokeHardness); | ||
76 | } | 89 | } |
77 | NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); | 90 | NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); |
78 | } //value: function (event) { | 91 | } //value: function (event) { |
@@ -112,7 +125,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
112 | 125 | ||
113 | if (this._isDrawing) { | 126 | if (this._isDrawing) { |
114 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); | 127 | var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); |
115 | if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<100){ | 128 | if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<1000){ |
116 | this._selectedBrushStroke.addPoint(currMousePos); | 129 | this._selectedBrushStroke.addPoint(currMousePos); |
117 | } | 130 | } |
118 | this.ShowCurrentBrushStrokeOnStage(); | 131 | this.ShowCurrentBrushStrokeOnStage(); |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index ddc8bc04..02367328 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -275,6 +275,9 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
275 | this.application.ninja.stage.clearDrawingCanvas(); | 275 | this.application.ninja.stage.clearDrawingCanvas(); |
276 | this._hoveredAnchorIndex = -1; | 276 | this._hoveredAnchorIndex = -1; |
277 | 277 | ||
278 | //set the cursor to be the default cursor | ||
279 | this.application.ninja.stage.drawingCanvas.style.cursor = "auto"; | ||
280 | |||
278 | if (this._isDrawing) { | 281 | if (this._isDrawing) { |
279 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); | 282 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); |
280 | //go through the drawing toolbase to get the position of the mouse | 283 | //go through the drawing toolbase to get the position of the mouse |
@@ -345,6 +348,14 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
345 | var selAnchor = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); | 348 | var selAnchor = this._selectedSubpath.pickAnchor(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); |
346 | if (selAnchor >=0) { | 349 | if (selAnchor >=0) { |
347 | this._hoveredAnchorIndex = selAnchor; | 350 | this._hoveredAnchorIndex = selAnchor; |
351 | } else { | ||
352 | //detect if the current mouse position will hit the path | ||
353 | var pathHitTestData = this._selectedSubpath.pathHitTest(currMousePos[0], currMousePos[1], currMousePos[2], this._PICK_POINT_RADIUS); | ||
354 | if (pathHitTestData[0]!==-1){ | ||
355 | //change the cursor | ||
356 | var cursor = "url('images/cursors/penAdd.png') 10 10,default"; | ||
357 | this.application.ninja.stage.drawingCanvas.style.cursor = cursor; | ||
358 | } | ||
348 | } | 359 | } |
349 | } | 360 | } |
350 | } //else of if (this._isDrawing) { | 361 | } //else of if (this._isDrawing) { |
@@ -353,7 +364,6 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
353 | if (this._selectedSubpath){ | 364 | if (this._selectedSubpath){ |
354 | this.DrawSubpathAnchors(this._selectedSubpath); | 365 | this.DrawSubpathAnchors(this._selectedSubpath); |
355 | } | 366 | } |
356 | |||
357 | }//value: function(event) | 367 | }//value: function(event) |
358 | },//HandleMouseMove | 368 | },//HandleMouseMove |
359 | 369 | ||