summaryrefslogtreecommitdiffstats
path: root/src/container.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2012-12-22 13:33:50 +0100
committerwout <wout@impinc.co.uk>2012-12-22 13:33:50 +0100
commita96c2890913e7c6714d2558d15490226e82119bf (patch)
tree727651d96ddc465eeaabd0c4c02f6980533ad9bb /src/container.js
parent0c4be8fcd2d413d311d00a09b29c75da6fc685bb (diff)
downloadsvg.js-a96c2890913e7c6714d2558d15490226e82119bf.tar.gz
svg.js-a96c2890913e7c6714d2558d15490226e82119bf.zip
Change lement creation syntax
Diffstat (limited to 'src/container.js')
-rw-r--r--src/container.js82
1 files changed, 28 insertions, 54 deletions
diff --git a/src/container.js b/src/container.js
index 35d80a4..f45bd6c 100644
--- a/src/container.js
+++ b/src/container.js
@@ -59,76 +59,50 @@ SVG.Container = {
return e;
},
- rect: function(v) {
- return this.place(new SVG.Rect(), v);
+ rect: function(w, h) {
+ var e = new SVG.Rect().size(w, h);
+ this.add(e);
+
+ return e;
},
- circle: function(v) {
- var g;
-
- if (v != null) {
- g = { x: v.x, y: v.y };
-
- if (v.r || v.radius)
- g.width = g.height = (v.r || v.radius) * 2;
- else
- g.width = g.height = v.width || v.height;
- }
+ circle: function(r) {
+ var e = new SVG.Circle().size(r);
+ this.add(e);
- return this.place(new SVG.Circle(), g);
+ return e;
},
- ellipse: function(v) {
- var g;
-
- if (v != null) {
- g = { x: v.x, y: v.y };
-
- if (v.width) g.width = v.width;
- if (v.height) g.height = v.height;
- if (v.rx) g.width = v.rx * 2;
- if (v.ry) g.height = v.ry * 2;
- }
+ ellipse: function(w, h) {
+ var e = new SVG.Ellipse().size(w, h);
+ this.add(e);
- return this.place(new SVG.Ellipse(), g);
+ return e;
},
- path: function(v) {
- return this.place(new SVG.Path(), v);
+ path: function(d) {
+ var e = new SVG.Path().plot(d);
+ this.add(e);
+
+ return e;
},
- image: function(v) {
- return this.place(new SVG.Image(), v);
+ image: function(s) {
+ var e = new SVG.Image().load(s);
+ this.add(e);
+
+ return e;
},
- text: function(v) {
- return this.place(new SVG.Text(), v);
+ text: function(t) {
+ var e = new SVG.Text().text(t);
+ this.add(e);
+
+ return e;
},
gradient: function(t, b) {
return this.defs().gradient(t, b);
- },
-
- place: function(e, v) {
- if (v != null) {
- e.move(v.x || 0, v.y || 0);
-
-
- if (v.width != null && v.height != null)
- e.size(v.width, v.height);
-
- v.data != null ?
- e.plot(v.data) :
- v.src != null ?
- e.load(v.src) :
- v.text != null ?
- e.text(v.text) :
- void 0;
- }
-
- this.add(e);
-
- return e;
}
}; \ No newline at end of file