aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-02 12:23:44 -0800
committerPushkar Joshi2012-03-02 12:23:44 -0800
commit1b68bb87c458877cb850a96d8a093d6064bc41dc (patch)
treee479c2f0a3958cdf2110654b1886769518b1bee7 /js/tools
parent0b7f2f54738d2c1ea480b9bac7d3a750b1ef4df6 (diff)
downloadninja-1b68bb87c458877cb850a96d8a093d6064bc41dc.tar.gz
Catmull-Rom spline sampling for the brush stroke, and options for stroke size, stroke hardness and both stroke colors (left and right --- temporarily using the stroke and fill colors respectively)
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index dc9e022e..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(10); 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) {