summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-02-05 10:51:47 +0100
committerwout <wout@impinc.co.uk>2014-02-05 10:51:47 +0100
commit050af98a7ada3280f02acf25fbaba585a264e68a (patch)
treeb03c435ba69363b85e3e865723ea71757d489d37 /src
parentc51d352babb75ef56fc71d93056a797d7f1d70c5 (diff)
downloadsvg.js-050af98a7ada3280f02acf25fbaba585a264e68a.tar.gz
svg.js-050af98a7ada3280f02acf25fbaba585a264e68a.zip
added pointAt() method to SVG.Path
Diffstat (limited to 'src')
-rwxr-xr-xsrc/path.js5
-rwxr-xr-xsrc/sugar.js40
2 files changed, 25 insertions, 20 deletions
diff --git a/src/path.js b/src/path.js
index 76ef1ba..0345487 100755
--- a/src/path.js
+++ b/src/path.js
@@ -37,10 +37,7 @@ SVG.Path = SVG.invent({
, height: function(height) {
return height == null ? this.bbox().height : this.size(this.bbox().width, height)
}
- // Get path length
- , length: function() {
- return this.node.getTotalLength()
- }
+
}
// Add parent method
diff --git a/src/sugar.js b/src/sugar.js
index 5d7f5aa..5c71afc 100755
--- a/src/sugar.js
+++ b/src/sugar.js
@@ -72,7 +72,6 @@ SVG.extend(SVG.Element, SVG.FX, {
})
-//
SVG.extend(SVG.Rect, SVG.Ellipse, {
// Add x and y radius
radius: function(x, y) {
@@ -81,21 +80,30 @@ SVG.extend(SVG.Rect, SVG.Ellipse, {
})
+SVG.extend(SVG.Path, {
+ // Get path length
+ length: function() {
+ return this.node.getTotalLength()
+ }
+ // Get point at length
+, pointAt: function(length) {
+ return this.node.getPointAtLength(length)
+ }
-if (SVG.Text) {
- SVG.extend(SVG.Text, SVG.FX, {
- // Set font
- font: function(o) {
- for (var key in o)
- key == 'anchor' ?
- this.attr('text-anchor', o[key]) :
- _styleAttr.indexOf(key) > -1 ?
- this.attr('font-'+ key, o[key]) :
- this.attr(key, o[key])
-
- return this
- }
+})
+
+SVG.extend(SVG.Text, SVG.FX, {
+ // Set font
+ font: function(o) {
+ for (var key in o)
+ key == 'anchor' ?
+ this.attr('text-anchor', o[key]) :
+ _styleAttr.indexOf(key) > -1 ?
+ this.attr('font-'+ key, o[key]) :
+ this.attr(key, o[key])
- })
-}
+ return this
+ }
+
+})