aboutsummaryrefslogtreecommitdiff
path: root/js/tools/BrushTool.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-14 15:37:09 -0700
committerPushkar Joshi2012-03-14 15:37:09 -0700
commit23baa44e0bc7bfb24e42702c1ef58bf62da083d8 (patch)
tree6efae3071b1b09e859fdefdbdac848063a22c355 /js/tools/BrushTool.js
parent6023f7c8258e660388ee33730601f1161f9299e9 (diff)
downloadninja-23baa44e0bc7bfb24e42702c1ef58bf62da083d8.tar.gz
PI for pen and brush strokes
Diffstat (limited to 'js/tools/BrushTool.js')
-rw-r--r--js/tools/BrushTool.js31
1 files changed, 30 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: {