I have an svg file with multiple levels of hierarchy. <g> within <g>, and different elements such as <polygon>, <polyline>, etc within each group. My goal is to create a function that will return me all children elements as RShapes in a simple single array format.
Then, return each shape one level up, store them all in a single array and return it. It sort of makes sense to me conceptually but I’m having difficulty implementing it.
I know that there are some recursion examples like drawing a tree, but I feel just running functions like line() recursively and having to return some data and track them like I’m trying here are somewhat different.
If you have any example or suggestions, I’d appreciate it.
I did a few tests and it seems working but if anyone has a better solution, please let me know!
can you give a link to an example svg? Or upload a file?
You are on a good path. Just go on.