Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Group of elements in Raphaël

Tags:

raphael

Is there a way to group elements in Raphaël on something like a layer in illustrator? So I can rotate translate delete the whole group.

like image 397
Andreas Köberle Avatar asked Apr 02 '12 21:04

Andreas Köberle


2 Answers

Maybe what you are after is Paper.set()

See: http://dmitrybaranovskiy.github.io/raphael/reference.html#Paper.set

It allows you to group several elements together so you can manipulate them all at once.

like image 146
Matt Esch Avatar answered Nov 23 '22 23:11

Matt Esch


In case you need to have a real element, here is a small plugin. It's kind of old but a beginning:

https://github.com/meszaros-lajos-gyorgy/Raphael-Plugins/blob/master/dev/raphael.group.js

And here is another website which created a small plugin:

http://2hats.net/_box/raphael/grouping.html

The reason why an extra plugin is needed is because Raphaels set() function does not create a real DOM element!

Creates array-like object to keep and operate several elements at once. Warning: it doesn’t create any elements for itself in the page, it just groups existing elements. Sets act as pseudo elements — all methods available to an element can be used on a set.

like image 29
F Lekschas Avatar answered Nov 23 '22 23:11

F Lekschas