summaryrefslogtreecommitdiffstats
path: root/src/path.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-01-22 12:48:49 +0100
committerwout <wout@impinc.co.uk>2014-01-22 12:48:49 +0100
commitb27d01e9f91bff6145170ebd46857cd703480fec (patch)
treeaca9a0b30423ec4f7db769969ae5f3b25c7893df /src/path.js
parentdf8db4b03df6740e47851907a4b901362634c50b (diff)
downloadsvg.js-b27d01e9f91bff6145170ebd46857cd703480fec.tar.gz
svg.js-b27d01e9f91bff6145170ebd46857cd703480fec.zip
Bumped to v0.33
Diffstat (limited to 'src/path.js')
-rwxr-xr-x[-rw-r--r--]src/path.js52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/path.js b/src/path.js
index 3a50703..e9f4735 100644..100755
--- a/src/path.js
+++ b/src/path.js
@@ -8,8 +8,58 @@ SVG.Path = function(unbiased) {
SVG.Path.prototype = new SVG.Shape
SVG.extend(SVG.Path, {
+ // Move over x-axis
+ x: function(x) {
+ return x == null ? this.bbox().x : this.transform('x', x)
+ }
+ // Move over y-axis
+, y: function(y) {
+ return y == null ? this.bbox().y : this.transform('y', y)
+ }
+ // Set width of element
+, width: function(width) {
+ var b = this.bbox()
+
+ return width == null ? b.width : this.size(width, b.height)
+ }
+ // Set height of element
+, height: function(height) {
+ var b = this.bbox()
+
+ return height == null ? b.height : this.size(b.width, height)
+ }
+ // Set the actual size in pixels
+, size: function(width, height) {
+ var scale = width / this._offset.width
+
+ return this.transform({
+ scaleX: scale
+ , scaleY: height != null ? height / this._offset.height : scale
+ })
+ }
+ // Set path data
+, plot: function(data) {
+ var x = this.trans.scaleX
+ , y = this.trans.scaleY
+
+ /* native plot */
+ this._plot(data)
+
+ /* store offset */
+ this._offset = this.transform({ scaleX: 1, scaleY: 1 }).bbox()
+
+ /* get and store the actual offset of the element */
+ if (this.unbiased) {
+ this._offset.x = this._offset.y = 0
+ } else {
+ this._offset.x -= this.trans.x
+ this._offset.y -= this.trans.y
+ }
+
+ return this.transform({ scaleX: x, scaleY: y })
+ }
// Private: Native plot
- _plot: function(data) {
+, _plot: function(data) {
return this.attr('d', data || 'M0,0')
}