aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorhwc4872012-04-23 17:04:48 -0700
committerhwc4872012-04-23 17:04:48 -0700
commit27c1ba250a7db26cf24dd456d20af9ff1649e638 (patch)
treeee178314a5e5ff13128ebfd8b3f0add4dd2ae8e3 /js/tools
parent0f2b7cf2e1aae16e3cf4e699ab7e3ca83deb1529 (diff)
downloadninja-27c1ba250a7db26cf24dd456d20af9ff1649e638.tar.gz
canvas interaction
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/OvalTool.js2
-rwxr-xr-xjs/tools/ShapeTool.js22
2 files changed, 13 insertions, 11 deletions
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index e8e88d1d..6edec811 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -66,7 +66,7 @@ exports.OvalTool = Montage.create(ShapeTool, {
66 var world = this.getGLWorld(canvas, this.options.use3D); 66 var world = this.getGLWorld(canvas, this.options.use3D);
67 67
68 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); 68 var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2);
69 var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); 69 var yOffset = -(canvas.height/2 - (top - canvas.offsetTop + h/2));
70 70
71 var oval = new Circle(); //GLCircle(); 71 var oval = new Circle(); //GLCircle();
72 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); 72 oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle);
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index f3b5e92d..b2948fe7 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -54,9 +54,9 @@ exports.ShapeTool = Montage.create(DrawingTool, {
54 }, 54 },
55 55
56 HandleLeftButtonUp: 56 HandleLeftButtonUp:
57 { 57 {
58 value: function (event) 58 value: function (event)
59 { 59 {
60 var drawData; 60 var drawData;
61 61
62 drawData = this.getDrawingData(); 62 drawData = this.getDrawingData();
@@ -69,24 +69,26 @@ exports.ShapeTool = Montage.create(DrawingTool, {
69 drawData.planeMat, drawData.midPt, canvas, true); 69 drawData.planeMat, drawData.midPt, canvas, true);
70 70
71 canvas.elementModel.isShape = true; 71 canvas.elementModel.isShape = true;
72 this.application.ninja.elementMediator.addElements(canvas, elementModel.data);
73 } else { 72 } else {
74 canvas = this._targetedElement; 73 canvas = this._targetedElement;
74 if (!canvas.getAttribute( "data-RDGE-id" ))
75 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() );
75 canvas.elementModel.controller = ShapesController; 76 canvas.elementModel.controller = ShapesController;
76 if(!canvas.elementModel.shapeModel) { 77 if(!canvas.elementModel.shapeModel) {
77 canvas.elementModel.shapeModel = Montage.create(ShapeModel); 78 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
78 } 79 }
79 } 80 }
81 this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data);
80 } 82 }
81 83
82 this.endDraw(event); 84 this.endDraw(event);
83 85
84 this._isDrawing = false; 86 this._isDrawing = false;
85 this._hasDraw=false; 87 this._hasDraw=false;
86 88
87 this.DrawHandles(); 89 this.DrawHandles();
88 } 90 }
89 }, 91 },
90 92
91 onAddElements: { 93 onAddElements: {
92 value: function(el) { 94 value: function(el) {