I recently asked a question on Graphic Stack Exchange about a way to redraw a given object's borders based upon a triangular grid. I do not have programming skills, so the answer, despite being very insightful, is somehow arabic to me (or any other language I do not speak...). I even wrote an e-mail to the owner of the blog I was given the link of (please see below), but again, in order to be able to put in practice the advice, I would need to have some knowledge of coding and I have very little time to make that happen. So I wanted to ask the Inkscape community if it would be possible to develop a plugin for such need, as probably some other people may have the same need. At the same time, I thought that this tool could also take in consideration a normal square grid (or, actually, any kind of grid). Do you think it would be possible?
Thank you anyway 🙂
Interesting question. I think you could break it down into these steps:
Loop over all the triangles, and decide if each one is inside the shape or outside the shape. For this you will need a way to get the x,y center of a triangle. Then you will also need a way to determine whether that x,y point is inside or outside the shape. In the case of a circle you can do a distance test, but it will be different for each type of shape.
Loop over all the edges between two triangles, and look at the two triangles. If they are both inside, or both outside, then you do not draw a line. But if one is inside and one is outside, then draw a line. For this you will need to find all edges, but also determine which triangles are on the sides of that edge.
For step 2 you may find my triangle grid page useful http://www-cs-students.stanford.edu/~amitp/game-programming/grids/ . There are three types of edges between two triangles, and on that page I label them West / , East \ , South –. I don't have a programming guide for this though; I've never worked with triangle grids the way your problem requires.
yes, but if I had an object with hundreds of points, I would have to draw them one by one (which is exactly what I was doing, by using the snap functions to be precise). However, I was looking for something that could automate the process, given also the fact that the spacing could be very small in order to allow some sort of higher resolution.
Let's say you made tiled clones that pick up the color of the object. They could be unioned to create one object having the triangle points at the edges, but you would need to decide where the cutoff is... a partial overlap by the clone results in an average of the objects color.
@TylerDurden , thank you, this seems a very interesting method. However, I am failing to get the same result you are showing. I set the triangle (basis for clone tiles) with a 60° rotation, but the overlapping area is not like the one you are showing. I set the the tiles fill with a transparency below to see it.
I transformed the tiles into Path, and the made Union, but as a result I had just a black area.
My understanding of your advice is that I would select the overlapping area based on a certain color, is that correct? How would you advise I could do that, maybe by coloring another dummy object with such color and then select same fill?
Once there is a collection of colored clones, they can be unlinked and ungrouped, some may be a shade of the original color... the level of cutoff to union the tiles will need to be decided. This may or may not work for you, but it might be a path to explore.
yes, this solution is very interesting and the closest to a what I am looking for. I noticed it is quite demanding in terms of memory, and sometimes I get different results (on my home computer, running on Debian Linux, I do get the tiles close to each other, on my working one, Windows 10, i keep on getting empty triangles in the middle, these kind of stars, in red), yet the settings are exactly the same. What could be the reason? I had to reset everything many times in order to get the tiles close to each other, but on Windows it is always unsuccessful. On both computers I have Inkscape 1.0.
Apart from that, I have also noticed (..Settings3.png) that the color of tiles has to be controlled by putting another shape of different color underneath the one I want to get the projected borders from (...4.png).
In order to make the process lighter on the computer, once I get the tiles, because my aim is to get the border, I have transformed the stroke to a path, so I can select both the outside and the inside of the shape and delete the unwanted tiles (...5.png). In this way, I get less objects to deal with. Still, it took around 5 minutes on my home computer (4G RAM) to produce 200x200 tiles.
The problem left (apart from the inconsistency in behavior of the program between the two operating systems) is the selection of the resulting tiles that I want to keep. I have looked around and, unfortunately, there is not yet a fuzzy selection tool (https://gitlab.com/inkscape/inbox/-/issues/449). That is actually the only bottleneck I found in this method. But I am very grateful for your help, this has been already a great advance.🙂
I think I found a way to fast select more of the wanted triangles, with the built in bucket paint, that has a threshold. The credit goes to my 5 years old son, he was drawing today and while experimenting with the the tools he colored areas of a radial gradient, discovering as lines the boundaries between different colored areas.
At this point questions, what colors and/or settings would be best to have a finer selection?
Searching for red on yellow was even better, and I can just set border to path to have the lines of the projected perimeter as needed. How could I clean up unneeded nodes between straight lines recursively, once I have removed the easy excessive ones? Simplifying makes random selection it seems, or can I somehow setup a 60° parameter to keep nodes before doing it?
Going back to the selection of the colors, the scales are based on 100, not 255, should I make a proportion to find the (most opposite?...) color and enhance the difference?
Sure I did, I didn't mention it :) maybe I could put the two things together and use this as helper to choose rapidly. For the idea I have, the shapes could be very large and full of points and I would like to keep down the manual process. I will try with the zoom, maybe the selection becomes even finer.
whichever method I choose, there will be extra nodes (i.e. 180° ones) that would not be necessary. Would it be possible to select them and delete them all at once, thus simplifying the path without losing its shape?
Presuming that the region will eventually be contiguous with its perimeter following the triangular grid, yes. Nodes along a line can be removed. That may cause the segment to become technically a curve (endnodes having Bezier handles), but that is easily remedied.
Hello Tyler, thank you. I should have mentioned, "bulk removal"... Is there a way to select only the flat ones (and then Ctrl+A and straighten the segments)?
I had a rather good result with blue on yellow, with threshold at 60.
Hello all,
I recently asked a question on Graphic Stack Exchange about a way to redraw a given object's borders based upon a triangular grid. I do not have programming skills, so the answer, despite being very insightful, is somehow arabic to me (or any other language I do not speak...). I even wrote an e-mail to the owner of the blog I was given the link of (please see below), but again, in order to be able to put in practice the advice, I would need to have some knowledge of coding and I have very little time to make that happen. So I wanted to ask the Inkscape community if it would be possible to develop a plugin for such need, as probably some other people may have the same need. At the same time, I thought that this tool could also take in consideration a normal square grid (or, actually, any kind of grid). Do you think it would be possible?
Thank you anyway 🙂
Good chance I don´t understand your needs - but an "Axonometric Grid" like you can generate from the Document Preference won´t work for you?
Hello PixelPest,
yes, but if I had an object with hundreds of points, I would have to draw them one by one (which is exactly what I was doing, by using the snap functions to be precise). However, I was looking for something that could automate the process, given also the fact that the spacing could be very small in order to allow some sort of higher resolution.
Let's say you made tiled clones that pick up the color of the object. They could be unioned to create one object having the triangle points at the edges, but you would need to decide where the cutoff is... a partial overlap by the clone results in an average of the objects color.
@TylerDurden , thank you, this seems a very interesting method. However, I am failing to get the same result you are showing. I set the triangle (basis for clone tiles) with a 60° rotation, but the overlapping area is not like the one you are showing. I set the the tiles fill with a transparency below to see it.
I transformed the tiles into Path, and the made Union, but as a result I had just a black area.
My understanding of your advice is that I would select the overlapping area based on a certain color, is that correct? How would you advise I could do that, maybe by coloring another dummy object with such color and then select same fill?
The checkbox in the Clones Trace tab needs to be ticked, and the original object needs to have its fill unset.
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Tiles-Trace.html
Related: http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Tiles-Symmetries.html
Once there is a collection of colored clones, they can be unlinked and ungrouped, some may be a shade of the original color... the level of cutoff to union the tiles will need to be decided. This may or may not work for you, but it might be a path to explore.
e.g. The completely black tiles can go, but the shaded ones need to be picked.
Once you decide on which shaded objects will stay, they can be unioned.
HI again,
yes, this solution is very interesting and the closest to a what I am looking for. I noticed it is quite demanding in terms of memory, and sometimes I get different results (on my home computer, running on Debian Linux, I do get the tiles close to each other, on my working one, Windows 10, i keep on getting empty triangles in the middle, these kind of stars, in red), yet the settings are exactly the same. What could be the reason? I had to reset everything many times in order to get the tiles close to each other, but on Windows it is always unsuccessful. On both computers I have Inkscape 1.0.
Apart from that, I have also noticed (..Settings3.png) that the color of tiles has to be controlled by putting another shape of different color underneath the one I want to get the projected borders from (...4.png).
In order to make the process lighter on the computer, once I get the tiles, because my aim is to get the border, I have transformed the stroke to a path, so I can select both the outside and the inside of the shape and delete the unwanted tiles (...5.png). In this way, I get less objects to deal with. Still, it took around 5 minutes on my home computer (4G RAM) to produce 200x200 tiles.
The problem left (apart from the inconsistency in behavior of the program between the two operating systems) is the selection of the resulting tiles that I want to keep. I have looked around and, unfortunately, there is not yet a fuzzy selection tool (https://gitlab.com/inkscape/inbox/-/issues/449). That is actually the only bottleneck I found in this method. But I am very grateful for your help, this has been already a great advance.🙂
Ok, here's another approach using the Alt key to select objects:
PS those clones are on an Isometric grid turned 90 degrees, since I only know how to make tiled triangles that way. 😟
HI :),
I think I found a way to fast select more of the wanted triangles, with the built in bucket paint, that has a threshold. The credit goes to my 5 years old son, he was drawing today and while experimenting with the the tools he colored areas of a radial gradient, discovering as lines the boundaries between different colored areas.
At this point questions, what colors and/or settings would be best to have a finer selection?
Thank you for giving the right direction! :)
Searching for red on yellow was even better, and I can just set border to path to have the lines of the projected perimeter as needed. How could I clean up unneeded nodes between straight lines recursively, once I have removed the easy excessive ones? Simplifying makes random selection it seems, or can I somehow setup a 60° parameter to keep nodes before doing it?
Going back to the selection of the colors, the scales are based on 100, not 255, should I make a proportion to find the (most opposite?...) color and enhance the difference?
The bucket tool makes new objects with each use, and its precision is variable depending on color and level of zoom.
I'd advise exploring the last example I shared (Alt+drag), which selects the actual objects which are created precisely by the cloning.
Sure I did, I didn't mention it :) maybe I could put the two things together and use this as helper to choose rapidly. For the idea I have, the shapes could be very large and full of points and I would like to keep down the manual process. I will try with the zoom, maybe the selection becomes even finer.
Hi again,
whichever method I choose, there will be extra nodes (i.e. 180° ones) that would not be necessary. Would it be possible to select them and delete them all at once, thus simplifying the path without losing its shape?
Presuming that the region will eventually be contiguous with its perimeter following the triangular grid, yes. Nodes along a line can be removed. That may cause the segment to become technically a curve (endnodes having Bezier handles), but that is easily remedied.
Hello Tyler, thank you. I should have mentioned, "bulk removal"... Is there a way to select only the flat ones (and then Ctrl+A and straighten the segments)?
I had a rather good result with blue on yellow, with threshold at 60.
I'd try Path>Simplify with a very low value. e.g. 0.0015.