aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js31
-rwxr-xr-xjs/tools/PenTool.js26
2 files changed, 56 insertions, 1 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index d45d108e..c93672a9 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -254,7 +254,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
254 var top = Math.round(midPt[1] - 0.5 * h); 254 var top = Math.round(midPt[1] - 0.5 * h);
255 255
256 if (!canvas) { 256 if (!canvas) {
257 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);
258 var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas); 258 var elementModel = TagTool.makeElement(w, h, planeMat, midPt, newCanvas);
259 ElementMediator.addElement(newCanvas, elementModel.data, true); 259 ElementMediator.addElement(newCanvas, elementModel.data, true);
260 260
@@ -276,10 +276,37 @@ exports.BrushTool = Montage.create(ShapeTool, {
276 world.render(); 276 world.render();
277 //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
278 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 }
279 } 305 }
280 } //if (!canvas) { 306 } //if (!canvas) {
281 else { 307 else {
282 308
309 /*
283 var world = null; 310 var world = null;
284 if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) { 311 if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) {
285 world = canvas.elementModel.shapeModel.GLWorld; 312 world = canvas.elementModel.shapeModel.GLWorld;
@@ -320,6 +347,8 @@ exports.BrushTool = Montage.create(ShapeTool, {
320 //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
321 canvas.elementModel.shapeModel.GLGeomObj = brushStroke; 348 canvas.elementModel.shapeModel.GLGeomObj = brushStroke;
322 } 349 }
350 */
351 alert("BrushStroke cannot edit existing canvas");
323 } //else of if (!canvas) { 352 } //else of if (!canvas) {
324 } //value: function (w, h, planeMat, midPt, canvas) { 353 } //value: function (w, h, planeMat, midPt, canvas) {
325 }, //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