How do I move SVG child shapes?
in
Programming Questions
•
2 years ago
I would like to take a child shape from an SVG and draw it in a specific place. Specifically, I have a US Map SVG and would like to be able to select an individual state and draw that state at a place on the screen.
I can choose an individual child to draw, but when I try to translate or place the shape, it still draws it in relation to where the child shape is within the larger SVG.
Here is some example code:
- PShape usa;
- PShape selection1;
- PShape selection2;
- void setup() {
- size(800, 400);
- smooth();
- frameRate(120);
- usa = loadShape("Blank_US_Map.svg");
- }
- void draw() {
- background(255);
- stroke(0);
- selection1 = usa.getChild("MN");
- selection2 = usa.getChild("MT");
- shape(selection1, 0, 0);
- shape(selection2, 0, 0);
- }
If you run this code, the two states, Minnesota and Montana, are drawn according to where they are on the map, instead of both being placed at (0,0). How can I get the child shape to be placed where I want it?
I have tried using Geomerative as well, but cannot get it to work.
Thanks!
1