aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-24 08:28:39 -0700
committerPushkar Joshi2012-04-24 08:28:39 -0700
commitf57727d36709bbda03b45788dc12faf31a591b40 (patch)
tree16e5b0341476517c7bb1db9603d2b6cbc97dc5ee /js
parent5da51344c4abf53b4a77bbd4eefbea5ec67f1643 (diff)
downloadninja-f57727d36709bbda03b45788dc12faf31a591b40.tar.gz
re-compute and store the center of the subpath in local coordinates upon file open
Diffstat (limited to 'js')
-rwxr-xr-xjs/lib/geom/sub-path.js8
-rwxr-xr-xjs/tools/PenTool.js3
2 files changed, 10 insertions, 1 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js
index 43420bc9..56c94df3 100755
--- a/js/lib/geom/sub-path.js
+++ b/js/lib/geom/sub-path.js
@@ -1106,6 +1106,14 @@ GLSubpath.prototype.importJSON = function(jo) {
1106 this._fillColor = jo.fillColor; 1106 this._fillColor = jo.fillColor;
1107 1107
1108 this._dirty = true; 1108 this._dirty = true;
1109 this.createSamples(false);
1110 this.offsetPerBBoxMin();
1111
1112 //compute and store the center of the bbox in local space
1113 var bboxMin = this.getBBoxMin();
1114 var bboxMax = this.getBBoxMax();
1115 var bboxMid = [0.5*(bboxMin[0]+bboxMax[0]),0.5*(bboxMin[1]+bboxMax[1]),0.5*(bboxMin[2]+bboxMax[2])];
1116 this.setCanvasCenterLocalCoord(bboxMid);
1109}; 1117};
1110 1118
1111GLSubpath.prototype.import = function( importStr ) { 1119GLSubpath.prototype.import = function( importStr ) {
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index 4ff77371..8ecc9f79 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -786,7 +786,8 @@ exports.PenTool = Montage.create(ShapeTool, {
786 glmat4.multiply( newMat, tMat, newMat); 786 glmat4.multiply( newMat, tMat, newMat);
787 this._selectedSubpathPlaneMat = newMat; 787 this._selectedSubpathPlaneMat = newMat;
788 ViewUtils.setMatrixForElement(this._selectedSubpathCanvas, newMat, true); 788 ViewUtils.setMatrixForElement(this._selectedSubpathCanvas, newMat, true);
789 789
790 //now set the center of the canvas as the center of the bounding box expressed in stage world coordinates
790 var localToStageWorldMat = ViewUtils.getLocalToStageWorldMatrix(this._selectedSubpathCanvas, false, false); 791 var localToStageWorldMat = ViewUtils.getLocalToStageWorldMatrix(this._selectedSubpathCanvas, false, false);
791 this._selectedSubpathCanvasCenter = MathUtils.transformAndDivideHomogeneousPoint(bboxMid, localToStageWorldMat); 792 this._selectedSubpathCanvasCenter = MathUtils.transformAndDivideHomogeneousPoint(bboxMid, localToStageWorldMat);
792 this._selectedSubpathCanvasCenter[0]+= xAdjustment; 793 this._selectedSubpathCanvasCenter[0]+= xAdjustment;