aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/LineTool.js56
1 files changed, 30 insertions, 26 deletions
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index f0d96c3c..4ec327b5 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -97,34 +97,38 @@ exports.LineTool = Montage.create(ShapeTool, {
97 if(this.drawData) { 97 if(this.drawData) {
98 w = Math.floor(this.drawData.width); 98 w = Math.floor(this.drawData.width);
99 h = Math.floor(this.drawData.height); 99 h = Math.floor(this.drawData.height);
100 // set the dimensions
101 if(slope === "horizontal") {
102 h = Math.max(this._strokeSize, 1);
103 w = Math.max(w, 1);
104 } else if(slope === "vertical") {
105 w = Math.max(this._strokeSize, 1);
106 h = Math.max(h, 1);
107 } else {
108 // else make the line's stroke fit inside the canvas by growing the canvas
109 var theta = Math.atan(slope);
110 xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta));
111 yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta));
112
113 w += ~~(xAdj*2);
114 h += ~~(yAdj*2);
115 }
116
100 if(!this._useExistingCanvas()) { 117 if(!this._useExistingCanvas()) {
101 // set the dimensions 118
102 if(slope === "horizontal") { 119 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
103 h = Math.max(this._strokeSize, 1); 120
104 w = Math.max(w, 1); 121 var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData);
105 } else if(slope === "vertical") { 122 this.application.ninja.elementMediator.addElements(canvas, styles);
106 w = Math.max(this._strokeSize, 1); 123 } else {
107 h = Math.max(h, 1); 124 canvas = this._targetedElement;
108 } else { 125 if (!canvas.getAttribute( "data-RDGE-id" ))
109 // else make the line's stroke fit inside the canvas by growing the canvas 126 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() );
110 var theta = Math.atan(slope); 127 canvas.elementModel.controller = ShapesController;
111 xAdj = Math.abs((this._strokeSize/2)*Math.sin(theta)); 128 if(!canvas.elementModel.shapeModel) {
112 yAdj = Math.abs((this._strokeSize/2)*Math.cos(theta)); 129 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
113
114 w += ~~(xAdj*2);
115 h += ~~(yAdj*2);
116 }
117
118 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
119
120 var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData);
121 this.application.ninja.elementMediator.addElements(canvas, styles);
122 } else {
123 canvas = this._targetedElement;
124 canvas.elementModel.controller = ShapesController;
125 if(!canvas.elementModel.shapeModel) {
126 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
127 } 130 }
131 this.RenderShape(w, h, this.drawData.planeMat, this.drawData.midPt, canvas, slope, xAdj, yAdj);
128 } 132 }
129 } 133 }
130 } 134 }