summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/path.js13
-rw-r--r--src/poly.js7
2 files changed, 15 insertions, 5 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) {
diff --git a/src/poly.js b/src/poly.js
index af1f075..269b112 100644
--- a/src/poly.js
+++ b/src/poly.js
@@ -42,7 +42,12 @@ SVG.extend(SVG.Polyline, SVG.Polygon, {
, plot: function(p) {
return (p == null) ?
this.array() :
- this.attr('points', (this._array = new SVG.PointArray(p)))
+ this.clear().attr('points', typeof p == 'string' ? p : (this._array = new SVG.PointArray(p)))
+ }
+ // Clear array cache
+, clear: function() {
+ delete this._array
+ return this
}
// Move by left top corner
, move: function(x, y) {