aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-06-29 15:16:58 +0100
committerwout <wout@impinc.co.uk>2013-06-29 15:16:58 +0100
commite4fb8522a2c57069b2523f16de92d5eb7e6dd85e (patch)
tree003e0b4dcfd0ff4006e4d45a96b5b7600a0f9396 /README.md
parent9845c4952ab6011e1b8b70a24b7065c2e9c21b7a (diff)
downloadsvg.js-e4fb8522a2c57069b2523f16de92d5eb7e6dd85e.tar.gz
svg.js-e4fb8522a2c57069b2523f16de92d5eb7e6dd85e.zip
IMplemented <use> element, bumped to v0.23
Diffstat (limited to 'README.md')
-rw-r--r--README.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/README.md b/README.md
index 288b651..8a4cb64 100644
--- a/README.md
+++ b/README.md
@@ -226,6 +226,24 @@ text.font({
})
```
+### Use
+The use element simply emulates another existing element. Any changes on the master element will be reflected on all the `use` instances. The usage of `use()` is very straightforward:
+
+```javascript
+var rect = draw.rect(100, 100).fill('#f09')
+var use = draw.use(rect).move(200, 200)
+```
+
+In the case of the example above two rects will appear on the svg canvas, the original and the `use` instance. In some cases you might want to hide the original element. the best way to do this is to create the original element in the defs node:
+
+```javascript
+var rect = draw.defs().rect(100, 100).fill('#f09')
+var use = draw.use(rect).move(200, 200)
+```
+
+In this way the rect element acts as a library element. You can edit it but it won't be rendered.
+
+
## Referencing elements
If you want to get an element created by svg.js by its id, you can use the `SVG.get()` method: