aboutsummaryrefslogtreecommitdiffstats
path: root/src/path.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2017-03-24 15:17:31 +0100
committerwout <wout@impinc.co.uk>2017-03-24 15:17:31 +0100
commit8324870a9b54a81c0339029a1bc3c2954217a6bb (patch)
tree4e98fcd79bacc20d511c42f55adaeac0d87bf074 /src/path.js
parenta749f7aa6e37e22cc02c5ad29647e1783bb75150 (diff)
downloadsvg.js-8324870a9b54a81c0339029a1bc3c2954217a6bb.tar.gz
svg.js-8324870a9b54a81c0339029a1bc3c2954217a6bb.zip
Speed improvements for plot() on path, polygon and poly line elements.
Diffstat (limited to 'src/path.js')
-rw-r--r--src/path.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/path.js b/src/path.js
index 0c70a47..e5504bb 100644
--- a/src/path.js
+++ b/src/path.js
@@ -13,11 +13,16 @@ SVG.Path = SVG.invent({
, array: function() {
return this._array || (this._array = new SVG.PathArray(this.attr('d')))
}
- // Plot new poly points
- , plot: function(p) {
- return (p == null) ?
+ // Plot new path
+ , plot: function(d) {
+ return (d == null) ?
this.array() :
- this.attr('d', (this._array = new SVG.PathArray(p)))
+ this.clear().attr('d', typeof d == 'string' ? d : (this._array = new SVG.PathArray(d)))
+ }
+ // Clear array cache
+ , clear: function() {
+ delete this._array
+ return this
}
// Move by left top corner
, move: function(x, y) {