aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorPushkar Joshi2012-02-29 09:47:41 -0800
committerPushkar Joshi2012-02-29 09:47:41 -0800
commitf931c48a7d0bcf1222cf05787e3294839ed0b9fb (patch)
tree584e3dc113dff708fe2a40e889d3ecc6a5b0bb78 /js/tools
parentb43efdcbfa671a46d1edaeb1555f508fe2ad0338 (diff)
downloadninja-f931c48a7d0bcf1222cf05787e3294839ed0b9fb.tar.gz
resample the brush stroke so we don't have gaps if the path is drawn rapidly,
and, allow to change the stroke color, and, more efficient stroke rendering by drawing translated radial gradients (instead of creating new gradients for each stroke sample)
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 9a0ad583..776d914c 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -64,6 +64,11 @@ exports.BrushTool = Montage.create(ShapeTool, {
64 //start a new brush stroke 64 //start a new brush stroke
65 if (this._selectedBrushStroke === null){ 65 if (this._selectedBrushStroke === null){
66 this._selectedBrushStroke = new GLBrushStroke(); 66 this._selectedBrushStroke = new GLBrushStroke();
67 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){
68 this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor);
69 }
70 //TODO get these values from the options
71 this._selectedBrushStroke.setStrokeWidth(20);
67 } 72 }
68 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); 73 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove();
69 } //value: function (event) { 74 } //value: function (event) {
@@ -132,10 +137,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
132 this._isDrawing = false; 137 this._isDrawing = false;
133 this._hasDraw = false; 138 this._hasDraw = false;
134 139
135 //TODO get these values from the options 140
136 if (this._selectedBrushStroke){
137 this._selectedBrushStroke.setStrokeWidth(20);
138 }
139 //display the previously drawn stroke in a separate canvas 141 //display the previously drawn stroke in a separate canvas
140 this.RenderCurrentBrushStroke(); 142 this.RenderCurrentBrushStroke();
141 143
@@ -150,7 +152,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
150 //clear the canvas before we draw anything else 152 //clear the canvas before we draw anything else
151 this.application.ninja.stage.clearDrawingCanvas(); 153 this.application.ninja.stage.clearDrawingCanvas();
152 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()>0){ 154 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()>0){
153 this._selectedBrushStroke.computeMetaGeometry(); 155 //this._selectedBrushStroke.computeMetaGeometry();
154 var ctx = this.application.ninja.stage.drawingContext;//stageManagerModule.stageManager.drawingContext; 156 var ctx = this.application.ninja.stage.drawingContext;//stageManagerModule.stageManager.drawingContext;
155 if (ctx === null) 157 if (ctx === null)
156 throw ("null drawing context in Brushtool::ShowCurrentBrushStrokeOnStage"); 158 throw ("null drawing context in Brushtool::ShowCurrentBrushStrokeOnStage");