Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chopping a path
#1
I made two plugins to chop the strokes of a path to smaller pieces. One is old, one is new.

To get the plugins, go to

http://kmarkku.arkku.net/Path_chop_files...aster.html

and click the Download button. Unzip. Put the file chop_path.py in the user's plug-ins folder. Restart Gimp. In the Paths tab, right-click the path you want to chop. Follow the links

Tools > Chopping > ...

There you see two plugins:
  • Chop the path at its anchors
  • Chop the path by another path
I explain now both a little.

Chop the path at its anchors

This is the old one but now it is in a different place in Gimp's menu. Also the wording of the GUI and the default action are a little different. The plugin chops the strokes of the path at the anchors, producing 2-anchor strokes. The default differs from what it was before: now the default is to make one path, so that the effect is to chop the strokes of the path into small 2-anchor strokes. Optionally you can make all the 2-anchor strokes into separate paths.

Chop the path by another path

In this plugin we have two paths: the one to be chopped and another path. The action is that the strokes of the path are chopped into shorter strokes by cutting them at the crossing points with the other path. Optionally all the shorter strokes can be made to separate paths each.

Example 1

On the left the red path has 1 stroke with 4 anchors. That path we want to chop. There is another path (blue), and that is the chopping path.

   

In the middle picture the plugin has been applied: The red path is chopped by the blue path. You see there 3 new anchors at the crossing points; those 3 anchors are in fact double anchors and stroke ends. The red stroke has been cut into 4 shorter strokes, so the path consists now of 4 strokes. To show that they are indeed 4 separate strokes, I moved their ends a little apart, on the right.

Example 2

A spiral chopped to pieces. To begin with, the spiral (red) is one stroke. It is chopped by the fan of lines (another path, blue).

   

After chopping, the spiral consists of 48 strokes, on the right. In this picture the spiral is chopped into 2-anchor strokes, and I grabbed and moved 3 of them to show that they indeed are separate strokes.

In this example the new short strokes happen to have only 2 anchors each (the end points). But since the plugin preserves all original anchors, in general you often get strokes with more than 2 anchors. If needed, you can try to get rid of some anchors with the Simplify plugin.

The ordering of the strokes follows the original spiral. The plugin enables you also to make separate paths instead of one path with several strokes.

Example 3

You can also use the plugin to chop a path by itself. On the left we have a red path, one stroke with 3 anchors. In the middle picture the path is chopped by itself. This means that the stroke has been cut at the crossing points. On the right I moved the stroke ends a little so that you can see how the cuts are done. Now there are 5 strokes.

   

For those interested: To do this plugin I had to compute intersections of two Bezier curves. I implemented the "interval subdivision algorithm" in Section 7.6 of:

https://scholarsarchive.byu.edu/cgi/view...ext=facpub

And that was the easy part in the work.

If the plugins do not work as supposed, please report.
Reply
#2
Nice, I have already some new ideas with this. Thanks.
Reply
#3
@Ottia Tuota, tried to chop a lissajous (see image) but the plugin hangs (no error on display).

   
Reply
#4
(10-08-2021, 08:15 AM)denzjos Wrote: @Ottia Tuota, tried to chop a lissajous (see image) but the plugin hangs (no error on display).

Works for me. I assume you tried "Chop the path at its anchors" since you don't say otherwise. Will you please try again and tell exactly what you do.

The following is off-topic: That Lissajous figure seems to have two not so nice features, though neither causes error for me in chopping.

First, there are clusters of very close anchors. That is due to my amateurish algorithms. Applying the Simplify plugin before chopping seems to be good.

Second, the curve is double. The reason is those two sharp points at top right and bottom right, call them A and B. The curve starts at A, runs the whole long curve to B, there turns around, and runs the same way back to A. The reason why it is so is that a general Lissajous figure, when there is no damping, is a closed curve, and I made the plugin so that exactly one cycle is run. But then there are those special cases with two sharp points where one cycle makes a double curve. I didn't try to give them any special treatment.

Edit: With the Simplify plugin you may want to use a selection to restrict the action to the anchor clusters. Otherwise you may lose more anchors than you like.
Reply
#5
The plugin that I tried was 'chop the path by another path'. Your example 3 in the earlier post give me that idea. Because you mentioned the were 2 connected paths in the lissajous I give it another try after I split the lissajous in two paths.
Reply
#6
(10-09-2021, 10:45 AM)denzjos Wrote: The plugin that I tried was 'chop the path by another path'. Your example 3 in the earlier post give me that idea. Because you mentioned the were 2 connected paths in the lissajous I give it another try after I split the lissajous in two paths.

Ok, I get the same result: the plugin just goes silent and does not finish(?). I tried with another Lissajous figure without sharp points, and there the plugin worked all right. Also chopping one figure with sharp points by another figure with sharp points worked all right. The fact that they were double curves didn't matter. You happened to find a problem case. I must investigate this.

Edit: On the other hand, when I take a problem case (Lissajous 2,3,0) and first delete half of it so that the curve is no longer double then chopping the curve with itself works all right. Well, I must try to find the cause for the error.
Reply
#7
(10-09-2021, 10:45 AM)denzjos Wrote: The plugin that I tried was 'chop the path by another path'. Your example 3 in the earlier post give me that idea. Because you mentioned the were 2 connected paths in the lissajous I give it another try after I split the lissajous in two paths.

I updated the special_curves plugin so that double Lissajous curves should appear no more, see:

https://www.gimp-forum.net/Thread-Parame...9#pid26099

This fixes this problem with the Lissajous figures. But the problem in the chopping plugin remains.
Reply
#8
No problem here to chop the lissajous: first 'Tools / Modify Path / Simplify', chop the 'Tools / Chopping / Chop the path by another path' and 'Edit / Break path apart'. Thank you Ottia Tuota.


Attached Files Thumbnail(s)
   
Reply
#9
(10-10-2021, 03:18 PM)denzjos Wrote: No problem here to chop the lissajous: first 'Tools / Modify Path / Simplify', chop the 'Tools / Chopping / Chop the path by another path' and 'Edit / Break path apart'. Thank you Ottia Tuota.

Great. But isn't that 'Edit / Break path apart' separating strokes to different paths? In the chopping plugin you get the same result by setting "Keep the chopped parts as one path?" to "No". Admittedly it could be said more clearly.
Reply
#10
@Ottia Tuota, I just used the 'break path apart' plugin to visualise that the chop is done the right way. Also, I have to break the paths apart to use the 'Render / Mass render / Stroke line on paths'. This way it is easy to choose parts of the path that I want to give a specific color.
Reply


Forum Jump: