summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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) {