aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-13 13:05:16 -0700
committerNivesh Rajbhandari2012-03-13 13:05:16 -0700
commite19376c54eedd1f1c457ba405b2f110be376a559 (patch)
treed48c090f71ed2cd6bd6ce38ff68c36ab69299985 /js/tools
parent970c2e63aa8ec3f70df2bf073cedb9e3b7617755 (diff)
parentf56b8cf4d3316d250c0f0045fb78f0dbd5c56e94 (diff)
downloadninja-e19376c54eedd1f1c457ba405b2f110be376a559.tar.gz
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js41
-rwxr-xr-xjs/tools/PenTool.js18
2 files changed, 52 insertions, 7 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 752aa2a3..4ce9976a 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;
@@ -69,12 +70,46 @@ 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);
91
92 var doSmoothing = false;
93 if (this.options.doSmoothing){
94 doSmoothing = this.options.doSmoothing;
95 }
96 this._selectedBrushStroke.setDoSmoothing(doSmoothing);
97
98 var useCalligraphic = false;
99 if (this.options.useCalligraphic){
100 useCalligraphic = this.options.useCalligraphic;
101 }
102 if (useCalligraphic) {
103 this._selectedBrushStroke.setStrokeUseCalligraphic(true);
104 var strokeAngle = 0;
105 if (this.options.strokeAngle){
106 strokeAngle= ShapesController.GetValueInPixels(this.options.strokeAngle.value, this.options.strokeAngle.units);
107 }
108 this._selectedBrushStroke.setStrokeAngle(Math.PI * -strokeAngle/180);
109 } else {
110 this._selectedBrushStroke.setStrokeUseCalligraphic(false);
111 }
112
78 } 113 }
79 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); 114 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove();
80 } //value: function (event) { 115 } //value: function (event) {
@@ -114,7 +149,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
114 149
115 if (this._isDrawing) { 150 if (this._isDrawing) {
116 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); 151 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY);
117 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<100){ 152 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<1000){
118 this._selectedBrushStroke.addPoint(currMousePos); 153 this._selectedBrushStroke.addPoint(currMousePos);
119 } 154 }
120 this.ShowCurrentBrushStrokeOnStage(); 155 this.ShowCurrentBrushStrokeOnStage();
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 71a91870..60ef4f92 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
@@ -457,9 +467,9 @@ exports.PenTool = Montage.create(ShapeTool, {
457 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ 467 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){
458 this._selectedSubpath.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); 468 this._selectedSubpath.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor);
459 } 469 }
460 if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){ 470 //if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){
461 this._selectedSubpath.setFillColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor); 471 // this._selectedSubpath.setFillColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor);
462 } 472 //}
463 } //if this is a new path being rendered 473 } //if this is a new path being rendered
464 474
465 this._selectedSubpath.makeDirty(); 475 this._selectedSubpath.makeDirty();