diff options
author | Pushkar Joshi | 2012-04-16 14:04:04 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-16 14:04:04 -0700 |
commit | 348ea7dfba12055e15e069a7c2b8bc527531e534 (patch) | |
tree | 710b85cfb062d086310f70472bff422317344054 /js/tools/PenTool.js | |
parent | 04d7f7ec211d7fee47aa353309eca36864c50d53 (diff) | |
download | ninja-348ea7dfba12055e15e069a7c2b8bc527531e534.tar.gz |
Allow the path stroke width to be changed without causing a drift in the canvas position
AND
some code cleanup (remove canvas left and top tracking for each subpath)
AND
add flags for the specifying in what coordinate space we're sampling the subpath
Diffstat (limited to 'js/tools/PenTool.js')
-rwxr-xr-x | js/tools/PenTool.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 06aac46c..a811f997 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -549,8 +549,6 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
549 | h = Math.round(h); | 549 | h = Math.round(h); |
550 | var left = Math.round(midPt[0] - 0.5 * w); | 550 | var left = Math.round(midPt[0] - 0.5 * w); |
551 | var top = Math.round(midPt[1] - 0.5 * h); | 551 | var top = Math.round(midPt[1] - 0.5 * h); |
552 | this._selectedSubpath.setCanvasLeft(left); | ||
553 | this._selectedSubpath.setCanvasTop(top); | ||
554 | 552 | ||
555 | if (!canvas) { | 553 | if (!canvas) { |
556 | var newCanvas = null; | 554 | var newCanvas = null; |
@@ -686,7 +684,6 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
686 | } | 684 | } |
687 | } | 685 | } |
688 | this._snapTargetIndex = -1; | 686 | this._snapTargetIndex = -1; |
689 | this._selectedSubpath.createSamples(); | ||
690 | 687 | ||
691 | //if we have some samples to render... | 688 | //if we have some samples to render... |
692 | if (this._selectedSubpath.getNumAnchors() > 1) { | 689 | if (this._selectedSubpath.getNumAnchors() > 1) { |
@@ -712,7 +709,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
712 | }, | 709 | }, |
713 | 710 | ||
714 | //prepare the selected subpath | 711 | //prepare the selected subpath |
715 | // convert the anchor points to stage world space (assume that's already the case if there already is a subpath canvas) | 712 | // convert the anchor points to stage world space (assume that's already the case if there is no subpath canvas) |
716 | // compute the center of the future canvas of this subpath in stage world space | 713 | // compute the center of the future canvas of this subpath in stage world space |
717 | // convert the anchor points from stage world to local space of the canvas | 714 | // convert the anchor points from stage world to local space of the canvas |
718 | PrepareSelectedSubpathForRendering: { | 715 | PrepareSelectedSubpathForRendering: { |
@@ -738,13 +735,19 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
738 | currAnchor.setPos(localPos[1][0],localPos[1][1],localPos[1][2]); | 735 | currAnchor.setPos(localPos[1][0],localPos[1][1],localPos[1][2]); |
739 | currAnchor.setNextPos(localPos[2][0],localPos[2][1],localPos[2][2]); | 736 | currAnchor.setNextPos(localPos[2][0],localPos[2][1],localPos[2][2]); |
740 | } | 737 | } |
738 | this._selectedSubpath.makeDirty(); | ||
741 | } | 739 | } |
742 | 740 | ||
743 | //compute the bbox in stage-world space | 741 | //compute the bbox in stage-world space |
744 | this._selectedSubpath.createSamples(); //we need to compute samples to get the bounding box center in stage world space | 742 | this._selectedSubpath.createSamples(true); //we need to compute samples to get the bounding box center in stage world space |
745 | var bboxMin = this._selectedSubpath.getBBoxMin(); | 743 | var bboxMin = this._selectedSubpath.getBBoxMin(); |
746 | var bboxMax = this._selectedSubpath.getBBoxMax(); | 744 | var bboxMax = this._selectedSubpath.getBBoxMax(); |
747 | this._selectedSubpathCanvasCenter = VecUtils.vecInterpolate(3, bboxMin, bboxMax, 0.5); | 745 | this._selectedSubpathCanvasCenter = VecUtils.vecInterpolate(3, bboxMin, bboxMax, 0.5); |
746 | if (this._selectedSubpathCanvas) { | ||
747 | //if the canvas does not yet exist, the stage world point already have this stage dimension offset below | ||
748 | this._selectedSubpathCanvasCenter[0]+= snapManager.getStageWidth()*0.5; | ||
749 | this._selectedSubpathCanvasCenter[1]+= snapManager.getStageHeight()*0.5; | ||
750 | } | ||
748 | 751 | ||
749 | var planeMatInv = glmat4.inverse(this._selectedSubpathPlaneMat, []); | 752 | var planeMatInv = glmat4.inverse(this._selectedSubpathPlaneMat, []); |
750 | 753 | ||
@@ -774,7 +777,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
774 | currAnchor.setNextPos(localPos[2][0],localPos[2][1],localPos[2][2]); | 777 | currAnchor.setNextPos(localPos[2][0],localPos[2][1],localPos[2][2]); |
775 | } | 778 | } |
776 | this._selectedSubpath.makeDirty(); | 779 | this._selectedSubpath.makeDirty(); |
777 | this._selectedSubpath.createSamples(); | 780 | this._selectedSubpath.createSamples(false); |
778 | this._selectedSubpath.offsetPerBBoxMin(); | 781 | this._selectedSubpath.offsetPerBBoxMin(); |
779 | } | 782 | } |
780 | }, | 783 | }, |
@@ -969,7 +972,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
969 | if (subpath === null) | 972 | if (subpath === null) |
970 | return; | 973 | return; |
971 | 974 | ||
972 | subpath.createSamples(); //dirty bit will be checked inside this function | 975 | subpath.createSamples(false); //dirty bit will be checked inside this function |
973 | var numAnchors = subpath.getNumAnchors(); | 976 | var numAnchors = subpath.getNumAnchors(); |
974 | if (numAnchors < 2) | 977 | if (numAnchors < 2) |
975 | return; | 978 | return; |
@@ -1278,7 +1281,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
1278 | if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ | 1281 | if (this._selectedSubpath.getSelectedAnchorIndex()>=0){ |
1279 | this._hoveredAnchorIndex=-1; | 1282 | this._hoveredAnchorIndex=-1; |
1280 | this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); | 1283 | this._selectedSubpath.removeAnchor(this._selectedSubpath.getSelectedAnchorIndex()); |
1281 | this._selectedSubpath.createSamples(); | 1284 | this._selectedSubpath.createSamples(false); |
1282 | //clear the canvas | 1285 | //clear the canvas |
1283 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); | 1286 | this.application.ninja.stage.clearDrawingCanvas();//stageManagerModule.stageManager.clearDrawingCanvas(); |
1284 | this.DrawSubpathAnchors(this._selectedSubpath); | 1287 | this.DrawSubpathAnchors(this._selectedSubpath); |