diff options
-rwxr-xr-x | js/lib/geom/sub-path.js | 45 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 7 |
2 files changed, 26 insertions, 26 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js index 4ded360c..d8d74928 100755 --- a/js/lib/geom/sub-path.js +++ b/js/lib/geom/sub-path.js | |||
@@ -72,9 +72,9 @@ var GLSubpath = function GLSubpath() { | |||
72 | //the canvas that will draw this subpath | 72 | //the canvas that will draw this subpath |
73 | this._canvas = null; | 73 | this._canvas = null; |
74 | 74 | ||
75 | //the X and Y location of this subpath's canvas in stage world space of Ninja | 75 | //the top left location of this subpath's canvas in screen space |
76 | this._canvasX = 0; | 76 | this._canvasLeft = 0; |
77 | this._canvasY = 0; | 77 | this._canvasTop = 0; |
78 | 78 | ||
79 | //stroke information | 79 | //stroke information |
80 | this._strokeWidth = 1.0; | 80 | this._strokeWidth = 1.0; |
@@ -362,20 +362,20 @@ GLSubpath.prototype.setPlaneCenter = function(pc){ | |||
362 | this._planeCenter = pc; | 362 | this._planeCenter = pc; |
363 | }; | 363 | }; |
364 | 364 | ||
365 | GLSubpath.prototype.getCanvasX = function(){ | 365 | GLSubpath.prototype.getCanvasLeft = function(){ |
366 | return this._canvasX; | 366 | return this._canvasLeft; |
367 | }; | 367 | }; |
368 | 368 | ||
369 | GLSubpath.prototype.getCanvasY = function(){ | 369 | GLSubpath.prototype.getCanvasTop = function(){ |
370 | return this._canvasY; | 370 | return this._canvasTop; |
371 | }; | 371 | }; |
372 | 372 | ||
373 | GLSubpath.prototype.setCanvasX = function(cx){ | 373 | GLSubpath.prototype.setCanvasLeft = function(cx){ |
374 | this._canvasX=cx; | 374 | this._canvasLeft=cx; |
375 | }; | 375 | }; |
376 | 376 | ||
377 | GLSubpath.prototype.setCanvasY = function(cy){ | 377 | GLSubpath.prototype.setCanvasTop = function(cy){ |
378 | this._canvasY=cy; | 378 | this._canvasTop=cy; |
379 | }; | 379 | }; |
380 | 380 | ||
381 | GLSubpath.prototype.getIsClosed = function () { | 381 | GLSubpath.prototype.getIsClosed = function () { |
@@ -868,20 +868,17 @@ GLSubpath.prototype.getStrokeWidth = function () { | |||
868 | 868 | ||
869 | GLSubpath.prototype.translateSubpathPerCanvas = function(elemMediator){ | 869 | GLSubpath.prototype.translateSubpathPerCanvas = function(elemMediator){ |
870 | //check if the canvas was translated | 870 | //check if the canvas was translated |
871 | var penCanvasLeft = parseInt(elemMediator.getProperty(this._canvas, "left"));//parseFloat(DocumentControllerModule.DocumentController.GetElementStyle(this._penCanvas, "left")); | 871 | var penCanvasCurrentLeft = parseInt(elemMediator.getProperty(this._canvas, "left"));//parseFloat(DocumentControllerModule.DocumentController.GetElementStyle(this._penCanvas, "left")); |
872 | var penCanvasTop = parseInt(elemMediator.getProperty(this._canvas, "top"));//parseFloat(DocumentControllerModule.DocumentController.GetElementStyle(this._penCanvas, "top")); | 872 | var penCanvasCurrentTop = parseInt(elemMediator.getProperty(this._canvas, "top"));//parseFloat(DocumentControllerModule.DocumentController.GetElementStyle(this._penCanvas, "top")); |
873 | var penCanvasWidth = parseInt(elemMediator.getProperty(this._canvas, "width"));//this._penCanvas.width; | ||
874 | var penCanvasHeight = parseInt(elemMediator.getProperty(this._canvas, "height"));//this._penCanvas.height; | ||
875 | var penCanvasOldX = penCanvasLeft + 0.5 * penCanvasWidth; | ||
876 | var penCanvasOldY = penCanvasTop + 0.5 * penCanvasHeight; | ||
877 | 873 | ||
878 | var translateCanvasX = penCanvasOldX - this._canvasX; | 874 | var translateCanvasX = Math.round(penCanvasCurrentLeft - this._canvasLeft); |
879 | var translateCanvasY = penCanvasOldY - this._canvasY; | 875 | var translateCanvasY = Math.round(penCanvasCurrentTop - this._canvasTop); |
880 | 876 | ||
881 | //update the canvasX and canvasY parameters for this subpath and also translate the subpath points (since they're stored in stage world space) | 877 | //update the left and top parameters for this subpath and also translate the subpath points (since they're stored in stage world space) |
882 | if (Math.abs(translateCanvasX)>=1 || Math.abs(translateCanvasY)>=1){ | 878 | if (Math.abs(translateCanvasX)>=1 || Math.abs(translateCanvasY)>=1){ |
883 | this.setCanvasX(translateCanvasX + this._canvasX); | 879 | this.setCanvasLeft(penCanvasCurrentLeft); |
884 | this.setCanvasY(translateCanvasY + this._canvasY); | 880 | this.setCanvasTop(penCanvasCurrentTop); |
881 | //todo does the canvas translation correspond to the translation in stage world space? | ||
885 | this.translateAnchors(translateCanvasX, translateCanvasY, 0); | 882 | this.translateAnchors(translateCanvasX, translateCanvasY, 0); |
886 | } | 883 | } |
887 | this._dirty=true; | 884 | this._dirty=true; |
@@ -896,6 +893,8 @@ GLSubpath.prototype.setStrokeWidth = function (w) { | |||
896 | this._dirty=true; | 893 | this._dirty=true; |
897 | 894 | ||
898 | var ElementMediator = require("js/mediators/element-mediator").ElementMediator; | 895 | var ElementMediator = require("js/mediators/element-mediator").ElementMediator; |
896 | |||
897 | //translate the subpath in case the actual canvas location does not match where subpath thinks the canvas should be | ||
899 | this.translateSubpathPerCanvas(ElementMediator); | 898 | this.translateSubpathPerCanvas(ElementMediator); |
900 | 899 | ||
901 | // **** adjust the left, top, width, and height to adjust for the change in stroke width **** | 900 | // **** adjust the left, top, width, and height to adjust for the change in stroke width **** |
@@ -920,6 +919,8 @@ GLSubpath.prototype.setStrokeWidth = function (w) { | |||
920 | ElementMediator.setProperty(canvasArray, "height", [bboxHeight+"px"], "Changing", "penTool");//canvas.height = h; | 919 | ElementMediator.setProperty(canvasArray, "height", [bboxHeight+"px"], "Changing", "penTool");//canvas.height = h; |
921 | ElementMediator.setProperty(canvasArray, "left", [left+"px"],"Changing", "penTool");//DocumentControllerModule.DocumentController.SetElementStyle(canvas, "left", parseInt(left) + "px"); | 920 | ElementMediator.setProperty(canvasArray, "left", [left+"px"],"Changing", "penTool");//DocumentControllerModule.DocumentController.SetElementStyle(canvas, "left", parseInt(left) + "px"); |
922 | ElementMediator.setProperty(canvasArray, "top", [top + "px"],"Changing", "penTool");//DocumentControllerModule.DocumentController.SetElementStyle(canvas, "top", parseInt(top) + "px"); | 921 | ElementMediator.setProperty(canvasArray, "top", [top + "px"],"Changing", "penTool");//DocumentControllerModule.DocumentController.SetElementStyle(canvas, "top", parseInt(top) + "px"); |
922 | this.setCanvasLeft(left); | ||
923 | this.setCanvasTop(top); | ||
923 | }; | 924 | }; |
924 | 925 | ||
925 | GLSubpath.prototype.getStrokeMaterial = function () { | 926 | GLSubpath.prototype.getStrokeMaterial = function () { |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 0dbefd16..91b7606e 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -419,10 +419,6 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
419 | bboxMax = this._selectedSubpath.getBBoxMax(); | 419 | bboxMax = this._selectedSubpath.getBBoxMax(); |
420 | var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]; | 420 | var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]; |
421 | 421 | ||
422 | this._selectedSubpath.setPlaneCenter(bboxMid); | ||
423 | this._selectedSubpath.setCanvasX(bboxMid[0]); | ||
424 | this._selectedSubpath.setCanvasY(bboxMid[1]); | ||
425 | |||
426 | //call render shape with the bbox width and height | 422 | //call render shape with the bbox width and height |
427 | this.RenderShape(bboxWidth, bboxHeight, bboxMid, this._penPlaneMat, this._penCanvas); | 423 | this.RenderShape(bboxWidth, bboxHeight, bboxMid, this._penPlaneMat, this._penCanvas); |
428 | } | 424 | } |
@@ -437,6 +433,9 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
437 | 433 | ||
438 | var left = Math.round(midPt[0] - 0.5 * w); | 434 | var left = Math.round(midPt[0] - 0.5 * w); |
439 | var top = Math.round(midPt[1] - 0.5 * h); | 435 | var top = Math.round(midPt[1] - 0.5 * h); |
436 | this._selectedSubpath.setPlaneCenter(midPt); | ||
437 | this._selectedSubpath.setCanvasLeft(left); | ||
438 | this._selectedSubpath.setCanvasTop(top); | ||
440 | 439 | ||
441 | if (!canvas) { | 440 | if (!canvas) { |
442 | var newCanvas = null; | 441 | var newCanvas = null; |