From 38ae1158abe94f917dbf375e73e1a9f0f68a61e8 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 18 Apr 2012 09:47:26 -0700 Subject: allow drawing polylines in YZ and XZ planes as well as XY. In those planes, still have bug with shift when the bbox of the path grows (due to missing translation) --- js/tools/PenTool.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'js/tools') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 8abb41ef..0e3bd15c 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -726,17 +726,23 @@ exports.PenTool = Montage.create(ShapeTool, { }, //prepare the selected subpath - // convert the anchor points to stage world space (assume that's already the case if there is no subpath canvas) // compute the center of the future canvas of this subpath in stage world space - // convert the anchor points from stage world to local space of the canvas + // compute local coordinates for the subpath (in case it does not have a canvas) PrepareSelectedSubpathForRendering: { value: function(){ var i=0,d=0; var currAnchor = null; var xAdjustment = snapManager.getStageWidth()*0.5; var yAdjustment = snapManager.getStageHeight()*0.5; + var swPos=null, swPrev=null, swNext=null; + var localPos=null, localPrev=null, localNext=null; var numAnchors = this._selectedSubpath.getNumAnchors(); + if (numAnchors<2){ + return;//nothing to do + } + this._selectedSubpath.makeDirty(); + var bboxMin=null, bboxMax=null; if (this._selectedSubpathCanvas) { //if there already is a subpath canvas, it means the anchor points are in local space @@ -779,10 +785,24 @@ exports.PenTool = Montage.create(ShapeTool, { bboxMax = this._selectedSubpath.getBBoxMax(); this._selectedSubpathCanvasCenter = VecUtils.vecInterpolate(3, bboxMin, bboxMax, 0.5); - //todo convert the path points into local coordinates - + //convert the path points into local coordinates by multiplying by the inverse of the plane mat + for (i=0;i