aboutsummaryrefslogtreecommitdiff
path: root/js/tools/BrushTool.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-02 12:36:34 -0800
committerPushkar Joshi2012-03-02 12:36:34 -0800
commitdc3c813320c8d3fb837d5d18e70ab35a53b116c1 (patch)
treeda417684de5e302d302ea617854015bd9a8ca17a /js/tools/BrushTool.js
parentd7d78d4a4e8cf82c56379d25efbe679b3b823abc (diff)
parent4419209a1fd850ab468209b562b66b0242b42a9c (diff)
downloadninja-dc3c813320c8d3fb837d5d18e70ab35a53b116c1.tar.gz
Merge branch 'brushtool' into pentool
Diffstat (limited to 'js/tools/BrushTool.js')
-rw-r--r--js/tools/BrushTool.js19
1 files changed, 16 insertions, 3 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
7var ShapeTool = require("js/tools/ShapeTool").ShapeTool; 7var ShapeTool = require("js/tools/ShapeTool").ShapeTool;
8var ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
8var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; 9var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase;
9var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; 10var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager;
10var Montage = require("montage/core/core").Montage; 11var 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();