From 7cbd26d475eaad817042692f9116f9a24ae60997 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 28 Feb 2012 10:24:06 -0800 Subject: Bug fixes: 1152: allow deleting of multiple paths from inside pen tool 1128: keyboard hotkey shortcut 'P' for pen tool 941: changing width or height of the path scales the path --- js/helper-classes/RDGE/GLAnchorPoint.js | 7 ++++ js/helper-classes/RDGE/GLSubpath.js | 64 ++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 5 deletions(-) (limited to 'js/helper-classes/RDGE') diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js index 716f59d4..c3e95b34 100755 --- a/js/helper-classes/RDGE/GLAnchorPoint.js +++ b/js/helper-classes/RDGE/GLAnchorPoint.js @@ -133,6 +133,13 @@ GLAnchorPoint.prototype.translateAll = function (x, y, z) { } +GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){ + this._x *= sx;this._prevX *= sx;this._nextX *= sx; + this._y *= sy;this._prevY *= sy;this._nextY *= sy; + this._z *= sz;this._prevZ *= sz;this._nextZ *= sz; +} + + // ********* getters ********** GLAnchorPoint.prototype.getPosX = function () { return this._x; } GLAnchorPoint.prototype.getPosY = function () { return this._y; } diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js index 3200cf59..7beb11b9 100755 --- a/js/helper-classes/RDGE/GLSubpath.js +++ b/js/helper-classes/RDGE/GLSubpath.js @@ -178,6 +178,65 @@ function GLSubpath() { } //render() this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; } + + + this.setWidth = function (newW) { + //todo this doesn't work in cases where the newW is zero or if the previous width was 0/1 (i.e. the path had become degenerate in width) + //todo same as above for the setHeight function below + //scale the contents of this subpath to lie within this width + //determine the scale factor by comparing with the old width + var oldWidth = this._BBoxMax[0]-this._BBoxMin[0]; + if (oldWidth<1){ + oldWidth=1; + } + var scaleX = newW/oldWidth; + if (scaleX===1){ + return; //no need to do anything + } + + //scale the anchor point positions such that the width of the bbox is the newW + var origX = this._BBoxMin[0]; + var numAnchors = this._Anchors.length; + for (var i=0;i