diff options
author | wout <wout@impinc.co.uk> | 2012-12-28 23:20:22 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2012-12-28 23:20:22 +0100 |
commit | a20c0b1430fb97ff203a9afd6ba6945cf18e58d1 (patch) | |
tree | 00d3e0f535b52a1dab50f8705b7efcd5a78d033e /src | |
parent | c8be3da4ddeb80b7ca1a24df07cdca671b35c68a (diff) | |
download | svg.js-a20c0b1430fb97ff203a9afd6ba6945cf18e58d1.tar.gz svg.js-a20c0b1430fb97ff203a9afd6ba6945cf18e58d1.zip |
Added skew method to the sugar module
Diffstat (limited to 'src')
-rw-r--r-- | src/circle.js | 4 | ||||
-rw-r--r-- | src/element.js | 14 | ||||
-rw-r--r-- | src/sugar.js | 8 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/circle.js b/src/circle.js index d1f2cdc..059813e 100644 --- a/src/circle.js +++ b/src/circle.js @@ -27,8 +27,8 @@ SVG.extend(SVG.Circle, { var r = this.attrs.r || 0; return this.attr({ - cx: (x || ((this.attrs.x || 0) + r)), - cy: (y || ((this.attrs.y || 0) + r)) + cx: x || (this.attrs.x || 0) + r, + cy: y || (this.attrs.y || 0) + r }); } diff --git a/src/element.js b/src/element.js index 5a4d4ed..e849867 100644 --- a/src/element.js +++ b/src/element.js @@ -110,20 +110,18 @@ SVG.extend(SVG.Element, { t.push('rotate(' + o.rotation + ',' + (o.cx != null ? o.cx : b.cx) + ',' + (o.cy != null ? o.cy : b.cy) + ')'); // add scale - if (o.scaleX != 1 && o.scaleY != 1) - t.push('scale(' + o.sx + ',' + o.sy + ')'); + t.push('scale(' + o.scaleX + ',' + o.scaleY + ')'); // add skew on x axis if (o.skewX != 0) - t.push('skewX(' + x.skewX + ')'); + t.push('skewX(' + o.skewX + ')'); // add skew on y axis if (o.skewY != 0) - t.push('skewY(' + x.skewY + ')') + t.push('skewY(' + o.skewY + ')') // add translate - if (o.x != 0 && o.y != 0) - t.push('translate(' + o.x + ',' + o.y + ')'); + t.push('translate(' + o.x + ',' + o.y + ')'); // add only te required transformations return this.attr('transform', t.join(' ')); @@ -138,9 +136,11 @@ SVG.extend(SVG.Element, { // include translations on x an y x: b.x + this.trans.x, y: b.y + this.trans.y, + // add the center - cx: b.x + this.trans.x + b.width / 2, + cx: b.x + this.trans.x + b.width / 2, cy: b.y + this.trans.y + b.height / 2, + // plain width and height width: b.width, height: b.height diff --git a/src/sugar.js b/src/sugar.js index bd8454d..10a8716 100644 --- a/src/sugar.js +++ b/src/sugar.js @@ -41,6 +41,14 @@ SVG.extend(SVG.Element, { cx: x == null ? b.cx : x, cy: y == null ? b.cx : y }); + }, + + // skew + skew: function(x, y) { + return this.transform({ + skewX: x || 0, + skewY: y || 0 + }); } }); |