diff options
author | Armen Kesablyan | 2012-06-19 01:03:59 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-19 01:03:59 -0700 |
commit | 2e13a73e4ee980a6f73f6ff48b2a195eb209a7db (patch) | |
tree | d352f5e769eae0e1b7b76ccbeafa9b174b1a9918 /js/lib/geom/sub-path.js | |
parent | 244e608645778746d1a3b5aa0d4c0868f7c5c272 (diff) | |
parent | c59eb371559a3061ce53223e249ca97daace5968 (diff) | |
download | ninja-2e13a73e4ee980a6f73f6ff48b2a195eb209a7db.tar.gz |
Merge branch 'refs/heads/master' into binding
Conflicts:
js/components/layout/tools-list.reel/tools-list.html
js/components/layout/tools-properties.reel/tools-properties.html
js/document/document-html.js
js/document/templates/app/main.js
js/panels/Panel.reel/Panel.js
node_modules/montage/ui/native-control.js
Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/lib/geom/sub-path.js')
-rwxr-xr-x | js/lib/geom/sub-path.js | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js index f765b715..9b72f6b7 100755 --- a/js/lib/geom/sub-path.js +++ b/js/lib/geom/sub-path.js | |||
@@ -54,7 +54,7 @@ var GLSubpath = function GLSubpath() { | |||
54 | //drawing context | 54 | //drawing context |
55 | this._world = null; | 55 | this._world = null; |
56 | this._canvas = null; //todo this might be unnecessary (but faster) since we can get it from the world | 56 | this._canvas = null; //todo this might be unnecessary (but faster) since we can get it from the world |
57 | 57 | ||
58 | //tool that owns this subpath | 58 | //tool that owns this subpath |
59 | this._drawingTool = null; | 59 | this._drawingTool = null; |
60 | 60 | ||
@@ -87,6 +87,7 @@ GLSubpath.prototype.buildColor = function(ctx, //the 2D rendering conte | |||
87 | if (ipColor.gradientMode){ | 87 | if (ipColor.gradientMode){ |
88 | var position, gradient, cs, inset; //vars used in gradient calculations | 88 | var position, gradient, cs, inset; //vars used in gradient calculations |
89 | inset = Math.ceil( lw ) - 0.5; | 89 | inset = Math.ceil( lw ) - 0.5; |
90 | inset=0; | ||
90 | 91 | ||
91 | if(ipColor.gradientMode === "radial") { | 92 | if(ipColor.gradientMode === "radial") { |
92 | var ww = w - 2*lw, hh = h - 2*lw; | 93 | var ww = w - 2*lw, hh = h - 2*lw; |
@@ -207,24 +208,25 @@ GLSubpath.prototype.geomType = function () { | |||
207 | GLSubpath.prototype.setWidth = function (newW) { | 208 | GLSubpath.prototype.setWidth = function (newW) { |
208 | var strokeWidth = this._strokeWidth; | 209 | var strokeWidth = this._strokeWidth; |
209 | var halfStrokeWidth = strokeWidth*0.5; | 210 | var halfStrokeWidth = strokeWidth*0.5; |
210 | if (newW<1) { | 211 | var minWidth = 1+strokeWidth; |
211 | newW=1; //clamp minimum width to 1 | 212 | if (newW<minWidth) { |
213 | newW=minWidth; | ||
212 | } | 214 | } |
213 | 215 | ||
214 | //scale the contents of this subpath to lie within this width | 216 | //scale the contents of this subpath to lie within this width |
215 | //determine the scale factor by comparing with the old width | 217 | //determine the scale factor by comparing with the old width |
216 | var oldWidth = this._BBoxMax[0]-this._BBoxMin[0]; | 218 | var oldCanvasWidth = this._BBoxMax[0]-this._BBoxMin[0]; |
217 | if (oldWidth<1) { | 219 | if (oldCanvasWidth<minWidth) { |
218 | oldWidth=1; | 220 | oldCanvasWidth=minWidth; |
219 | } | 221 | } |
220 | 222 | ||
221 | var scaleX = newW/oldWidth; | 223 | var scaleX = (newW-strokeWidth)/(oldCanvasWidth-strokeWidth); |
222 | if (scaleX===1) { | 224 | if (scaleX===1) { |
223 | return; //no need to do anything | 225 | return; //no need to do anything |
224 | } | 226 | } |
225 | 227 | ||
226 | //scale the anchor point positions such that the width of the bbox is the newW | 228 | //scale the anchor point positions such that the width of the bbox is the newW |
227 | var origX = this._BBoxMin[0]; //this should always be zero since we only deal with local coordinates | 229 | var origX = halfStrokeWidth;//this is the left edge //this._BBoxMin[0]; //this should always be zero since we only deal with local coordinates |
228 | var numAnchors = this._Anchors.length; | 230 | var numAnchors = this._Anchors.length; |
229 | for (var i=0;i<numAnchors;i++){ | 231 | for (var i=0;i<numAnchors;i++){ |
230 | //compute the distance from the bboxMin | 232 | //compute the distance from the bboxMin |
@@ -241,23 +243,27 @@ GLSubpath.prototype.setWidth = function (newW) { | |||
241 | }; | 243 | }; |
242 | 244 | ||
243 | GLSubpath.prototype.setHeight = function (newH) { | 245 | GLSubpath.prototype.setHeight = function (newH) { |
244 | if (newH<1) { | 246 | var strokeWidth = this._strokeWidth; |
245 | newH=1; //clamp minimum width to 1 | 247 | var halfStrokeWidth = strokeWidth*0.5; |
248 | var minHeight = 1+strokeWidth; | ||
249 | |||
250 | if (newH<minHeight) { | ||
251 | newH=minHeight; //clamp minimum width to 1 | ||
246 | } | 252 | } |
247 | //scale the contents of this subpath to lie within this height | 253 | //scale the contents of this subpath to lie within this height |
248 | //determine the scale factor by comparing with the old height | 254 | //determine the scale factor by comparing with the old height |
249 | var oldHeight = this._BBoxMax[1]-this._BBoxMin[1]; | 255 | var oldHeight = this._BBoxMax[1]-this._BBoxMin[1]; |
250 | if (oldHeight<1){ | 256 | if (oldHeight<minHeight){ |
251 | oldHeight=1; | 257 | oldHeight=minHeight; |
252 | } | 258 | } |
253 | 259 | ||
254 | var scaleY = newH/oldHeight; | 260 | var scaleY = (newH-strokeWidth)/(oldHeight-strokeWidth); |
255 | if (scaleY===1){ | 261 | if (scaleY===1){ |
256 | return; //no need to do anything | 262 | return; //no need to do anything |
257 | } | 263 | } |
258 | 264 | ||
259 | //scale the anchor point positions such that the height of the bbox is the newH | 265 | //scale the anchor point positions such that the height of the bbox is the newH |
260 | var origY = this._BBoxMin[1]; | 266 | var origY = halfStrokeWidth;// this._BBoxMin[1];//this is the top edge |
261 | var numAnchors = this._Anchors.length; | 267 | var numAnchors = this._Anchors.length; |
262 | for (var i=0;i<numAnchors;i++){ | 268 | for (var i=0;i<numAnchors;i++){ |
263 | //compute the distance from the bboxMin | 269 | //compute the distance from the bboxMin |
@@ -270,6 +276,7 @@ GLSubpath.prototype.setHeight = function (newH) { | |||
270 | this._Anchors[i].setNextPos(this._Anchors[i].getNextX(), origY + nextW*scaleY,this._Anchors[i].getNextZ()); | 276 | this._Anchors[i].setNextPos(this._Anchors[i].getNextX(), origY + nextW*scaleY,this._Anchors[i].getNextZ()); |
271 | } | 277 | } |
272 | this.makeDirty(); | 278 | this.makeDirty(); |
279 | this.computeBoundingBox(true, false); | ||
273 | }; | 280 | }; |
274 | 281 | ||
275 | GLSubpath.prototype.setWorld = function (world) { | 282 | GLSubpath.prototype.setWorld = function (world) { |