Gimp-Forum.net
Replicating a path - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+--- Thread: Replicating a path (/Thread-Replicating-a-path)

Pages: 1 2 3 4 5 6


RE: Replicating a path - rich2005 - 12-22-2021

It was yesterday and probably using an invalid transformation, maybe a dragged control point.

New wording ? I don't think any more or less clear than v1

However, a simple transform about the center point gives this:


[attachment=7272]


RE: Replicating a path - Ottia Tuota - 12-22-2021

(12-22-2021, 02:14 PM)rich2005 Wrote: New wording ? I don't think any more or less clear than v1

I must agree with that. Well, thanks for your suggestions anyway. I think I let it be as it is for now, I guess it is not too difficult to use. Everybody seems to get good results with it.


RE: Replicating a path - denzjos - 12-23-2021

I think the path Ottia Tuota is walking on is worth a jewel (click on the image for original scale).
[attachment=7274]


RE: Replicating a path - Ottia Tuota - 12-23-2021

Thanks. I appreciate this. It is just a pensionary's hobby, and the path seems endless, new ideas coming every now and then. I am happy if I can make something useful.


RE: Replicating a path - Ottia Tuota - 01-28-2022

Here is now a plugin that Rich suggested: "Replicate a path along another path". Perhaps it should still be called experimental. The basic usage is shown in the picture:


[attachment=7412]


The main inputs are three paths:
  • Source path
  • Base path (a 2-anchor line segment)
  • Target path
In this picture the Base path is the red line below the Source path. You can imagine that the Base path is mapped repeatedly onto the Target path, and the Source path just follows along. (But the transformed Base is not drawn by the plugin, only the Source.)

The task of the plugin is difficult. Often the results have faults. I shall make a separate post about this later (tomorrow). I don't know how I could help this. It is the user's responsibility to make the input paths such that they work well. To avoid difficulties:
  • Use only gently curving Target paths. Avoid tight bends or fast changing curvatures.
  • Use only smooth Target paths: no sharp points.
  • Make sure that the Base path is close to the Source path and sufficiently long.
And even so, results may need manual corrections. But with reasonable input paths, the results are gratifying.

You can download the plugin from

http://kmarkku.arkku.net/Path_replicate_files/Gimp_master.html

Unzip the .zip file and place the one file it contains (replicate_path_along_path.py) in your user's plug-ins folder. Then (re)start Gimp. Make a new image, and there the three input paths like above. In Gimp's menu, go to the Paths dock, right-click the Source path, and follow the link

Tools > Replicate > Replicate path along another path

and click. That opens the GUI of the plugin. I trust it to be so self-explanatory that you can go experimenting without further explanations.

You may wonder about the input 'tapering' which is in percents. It means this: For example, if you set tapering=10, each created copy of the Source will be 10% smaller than its predecessor. In addition, each copy will have some "inner tapering". Two pictures about this, the first with tapering=10 and the second with tapering=30:

[attachment=7413]

The Source paths are on the left, and the Base paths coincide with their bottom lines.

Often you may wish to touch up the resulting path by joining close stroke ends. The first picture above is an example where it is good to do. You can do it with my plugin in

https://www.gimp-forum.net/Thread-Joining-strokes-of-a-path

or with Ofnuts' plugin Edit > Join strokes, contained in ofn-path-edits.

This new plugin is too complicated for me to have taken care of all failing points. Probably you will soon find cases where you just get some obscure error message. If so, please tell me. And post:
  • The paths you used (an .xcf file)
  • The parameters you used
  • The error message as completely as possible
I don't  guarantee that I could make this much better. The problem is difficult. But I at least can try to correct most blatant errors.


RE: Replicating a path - Ottia Tuota - 01-29-2022

I continue with the plugin "Replicate path along another path". Here I first explain a little the idea behind the plugin. Somebody may be interested. Then I mention some problems you may encounter.

The idea behind the plugin very roughly

Very much simplified the idea is as follows. Let tapering=0. Assume that the Base path is the red horizontal line segment and the Source path is the upright line segment in this picture:

[attachment=7414]

Imagine there a coordinate system where the end points of Base are (0,0) and (1,0). Let (x,y) be the coordinates of the uppermost point of Source. Then the length of Source is y and it is located at x-coordinate x. We should map the Source somehow to the Target as several copies. Let us first look at one copy only. And let us look how the point (x,y) is mapped.

[attachment=7415]

We find on the Target a point based on x and the number of the copy (no details now). From that point we shoot up a perpendicular. From that perpendicular we take a point F(x,y) at distance=y scaled suitably. That point F(x,y) is to where (x,y) is mapped.

And here is the picture when we make several copies. The procedure for each copy is the same except that the chosen point on the Target varies.

[attachment=7416]

And that was the basic idea in how the mapping of points is done. However, this is not nearly all since we are making paths, not raster pictures. But I stop here.

Problems

The next picture tries to show two possible problems:

[attachment=7417]

If there is too tight a bend the pattern starts to fold on itself. This problem is inherent in the task, and solving it would require a completely different approach, a quite different way to do the mapping. And then the resulting paths would look quite different.

If the Target is not smooth the result may be non-sensical. It can even be something very wild. This problem is probably partly due to my implementation.

To avoid such difficulties: In the Target path avoid:
  • too tight bends;
  • anchors where the path is not smooth;
  • zero length handles anywhere;
  • too abrupt changes of curvature, for example "hooks" at stroke ends.
Also, the Base path should be in the close vicinity of the Source path. Abrupt changes of curvature in the Target may cause faults. And faults may appear at stroke ends if the Base is narrower than the Source, as in the following example:

[attachment=7418]

The best remedy is to correct such faults manually, unless one is willing to modify the Target path (in this example it would help to make the Target very straight at the problematic stroke end).

Remark

Gimp has the tool "Text along path". Its working is so similar that I think somebody might have taken its code and made it into a tool "Path along path" or "Replicate path along path". Then no need for anybody to write 2600 lines of Python for the same job. That nobody has done it(?) or published(?) might be due to precisely such difficulties: the tool would not be so nicely behaving that it could be offered as a production version. This is just another guess.


RE: Replicating a path - rich2005 - 01-29-2022

Nice plugin, must have taken much work, and very much appreciated.

On a lighter note, start of "angry Gimp User" maybe for Gimp splash.

[attachment=7419]

The little triangle replicated around the 'circular-ish' path. Path reversed using Ofnuts path tools to render on the inside.


RE: Replicating a path - Ottia Tuota - 01-29-2022

(01-29-2022, 04:07 PM)rich2005 Wrote: Nice plugin, must have taken much work, and very much appreciated.

On a lighter note, start of "angry Gimp User" maybe for Gimp splash.



The little triangle replicated around the 'circular-ish' path. Path reversed using Ofnuts path tools to render on the inside.

Thanks, Rich. Good to hear that it works. The plugin has an option to use the Target path reversed, so no need to use another plugin for that.


RE: Replicating a path - rich2005 - 01-29-2022

(01-29-2022, 04:32 PM)Ottia Tuota Wrote: Thanks, Rich. Good to hear that it works. The plugin has an option to use the Target path reversed, so no need to use another plugin for that.

Indeed it does, totally missed that last option. Wink


RE: Replicating a path - teapot - 01-30-2022

Hi Ottia Tuota,

Thank you so much for this fantastic plugin. It's working really well here and I think it's going to be very useful.

In the past I have also wondered why gimp has "Text along path" but not "Path along path". Co-incidentally a few months ago I went looking to see of there was such a script and didn't find anything either so it's great to see you have implemented this difficult task.

One thing I was puzzled by is when the number of copies is set to 0 I got an empty path, not one with as many copies as there is room.

Setting the length of copies to 0 worked fine so I stuck with that.

Here's a couple of outcomes:

With a target path of a rectangle with rounded corners, distort and finished by a quick edit at the
corners.

[attachment=7420]

The target a hand drawn spiral and no distort.

[attachment=7421]