Hello lovely Inkscapers,
I want to fill a series of given shapes, in this case triangles with parallel lines. Exactly the same effect as the 'Eggbot Contributed - Hatch fills...'
What I want to do next is to base the density of the hatch fill on the average colour value of the pixels behind the shape. A bit complex but I'm sure its possible. For example, triangleX sits over a an image (black and white for simplicity) and the average colour value is 0.1 for example, almost white. Therefore the hatch fill spacing should be high, to leave the triangle relatively white.
And when the average colour behind the triangle is dark or close to black then I want the spacing to be high, to fill the triangle effectively.
The goal of this exercise is to take an image and draw a series of triangles over it and have inkscape fill those triangles with lines that represent the lightness of the image behind.
Maybe such a filter exists?
Thanks for your help... or ideas?
Jeremy
Fill shape with lines
Re: Fill shape with lines
Welcome aboard!
With filtering you can make a hatching that varies the hatches stroke width according to the object luminosity, while those hatch strokes are placed eveny.
What you described is the opposite of this, keeping an even hatch width and varying the spaces in between. Atop that the hatches-rough lpe can create a "centerline" path that a cnc machine can use.
Quite a challenge.
Anyway, if you are interested, here is the mentioned filter:
basic hatch filter
-it uses an image filter primitive so needs a bit of special treatment for actual using. Also made its concept to a three way crosshatch filter.
related topic
With filtering you can make a hatching that varies the hatches stroke width according to the object luminosity, while those hatch strokes are placed eveny.
What you described is the opposite of this, keeping an even hatch width and varying the spaces in between. Atop that the hatches-rough lpe can create a "centerline" path that a cnc machine can use.
Quite a challenge.
Anyway, if you are interested, here is the mentioned filter:
basic hatch filter
-it uses an image filter primitive so needs a bit of special treatment for actual using. Also made its concept to a three way crosshatch filter.
related topic
-
- Posts: 62
- Joined: Tue Jan 19, 2010 6:52 am
Re: Fill shape with lines
I've been looking for something like this for years. The closest I've come is halftoning with tiled clones, but that doesn't work with lines. I've also posterized the image and applied various hatch densities by hand. http://cleversomeday.com/sketchpix/
-
- Posts: 3
- Joined: Sat Apr 01, 2017 10:04 pm
Re: Fill shape with lines
Thanks Lazur and cleversomeday, both useful answers.
But I cant help but feel like its not too hard to make something more automated. I have experience in python but I don't know what scripting language Inkscape uses for custom filters?
Is it feasible to make something like this or am I wasting my time?
Thanks again for the replies
But I cant help but feel like its not too hard to make something more automated. I have experience in python but I don't know what scripting language Inkscape uses for custom filters?
Is it feasible to make something like this or am I wasting my time?
Thanks again for the replies
Re: Fill shape with lines
Just a note that filtering is only rendered on screen, and it won't generate vector content. Inkscape uses the svg spec as a reference to add any custom filters. It *is* automated to use a hatching filter, theoretically you could apply svg filters to videos -and have a hatched video...
it is rendered in a live way, you can update the source image.
Other procedural option is the (live) path effects, however that would need custom compiling to add anything to it. Usually these effects were available as extensions before, which, you "can" add in yours by saving to inkscape's according share library.
Writing a custom extension is way over my head, although there is somewhere a related page at inkscape/wiki (?), not sure.
In general I have doubts if it would be anything easy.
it is rendered in a live way, you can update the source image.
Other procedural option is the (live) path effects, however that would need custom compiling to add anything to it. Usually these effects were available as extensions before, which, you "can" add in yours by saving to inkscape's according share library.
Writing a custom extension is way over my head, although there is somewhere a related page at inkscape/wiki (?), not sure.
In general I have doubts if it would be anything easy.
Re: Fill shape with lines
Writing Extensions: https://inkscape.org/en/develop/extensions/
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Re: Fill shape with lines
Than's Moini, that was exactly I was thinking of!
-
- Posts: 3
- Joined: Sat Apr 01, 2017 10:04 pm
Re: Fill shape with lines
Okay, so it seems writing an extension would be rather difficult without at least breaking it down first.
I'll also add some context to the problem, there might be another way, software or other?
The primary goal is to achieve these 'geometric portrait' images:
I can handle a few manual processes but what I'm doing seems so automatable! So I'll list my steps and maybe you'll see something that could be done faster:
-Creating the base geometry. This has to be manual (in my opinion) but it does not take too long, drawing over an image as a guide. You just have to make sure you create closed triangles for the fill or hatch process to work.
-Sample the average colour from behind the given polygon. This should be automatable for sure!! I just take the eye dropper tool and sample an area of the original image and apply as fill colour for the polygon.
-Apply hatch, with hatch spacing corresponding to fill colour. This is where we need some 1s and 0s magic. The ultimate goal is to have these drawn by a plotter and I know already what spacings should represent what shade. The polygons have a value 0-255, I need this to be converted to a value 0.01-15mm. The slightly complex part here is this is not linear. This is simple sin() maths and I have an equation that I use to give me the correct result, but I have to do this for every polygon. Check its value, 144, convert it to spacing 3.2mm (for example), select hatch angle (this could be random with a seed button eventually) and finally apply the hatch.
When it's all said and done I realise my calculation was off and the dark shades are not dark enough or the light shades are too light!!
I know this is a rather complex problem but a hatch fill extension with a few extra options is what I'm after here.
-Random rotation
-Use fill colour as spacing distance (with max and min options)
-Ability to apply to many polygons at once
Am I dreaming? is this remotely possible?
Anyway, that's my goal, any steps toward the final product are appreciated, even small ones.
Thanks in advance
Jeremy
I'll also add some context to the problem, there might be another way, software or other?
The primary goal is to achieve these 'geometric portrait' images:
I can handle a few manual processes but what I'm doing seems so automatable! So I'll list my steps and maybe you'll see something that could be done faster:
-Creating the base geometry. This has to be manual (in my opinion) but it does not take too long, drawing over an image as a guide. You just have to make sure you create closed triangles for the fill or hatch process to work.
-Sample the average colour from behind the given polygon. This should be automatable for sure!! I just take the eye dropper tool and sample an area of the original image and apply as fill colour for the polygon.
-Apply hatch, with hatch spacing corresponding to fill colour. This is where we need some 1s and 0s magic. The ultimate goal is to have these drawn by a plotter and I know already what spacings should represent what shade. The polygons have a value 0-255, I need this to be converted to a value 0.01-15mm. The slightly complex part here is this is not linear. This is simple sin() maths and I have an equation that I use to give me the correct result, but I have to do this for every polygon. Check its value, 144, convert it to spacing 3.2mm (for example), select hatch angle (this could be random with a seed button eventually) and finally apply the hatch.
When it's all said and done I realise my calculation was off and the dark shades are not dark enough or the light shades are too light!!
I know this is a rather complex problem but a hatch fill extension with a few extra options is what I'm after here.
-Random rotation
-Use fill colour as spacing distance (with max and min options)
-Ability to apply to many polygons at once
Am I dreaming? is this remotely possible?
Anyway, that's my goal, any steps toward the final product are appreciated, even small ones.
Thanks in advance
Jeremy
Re: Fill shape with lines
mulholland wrote:
-Sample the average colour from behind the given polygon. This should be automatable for sure!! I just take the eye dropper tool and sample an area of the original image and apply as fill colour for the polygon.
- That's already implemented in 0.92.1, when you generate the Voronoi diagram:
mulholland wrote:-Apply hatch, with hatch spacing corresponding to fill colour. This is where we need some 1s and 0s magic. The ultimate goal is to have these drawn by a plotter and I know already what spacings should represent what shade. The polygons have a value 0-255, I need this to be converted to a value 0.01-15mm. The slightly complex part here is this is not linear. This is simple sin() maths and I have an equation that I use to give me the correct result, but I have to do this for every polygon. Check its value, 144, convert it to spacing 3.2mm (for example), select hatch angle (this could be random with a seed button eventually) and finally apply the hatch.
- How do you determine the angle? I notice they're all different. Always random?
mulholland wrote:Am I dreaming? is this remotely possible?
- Yes, should be doable. Even for non-polygon objects
The only thing that would need to be added to the hatch fill extension would be the direction randomization (if desired) and the dependency of the line density from the objects' lightness value.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
-
- Posts: 62
- Joined: Tue Jan 19, 2010 6:52 am
Re: Fill shape with lines
Just wondering if you have made any progress on this @mulholland or anyone else. The iOS app imaengine hatch filter does some things similar to this. See also the Trimaginator app.
Re: Fill shape with lines
Why not make this effect with a Patternfill ?
Prepare a bunch of custom patterns that represent different levels of grey and you are good to go.
Its flexible and easy on the processor.
Prepare a bunch of custom patterns that represent different levels of grey and you are good to go.
Its flexible and easy on the processor.