# How to convert object fill in to fine lines?

I am trying to find a way to convert a solid object fill in to millions (more or less) lines? for example:

I am okay to use any tools but ideally I want output in SVG format (not necessary tho)

Magnified view:

This is a partial solution for Inkscape. Another answer for Illustrator shows how one can use the Scribble effect in a non-random way and get the wanted straight line zigzag fill and the result needs only some minor manual fixes (=gap fills if the shape is complex)

Inkscape hasn't such effect. It has a Path effect which generates coarse hatch fills, but the result is very coarse. In theory it could make the same as Illustrator's Scribble, but it simply doesn't have the needed adjustability and accuracy.

The questioner gave in a comment one hint: There's 3rd party extension by a plotter manufacturer (=EggBot) which can generate some resembling fill patterns. I skip them because I haven't them. I tried to get them, but the installation stopped, because my Inkscape isn't installed in a standard way.

If your shape is vertically symmetric so that the upper half can be presented in XY coordinates as Y=f(x) where f is a formula written with Python math functions and operators, you can plot the zigzag fill with Inkscape's Function Plotter extension. As an example we check your circle.

I must cheat a little, because the exact formula for a triangular zigzag curve is complex. It needs tricky modulo arithmetics. I do not know how to write it with Python's functions. A competent programmer probably could say it in a second.

But Python has some generally known (=same as in Excel) elementary math stuff such as sine, pi and squareroot. I use them, because the resulted curve can be converted to straight lines later.

High zoom view shows that it's actually a soft curve:

To make it draw a square and goto Extensions > Render > Function Plotter. I selected the square presents x and y ranges both from -1 to +1.

The function is taken from electronics. It's amplitude modulated sine (no carrier!). The envelope part sqrt(1-x*x)is a half circle. The last number 40 defines that there's 40 full cycles of the sine curve i.e. 40 top and bottom peaks. It has defined to have total 161 nodes in the approximate. There's a node in every zero crossing and peak.

If you want more, say 100 full cycles, you must change 40 to 100 and 161 to 401.

If one converts all nodes to corner points, he gets the triangular form without calculations. Extension Modify Path > Flatten Bezier does the job. Here's an example of flattening:

You should apply Flatten and then select all zero line nodes except the leftmost and the rightmost with the none tool and press DEL. Then flatten again and you are done - only straight lines, no extra nodes:

Save it as plain SVG to drop out all Inkscape's own parts (there should be none because the result is a path, it has no functions).

I guess the function plotting method is not practical, so I try something else. If straight parallel lines are accepted fill (=no zigzag), one can tile a bunch of lines and either set a clipping mask or split the lines destructively with a shape

Inkscape has several ways to create a bunch of straight lines

• tiled cloning (must be relinked if one wants to split the lines)
• Path effect Interpolate Subpaths
• Extension generate from Path > Interpolate

The 3rd method is simplest. It generates the intermediate lines as a group:

The lines should be ungrouped and combined (Path > Combine) to keep them surely as one object. Groups are easily corrupted because their members can still be selected independently. In addition many path operations do not work with groups, they need a single paths or combined paths.

The next image shows the result when a shape is placed on the lines and Object > Clip > Set is applied:

The clipping can be taken back any time, the original parts are there intact, only partially hidden. There's no way to snap anything to the apparent end of the line, because there's no node. For this the lines must be split destructively or no clipping should be made. Snapping to path intersection works very well in Inkscape.

We can utilize the snapping by drawing the triangular zigzag with the pen:

The blue zigzag is made with the pen by clicking only, one click per one crossing point. It took about one minute. The blue zigzag is an independent single path.

If it's disturbing that half of the line segments s are vertical and the other half are tilted, it's fixed by rotating the lines before drawing the zigzag.

A question arises "If one splits the lines for ex. with Path > Cut path, can the pieces be combined somehow automatically, not one by one, to a zigzag. In theory YES. But there are difficulties which make the result unsure.

At first we split the lines with the same black curve. A top shape really splits the underlying lines if they are combined (Path > Combine). The remnants can be selected and removed easily by using the normal selection tool in "select if touched"-mode (=Alt+Drag):

Then we can select the bottom end nodes of all lines and try node function Join selected nodes. The result is unfortunately unexpected:

All node joining end connecting operations, when bunched, select the order unpredictably. The connections must be done one by one. Its much easier to draw the zigzag with the Pen as shown above.

• Awesomely perfect, I does the job as per example and just the perfect output I wanted it, just one trouble what if the output shape required is rectangular or some irregular shape!
– M V
Jun 23, 2019 at 12:35
• You can use the scribble effect in illustrator it does a way better job than you describe Jun 23, 2019 at 12:57
• @user287001 Thanks a millions for your attention and heads-up. It does the job! However, just to add another tip EggBot >> Hatch Fill also can be used but it needs to join lines to make zigzag lines patten.
– M V
Jun 23, 2019 at 13:01
• @joojaa Thanks for response, but scribble effect is random and dont have single path which is needed.
– M V
Jun 23, 2019 at 13:04
• @MV you can edit the settings so to remove randomness. And you can then join the errant gaps. Jun 23, 2019 at 13:07

Illustrator scribble effect does much what you are asking for

Just apply scribble onto the path fill. Then adjust the scribble settings to have 0 variation.

Then because this is a live effect, you need to expand it with Object → Expand Appearance

Now Scribble does measure the distance between seed points a bit differently than your example. This may or may not be a problem, its not so accurately described in the problem setting.

• Wow, only now I learned about scribble settings, a big thanks :-)
– M V
Jun 23, 2019 at 13:29

If you can find a way to mathematically describe the envelope of your shape, you could multiply the function by `sin` with a short period. For the disk example, `sin(100*x) * sqrt(1 - x**2)` seems to work fine:

Here's a live example, in which you can change the parameters with sliders.

It's possible to plot a function as SVG from gnuplot, matplotlib, or this website.