aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-11 13:44:11 -0700
committerPushkar Joshi2012-04-11 13:44:11 -0700
commit8440896d099e09ee306671c6c906eec027383266 (patch)
treeb1fa0c5265716b0e088e1d3d4db79cc2faf98ba4 /js
parentc786aafb077f9f510c62bc51faa7a74a23ccda1c (diff)
downloadninja-8440896d099e09ee306671c6c906eec027383266.tar.gz
correctly add points to open paths on transformed canvases
Diffstat (limited to 'js')
-rwxr-xr-xjs/tools/PenTool.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js
index c21c1f24..ed08372d 100755
--- a/js/tools/PenTool.js
+++ b/js/tools/PenTool.js
@@ -179,7 +179,7 @@ exports.PenTool = Montage.create(ShapeTool, {
179 if (this._entryEditMode === this.ENTRY_SELECT_PATH){ 179 if (this._entryEditMode === this.ENTRY_SELECT_PATH){
180 //this should not happen, as ENTRY_SELECT_PATH implies there was a selected subpath 180 //this should not happen, as ENTRY_SELECT_PATH implies there was a selected subpath
181 this._entryEditMode = this.ENTRY_SELECT_NONE; 181 this._entryEditMode = this.ENTRY_SELECT_NONE;
182 console.log("Warning...PenTool handleMouseDown: changing from SELECT_PATH to SELECT_NONE"); 182 throw("Warning...PenTool handleMouseDown: changing from SELECT_PATH to SELECT_NONE");
183 } 183 }
184 } 184 }
185 185
@@ -190,8 +190,9 @@ exports.PenTool = Montage.create(ShapeTool, {
190 } 190 }
191 var globalMousePos = this._getUnsnappedScreenPosition(event.pageX, event.pageY); 191 var globalMousePos = this._getUnsnappedScreenPosition(event.pageX, event.pageY);
192 var localMousePos = ViewUtils.globalToLocal(globalMousePos, drawingCanvas); 192 var localMousePos = ViewUtils.globalToLocal(globalMousePos, drawingCanvas);
193 193 var localToStageWorldNoTransform = ViewUtils.getLocalToStageWorldMatrix(drawingCanvas, true, false);
194 194 var swMousePos = MathUtils.transformAndDivideHomogeneousPoint(localMousePos,localToStageWorldNoTransform);
195 swMousePos[0]+= snapManager.getStageWidth()*0.5; swMousePos[1]+= snapManager.getStageHeight()*0.5;
195 var prevSelectedAnchorIndex = this._selectedSubpath.getSelectedAnchorIndex(); 196 var prevSelectedAnchorIndex = this._selectedSubpath.getSelectedAnchorIndex();
196 // ************* Add/Select Anchor Point ************* 197 // ************* Add/Select Anchor Point *************
197 //check if the clicked location is close to an anchor point...if so, make that anchor the selected point and do nothing else 198 //check if the clicked location is close to an anchor point...if so, make that anchor the selected point and do nothing else
@@ -273,9 +274,12 @@ exports.PenTool = Montage.create(ShapeTool, {
273 if (!this._selectedSubpath.getIsClosed()) { 274 if (!this._selectedSubpath.getIsClosed()) {
274 this._selectedSubpath.addAnchor(new AnchorPoint()); 275 this._selectedSubpath.addAnchor(new AnchorPoint());
275 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); 276 var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex());
276 newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); 277 /*newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]);
277 newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); 278 newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]);
278 newAnchor.setNextPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); 279 newAnchor.setNextPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]);*/
280 newAnchor.setPos(swMousePos[0], swMousePos[1], swMousePos[2]);
281 newAnchor.setPrevPos(swMousePos[0], swMousePos[1], swMousePos[2]);
282 newAnchor.setNextPos(swMousePos[0], swMousePos[1], swMousePos[2]);
279 283
280 //set the mode so that dragging will update the next and previous locations 284 //set the mode so that dragging will update the next and previous locations
281 this._editMode = this.EDIT_PREV_NEXT; 285 this._editMode = this.EDIT_PREV_NEXT;