diff options
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-x | js/tools/ShapeTool.js | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index d2337000..0562dbc2 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -53,23 +53,17 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
53 | } | 53 | } |
54 | }, | 54 | }, |
55 | 55 | ||
56 | HandleLeftButtonUp: | 56 | HandleLeftButtonUp: { |
57 | { | 57 | value: function (event) { |
58 | value: function (event) | 58 | var canvas, drawData = this.getDrawingData(); |
59 | { | ||
60 | var drawData; | ||
61 | |||
62 | drawData = this.getDrawingData(); | ||
63 | 59 | ||
64 | if(drawData) { | 60 | if(drawData) { |
65 | var canvas; | ||
66 | if(!this._useExistingCanvas()) { | 61 | if(!this._useExistingCanvas()) { |
67 | canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | 62 | canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
68 | var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, | 63 | document.application.njUtils.createModelWithShape(canvas); |
69 | drawData.planeMat, drawData.midPt, canvas, true); | ||
70 | 64 | ||
71 | canvas.elementModel.isShape = true; | 65 | var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData); |
72 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); | 66 | this.application.ninja.elementMediator.addElements(canvas, styles); |
73 | } else { | 67 | } else { |
74 | canvas = this._targetedElement; | 68 | canvas = this._targetedElement; |
75 | if (!canvas.getAttribute( "data-RDGE-id" )) | 69 | if (!canvas.getAttribute( "data-RDGE-id" )) |
@@ -193,26 +187,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
193 | } | 187 | } |
194 | }, | 188 | }, |
195 | 189 | ||
196 | createCanvas: { | ||
197 | value: function (left, top, w, h) | ||
198 | { | ||
199 | //var tmpDiv = document.createElement("canvas"); | ||
200 | var tmpDiv = NJUtils.makeNJElement("canvas", "Canvas", "block"); | ||
201 | var rules = { | ||
202 | 'position': 'absolute', | ||
203 | 'top' : top + 'px', | ||
204 | 'left' : left + 'px', | ||
205 | '-webkit-transform-style' : 'preserve-3d', | ||
206 | '-webkit-transform' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)' | ||
207 | }; | ||
208 | |||
209 | tmpDiv.width = w; | ||
210 | tmpDiv.height = h; | ||
211 | |||
212 | return {el: tmpDiv, rules: rules}; | ||
213 | } | ||
214 | }, | ||
215 | |||
216 | // We can draw on an existing canvas unless it has only a single shape object | 190 | // We can draw on an existing canvas unless it has only a single shape object |
217 | _useExistingCanvas: { | 191 | _useExistingCanvas: { |
218 | value: function() | 192 | value: function() |