diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2015-10-11 15:20:01 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2015-10-11 15:20:01 +0200 |
commit | 79e050f93709ffa98c071ac9620d79d3d077c32d (patch) | |
tree | ca811db5e8fcb434e9363c1765061637e3a09dfb /README.md | |
parent | 412b37652b6695a6df4c214d7048275f2912dad7 (diff) | |
download | svg.js-79e050f93709ffa98c071ac9620d79d3d077c32d.tar.gz svg.js-79e050f93709ffa98c071ac9620d79d3d077c32d.zip |
added ungroup/flatten (#238), toParent and toDoc
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -1571,6 +1571,43 @@ rect.putIn(group) //-> returns group __`returns`: `element`__ +### toParent() +Moves an element to another parent (similar to add) but remains the visual representation. All transformations are merged and applied to the element. + +```javascript +rect.toParent(group) // looks the same as before +``` + +__`returns`: `itself`__ + +### toDoc() +Same as `toParent()` but with the root-node as parent + +__`returns`: `itself`__ + +### ungroup() / flatten() +Break up the group/container and places all elements in the given parent while remaining their visual representation. The result is a flat svg structure e.g. for exporting + +```javascript +// ungroups all elements in this group recursively and places them into the given parent +// (default: parent container of the calling element) +group.ungroup(parent, depth) + +// call it on the whole document to get a flat svg structure +drawing.ungroup() + +// breaks up the group and places all elements in drawing +group.ungroup(drawing) + +// breaks up all groups until it reaches a depth of 3 +drawing.ungroup(null, 3) + +// flat and export svg +var svgString = drawing.ungroup().svg() +``` + +__`returns`: `itself`__ + ## Geometry ### viewbox() |