aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js40
-rwxr-xr-xjs/tools/PenTool.js26
2 files changed, 62 insertions, 4 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 4ce9976a..c93672a9 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -85,7 +85,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
85 85
86 var strokeHardness = 100; 86 var strokeHardness = 100;
87 if (this.options.strokeHardness){ 87 if (this.options.strokeHardness){
88 strokeHardness = ShapesController.GetValueInPixels(this.options.strokeHardness.value, this.options.strokeHardness.units); 88 strokeHardness = this.options.strokeHardness.value;
89 } 89 }
90 this._selectedBrushStroke.setStrokeHardness(strokeHardness); 90 this._selectedBrushStroke.setStrokeHardness(strokeHardness);
91 91
@@ -94,7 +94,10 @@ exports.BrushTool = Montage.create(ShapeTool, {
94 doSmoothing = this.options.doSmoothing; 94 doSmoothing = this.options.doSmoothing;
95 } 95 }
96 this._selectedBrushStroke.setDoSmoothing(doSmoothing); 96 this._selectedBrushStroke.setDoSmoothing(doSmoothing);
97 97 if (doSmoothing){
98 this._selectedBrushStroke.setSmoothingAmount(this.options.smoothingAmount.value);
99 }
100
98 var useCalligraphic = false; 101 var useCalligraphic = false;
99 if (this.options.useCalligraphic){ 102 if (this.options.useCalligraphic){
100 useCalligraphic = this.options.useCalligraphic; 103 useCalligraphic = this.options.useCalligraphic;
@@ -103,7 +106,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
103 this._selectedBrushStroke.setStrokeUseCalligraphic(true); 106 this._selectedBrushStroke.setStrokeUseCalligraphic(true);
104 var strokeAngle = 0; 107 var strokeAngle = 0;
105 if (this.options.strokeAngle){ 108 if (this.options.strokeAngle){
106 strokeAngle= ShapesController.GetValueInPixels(this.options.strokeAngle.value, this.options.strokeAngle.units); 109 strokeAngle= this.options.strokeAngle.value;
107 } 110 }
108 this._selectedBrushStroke.setStrokeAngle(Math.PI * -strokeAngle/180); 111 this._selectedBrushStroke.setStrokeAngle(Math.PI * -strokeAngle/180);
109 } else { 112 } else {
@@ -251,7 +254,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
251 var top = Math.round(midPt[1] - 0.5 * h); 254 var top = Math.round(midPt[1] - 0.5 * h);
252 255
253 if (!canvas) { 256 if (!canvas) {
254 var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); 257 var newCanvas = NJUtils.makeNJElement("canvas", "Brushstroke", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true);
255 var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); 258 var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas);
256 ElementMediator.addElement(newCanvas, elementModel.data, true); 259 ElementMediator.addElement(newCanvas, elementModel.data, true);
257 260
@@ -273,10 +276,37 @@ exports.BrushTool = Montage.create(ShapeTool, {
273 world.render(); 276 world.render();
274 //TODO this will not work if there are multiple shapes in the same canvas 277 //TODO this will not work if there are multiple shapes in the same canvas
275 newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke; 278 newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke;
279
280 newCanvas.elementModel.shapeModel.shapeCount++;
281 if(newCanvas.elementModel.shapeModel.shapeCount === 1)
282 {
283 newCanvas.elementModel.selection = "BrushStroke";
284 newCanvas.elementModel.pi = "BrushStrokePi";
285 newCanvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
286 var strokeColor = this._selectedBrushStroke.getStrokeColor();
287 newCanvas.elementModel.shapeModel.stroke = strokeColor;
288 if(strokeColor) {
289 newCanvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
290 }
291 newCanvas.elementModel.shapeModel.strokeMaterial = this._selectedBrushStroke.getStrokeMaterial();
292
293 newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke;
294 newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D;
295 }
296 else
297 {
298 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
299 }
300
301 if(newCanvas.elementModel.isShape)
302 {
303 this.application.ninja.selectionController.selectElement(canvas);
304 }
276 } 305 }
277 } //if (!canvas) { 306 } //if (!canvas) {
278 else { 307 else {
279 308
309 /*
280 var world = null; 310 var world = null;
281 if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) { 311 if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) {
282 world = canvas.elementModel.shapeModel.GLWorld; 312 world = canvas.elementModel.shapeModel.GLWorld;
@@ -317,6 +347,8 @@ exports.BrushTool = Montage.create(ShapeTool, {
317 //TODO this will not work if there are multiple shapes in the same canvas 347 //TODO this will not work if there are multiple shapes in the same canvas
318 canvas.elementModel.shapeModel.GLGeomObj = brushStroke; 348 canvas.elementModel.shapeModel.GLGeomObj = brushStroke;
319 } 349 }
350 */
351 alert("BrushStroke cannot edit existing canvas");
320 } //else of if (!canvas) { 352 } //else of if (!canvas) {
321 } //value: function (w, h, planeMat, midPt, canvas) { 353 } //value: function (w, h, planeMat, midPt, canvas) {
322 }, //RenderShape: { 354 }, //RenderShape: {
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 60ef4f92..e239b3f1 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -601,7 +601,33 @@ exports.PenTool = Montage.create(ShapeTool, {
601 601
602 world.addObject(subpath); 602 world.addObject(subpath);
603 world.render(); 603 world.render();
604 //TODO this will not work if there are multiple shapes in the same canvas
604 newCanvas.elementModel.shapeModel.GLGeomObj = subpath; 605 newCanvas.elementModel.shapeModel.GLGeomObj = subpath;
606 newCanvas.elementModel.shapeModel.shapeCount++;
607 if(newCanvas.elementModel.shapeModel.shapeCount === 1)
608 {
609 newCanvas.elementModel.selection = "Subpath";
610 newCanvas.elementModel.pi = "SubpathPi";
611 newCanvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
612 var strokeColor = subpath.getStrokeColor();
613 newCanvas.elementModel.shapeModel.stroke = strokeColor;
614 if(strokeColor) {
615 newCanvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
616 }
617 newCanvas.elementModel.shapeModel.strokeMaterial = this._selectedBrushStroke.getStrokeMaterial();
618
619 newCanvas.elementModel.shapeModel.GLGeomObj = subpath;
620 newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D;
621 }
622 else
623 {
624 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
625 }
626
627 if(newCanvas.elementModel.isShape)
628 {
629 this.application.ninja.selectionController.selectElement(newCanvas);
630 }
605 } //if (!canvas) { 631 } //if (!canvas) {
606 else { 632 else {
607 633