diff options
Diffstat (limited to 'js/lib')
-rwxr-xr-x | js/lib/geom/sub-path.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js index 19a1da3b..4ded360c 100755 --- a/js/lib/geom/sub-path.js +++ b/js/lib/geom/sub-path.js | |||
@@ -866,6 +866,27 @@ GLSubpath.prototype.getStrokeWidth = function () { | |||
866 | return this._strokeWidth; | 866 | return this._strokeWidth; |
867 | }; | 867 | }; |
868 | 868 | ||
869 | GLSubpath.prototype.translateSubpathPerCanvas = function(elemMediator){ | ||
870 | //check if the canvas was translated | ||
871 | var penCanvasLeft = 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")); | ||
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 | |||
878 | var translateCanvasX = penCanvasOldX - this._canvasX; | ||
879 | var translateCanvasY = penCanvasOldY - this._canvasY; | ||
880 | |||
881 | //update the canvasX and canvasY 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){ | ||
883 | this.setCanvasX(translateCanvasX + this._canvasX); | ||
884 | this.setCanvasY(translateCanvasY + this._canvasY); | ||
885 | this.translateAnchors(translateCanvasX, translateCanvasY, 0); | ||
886 | } | ||
887 | this._dirty=true; | ||
888 | }; | ||
889 | |||
869 | GLSubpath.prototype.setStrokeWidth = function (w) { | 890 | GLSubpath.prototype.setStrokeWidth = function (w) { |
870 | var diffStrokeWidth = w-Math.floor(this._strokeWidth);//if positive, then stroke width grew, else shrunk | 891 | var diffStrokeWidth = w-Math.floor(this._strokeWidth);//if positive, then stroke width grew, else shrunk |
871 | if (diffStrokeWidth === 0) | 892 | if (diffStrokeWidth === 0) |
@@ -874,11 +895,14 @@ GLSubpath.prototype.setStrokeWidth = function (w) { | |||
874 | this._strokeWidth = w; | 895 | this._strokeWidth = w; |
875 | this._dirty=true; | 896 | this._dirty=true; |
876 | 897 | ||
898 | var ElementMediator = require("js/mediators/element-mediator").ElementMediator; | ||
899 | this.translateSubpathPerCanvas(ElementMediator); | ||
900 | |||
877 | // **** adjust the left, top, width, and height to adjust for the change in stroke width **** | 901 | // **** adjust the left, top, width, and height to adjust for the change in stroke width **** |
878 | this.createSamples(); //dirty bit is checked here | 902 | this.createSamples(); //dirty bit is checked here |
879 | this.buildLocalCoord(); //local dirty bit is checked here | 903 | this.buildLocalCoord(); //local dirty bit is checked here |
880 | 904 | ||
881 | //build the width and height of this canvas by looking at local coordinates (X and Y needed only) | 905 | //build the width and height of this canvas by looking at local coordinates |
882 | var bboxMin = this.getLocalBBoxMin(); | 906 | var bboxMin = this.getLocalBBoxMin(); |
883 | var bboxMax = this.getLocalBBoxMax(); | 907 | var bboxMax = this.getLocalBBoxMax(); |
884 | var bboxWidth = bboxMax[0] - bboxMin[0]; | 908 | var bboxWidth = bboxMax[0] - bboxMin[0]; |
@@ -892,7 +916,6 @@ GLSubpath.prototype.setStrokeWidth = function (w) { | |||
892 | var top = Math.round(bboxMid[1] - 0.5 * bboxHeight); | 916 | var top = Math.round(bboxMid[1] - 0.5 * bboxHeight); |
893 | 917 | ||
894 | var canvasArray=[this._canvas]; | 918 | var canvasArray=[this._canvas]; |
895 | var ElementMediator = require("js/mediators/element-mediator").ElementMediator; | ||
896 | ElementMediator.setProperty(canvasArray, "width", [bboxWidth+"px"], "Changing", "penTool");//canvas.width = w; | 919 | ElementMediator.setProperty(canvasArray, "width", [bboxWidth+"px"], "Changing", "penTool");//canvas.width = w; |
897 | ElementMediator.setProperty(canvasArray, "height", [bboxHeight+"px"], "Changing", "penTool");//canvas.height = h; | 920 | ElementMediator.setProperty(canvasArray, "height", [bboxHeight+"px"], "Changing", "penTool");//canvas.height = h; |
898 | ElementMediator.setProperty(canvasArray, "left", [left+"px"],"Changing", "penTool");//DocumentControllerModule.DocumentController.SetElementStyle(canvas, "left", parseInt(left) + "px"); | 921 | ElementMediator.setProperty(canvasArray, "left", [left+"px"],"Changing", "penTool");//DocumentControllerModule.DocumentController.SetElementStyle(canvas, "left", parseInt(left) + "px"); |