Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automation questions.
#6
Thank you both for the replies and information. In the end, since these .svg paths are supposed to fit on a grid, I managed to solve the problem by moving every node to the nearest vertex in that 70px grid with a bit of regex (after changing what is selected as well for fewer nodes). I first separate the path coordinates from the rest of the file, and then run a function for each number found in there to translate that node into the vertex:

Code:
coordinates = re.search(r' d="(.+?) Z" />', vector_string.stderr, re.S).group(1)
coordinates = re.sub(r"\d+.\d+", lambda exp: str(round(float(exp.group()) / 70) * 70.0) + '0', coordinates)

With that I ended up with perfectly straight lines right in the center. I have attached a before and after svg to this post (v1 and final respectively) to see the difference.

There are fewer nodes now than before (about half), but still more than needed. As you can see in the examples, there will be 'corners' where up to 5 nodes converge, and only 1 is needed. In the end it will look the same, but since these will be used on a web application that computes lighting based on the path, the extra nodes will take their toll. I'm trying to deduplicate those, but I'm having trouble understanding exactly what I should be checking for in the file for that.

As an example, in the image below you will see 4 points where multiple nodes converge. Only a few nodes will actually form a path that isn't towards the same point of origin (A-D, F-J, L-M), the rest are essentially useless (G-H for example, originates and ends in the same place). I need to remove those without accidentally removing a node that actually goes somewhere forming a visible path. For that I need to understand how GIMP organizes or chains these nodes to form a path.

[Image: b3XOxa2.jpg]

In the 'final' svg you can see near the beginning several 910.00,910.00, also towards the end. How many am I safe to remove?

My thinking is no set of 2 numbers (separated by a comma) should repeat next to an equal set, and that should be enough to remove all duplicates, but I'm not sure. I ramble, and hope you can understand my musings; I would appreciate any insight you may have on this.

Cheers!


Attached Files
.svg   svg_example_v1.svg (Size: 18.34 KB / Downloads: 156)
.svg   svg_example_final.svg (Size: 18.33 KB / Downloads: 147)
Reply


Messages In This Thread
Automation questions. - by PSNick - 10-10-2019, 01:00 AM
RE: Automation questions. - by Ofnuts - 10-10-2019, 07:07 AM
RE: Automation questions. - by PSNick - 10-11-2019, 04:45 AM
RE: Automation questions. - by Ofnuts - 10-11-2019, 06:24 AM
RE: Automation questions. - by rich2005 - 10-11-2019, 08:41 AM
RE: Automation questions. - by PSNick - 10-13-2019, 01:48 AM
RE: Automation questions. - by Ofnuts - 10-13-2019, 09:18 AM

Forum Jump: