aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js41
-rwxr-xr-xjs/tools/PenTool.js33
2 files changed, 67 insertions, 7 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 4ce9976a..90010cdf 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
@@ -263,6 +266,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
263 var brushStroke = this._selectedBrushStroke; 266 var brushStroke = this._selectedBrushStroke;
264 if (brushStroke){ 267 if (brushStroke){
265 brushStroke.setWorld(world); 268 brushStroke.setWorld(world);
269 brushStroke.setCanvas(newCanvas);
266 270
267 brushStroke.setPlaneMatrix(planeMat); 271 brushStroke.setPlaneMatrix(planeMat);
268 var planeMatInv = glmat4.inverse( planeMat, [] ); 272 var planeMatInv = glmat4.inverse( planeMat, [] );
@@ -273,10 +277,37 @@ exports.BrushTool = Montage.create(ShapeTool, {
273 world.render(); 277 world.render();
274 //TODO this will not work if there are multiple shapes in the same canvas 278 //TODO this will not work if there are multiple shapes in the same canvas
275 newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke; 279 newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke;
280
281 newCanvas.elementModel.shapeModel.shapeCount++;
282 if(newCanvas.elementModel.shapeModel.shapeCount === 1)
283 {
284 newCanvas.elementModel.selection = "BrushStroke";
285 newCanvas.elementModel.pi = "BrushStrokePi";
286 newCanvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
287 var strokeColor = this._selectedBrushStroke.getStrokeColor();
288 newCanvas.elementModel.shapeModel.stroke = strokeColor;
289 if(strokeColor) {
290 newCanvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
291 }
292 newCanvas.elementModel.shapeModel.strokeMaterial = this._selectedBrushStroke.getStrokeMaterial();
293
294 newCanvas.elementModel.shapeModel.GLGeomObj = brushStroke;
295 newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D;
296 }
297 else
298 {
299 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
300 }
301
302 if(newCanvas.elementModel.isShape)
303 {
304 this.application.ninja.selectionController.selectElement(canvas);
305 }
276 } 306 }
277 } //if (!canvas) { 307 } //if (!canvas) {
278 else { 308 else {
279 309
310 /*
280 var world = null; 311 var world = null;
281 if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) { 312 if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) {
282 world = canvas.elementModel.shapeModel.GLWorld; 313 world = canvas.elementModel.shapeModel.GLWorld;
@@ -317,6 +348,8 @@ exports.BrushTool = Montage.create(ShapeTool, {
317 //TODO this will not work if there are multiple shapes in the same canvas 348 //TODO this will not work if there are multiple shapes in the same canvas
318 canvas.elementModel.shapeModel.GLGeomObj = brushStroke; 349 canvas.elementModel.shapeModel.GLGeomObj = brushStroke;
319 } 350 }
351 */
352 alert("BrushStroke cannot edit existing canvas");
320 } //else of if (!canvas) { 353 } //else of if (!canvas) {
321 } //value: function (w, h, planeMat, midPt, canvas) { 354 } //value: function (w, h, planeMat, midPt, canvas) {
322 }, //RenderShape: { 355 }, //RenderShape: {
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 60ef4f92..779b7f16 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -467,9 +467,9 @@ exports.PenTool = Montage.create(ShapeTool, {
467 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ 467 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){
468 this._selectedSubpath.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); 468 this._selectedSubpath.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor);
469 } 469 }
470 //if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){ 470 if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){
471 // this._selectedSubpath.setFillColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor); 471 this._selectedSubpath.setFillColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor);
472 //} 472 }
473 } //if this is a new path being rendered 473 } //if this is a new path being rendered
474 474
475 this._selectedSubpath.makeDirty(); 475 this._selectedSubpath.makeDirty();
@@ -594,6 +594,7 @@ exports.PenTool = Montage.create(ShapeTool, {
594 594
595 var subpath = this._selectedSubpath; //new GLSubpath(); 595 var subpath = this._selectedSubpath; //new GLSubpath();
596 subpath.setWorld(world); 596 subpath.setWorld(world);
597 subpath.setCanvas(newCanvas);
597 subpath.setPlaneMatrix(planeMat); 598 subpath.setPlaneMatrix(planeMat);
598 var planeMatInv = glmat4.inverse( planeMat, [] ); 599 var planeMatInv = glmat4.inverse( planeMat, [] );
599 subpath.setPlaneMatrixInverse(planeMatInv); 600 subpath.setPlaneMatrixInverse(planeMatInv);
@@ -601,7 +602,33 @@ exports.PenTool = Montage.create(ShapeTool, {
601 602
602 world.addObject(subpath); 603 world.addObject(subpath);
603 world.render(); 604 world.render();
605 //TODO this will not work if there are multiple shapes in the same canvas
604 newCanvas.elementModel.shapeModel.GLGeomObj = subpath; 606 newCanvas.elementModel.shapeModel.GLGeomObj = subpath;
607 newCanvas.elementModel.shapeModel.shapeCount++;
608 if(newCanvas.elementModel.shapeModel.shapeCount === 1)
609 {
610 newCanvas.elementModel.selection = "Subpath";
611 newCanvas.elementModel.pi = "SubpathPi";
612 newCanvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
613 var strokeColor = subpath.getStrokeColor();
614 newCanvas.elementModel.shapeModel.stroke = strokeColor;
615 if(strokeColor) {
616 newCanvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
617 }
618 newCanvas.elementModel.shapeModel.strokeMaterial = subpath.getStrokeMaterial();
619
620 newCanvas.elementModel.shapeModel.GLGeomObj = subpath;
621 newCanvas.elementModel.shapeModel.useWebGl = this.options.use3D;
622 }
623 else
624 {
625 // TODO - update the shape's info only. shapeModel will likely need an array of shapes.
626 }
627
628 if(newCanvas.elementModel.isShape)
629 {
630 this.application.ninja.selectionController.selectElement(newCanvas);
631 }
605 } //if (!canvas) { 632 } //if (!canvas) {
606 else { 633 else {
607 634