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) |
RE: Replicating a path - teapot - 12-21-2021 Thank you for the script Ottia Tuota My first try: [attachment=7253] RE: Replicating a path - Ottia Tuota - 12-21-2021 Thanks to all who tried the plugin. Here is a new plugin, "Replicate path by affine mapping". The idea is that when you take a path and apply the tools Move, Scalse, Rotate, Shear, Flip to it, then the plugin enables you to do the same action repeatedly in one step, producing a succession of paths. Some quickly made miscellanous examples of what the plugin does: [attachment=7261] The plugin is here: http://kmarkku.arkku.net/Path_replicate_files/Gimp_master.html Unzip the .zip file and place the one file it contains (replicate_path_by_affine_mapping.py) in your user's plug-ins folder. Then (re)start Gimp. The plugin is in the menu here: Tools > Replicate > Replicate path by an affine mapping. I explain the plugin now. But do not expect too much of it. It is rather limited and often what it produces is not what you were trying to get. The plugin is used as follows. As input you give two paths; I call them "the Original path" and "the Seed".
[attachment=7263]
P = the Original path F = the affine transformation (the tools Move,...). Then Seed = F(P), and what the plugin creates are paths F(F(P)), F(F(F(P))), F(F(F(F(P)))), ... As default the plugin merges all output paths together but it allows you to have them as separate paths. A word of caution: It may happen that the transformation F cannot be determined uniquely from the Original path and the Seed. Then the plugin just chooses one from a small number of possibilities, and it may not be what you wanted. The remedy is to put an additional anchor somewhere in the Original path to help the plugin to make the right decision. (And the Seed must be constructed after adding the anchor.) Finally, some playings, together with Path to selection and Bucket fill or Gradient. Sorry if these hurt your eyes, I don't have the same skills as some others. [attachment=7264] RE: Replicating a path - denzjos - 12-21-2021 @Ottia Tuota, nice work to build new tools for using in gimp. Is it possible that there is a bug in the program ? The first item in the menu (The path to be replicated) is just visible after using the plugin one time. [attachment=7266] First activation plugin : [attachment=7267] RE: Replicating a path - teapot - 12-21-2021 Thank you for the great new script Ottia Tuota. It'll take me practice to use effectively but here's an initial try: [attachment=7268] RE: Replicating a path - Krikor - 12-21-2021 (12-21-2021, 05:33 PM)denzjos Wrote: @Ottia Tuota, nice work to build new tools for using in gimp. Is it possible that there is a bug in the program ? The first item in the menu (The path to be replicated) is just visible after using the plugin one time. I experienced something like the one reported by Denzjos. Only after several attempts the first menu item never appeared. Edited: Several attempts and so far the first menu has not been displayed. However the plugin seems to find the "Seed" anyway. [attachment=7269] Edited 02: Ohh... Now I see that there is really no need for this menu, as the "Seed" is actually indicated by the second menu. It seems that the version made available is already an improvement on the one shown in the plugin presentation in this topic. Thx! RE: Replicating a path - Ottia Tuota - 12-21-2021 (12-21-2021, 05:33 PM)denzjos Wrote: @Ottia Tuota, nice work to build new tools for using in gimp. Is it possible that there is a bug in the program ? The first item in the menu (The path to be replicated) is just visible after using the plugin one time. It is my experience that that is how Gimp works. When you call the plugin the first time by right-clicking the path in the Paths dock, then the path does not appear in the GUI. Gimp sets it automatically to be the path the plugin is working on. If you then re-call the plugin by pressing ctrl-shift-F, the path does appear in the GUI. You can then change the path if you like. But: If instead of ctrl-shift-F you do again the right-clicking thing, the path is not shown in the GUI. I guess Gimp thinks that you know what path you want and there is no need to change it. This may be confusing when the plugin needs two paths as input. But I think this is the normal way how Gimp works. Perhaps somebody more knowledgable can confirm or refute. Perhaps the wording in the GUI is not very good. Instead of "Path to be replicated" and "Seed" it would better to call them "Primary input path" and "Secondary input path". I must think about it. Any suggestions? RE: Replicating a path - denzjos - 12-22-2021 @Ottia Tuota, thanks for the explanation. For me, the wording in the GUI is understandable, so that's fine for me. RE: Replicating a path - Ottia Tuota - 12-22-2021 Thanks denzjos. But I decided to change the wording a little: I call the Seed now the Auxiliary path. Perhaps it is clearer that way. The new version 0.2 is here: http://kmarkku.arkku.net/Path_replicate_files/Gimp_master.html No other changes. RE: Replicating a path - rich2005 - 12-22-2021 Ahhh...just made some suggestions [attachment=7270] However, that using the unified transform tool, very easy to move, rotate, scale all in one It is picky about position and I could generate errors when the input and seed had a large separation. Very nice plugin. RE: Replicating a path - Ottia Tuota - 12-22-2021 (12-22-2021, 10:15 AM)rich2005 Wrote: However, that using the unified transform tool, very easy to move, rotate, scale all in one Yes, indeed, I had not noticed the Unified Transform tool. What errors did you get? If it was "No affine transformation was found. Perhaps you chose the wrong transformed path or used in its construction some other tool than Move, Scale, Rotate, Share, or Flip? " then it came from the plugin. The plugin works by examining the two paths and it tries to find out if one is obtained by an affine transformation from the other. Crucial is line 424: ACCEPT_ERROR = 1e-3 and that error limit 1e-3 = 0.001 could be too small, I don't know. It is in pixels. But I tried now the Unified Transform tool and I think that perhaps the question was that you made in the tool some non-affine transformation (that is, Perspective). It happens if you crab the small diamond in some corner. When you use the tool, pay attention to the 3x3-matrix in the top right corner and there look at the bottom row. The bottom row should remain as 0.0000 0.0000 1.0000 and if it changes then the transformation is no longer affine. There is a very good reason why the plugin accepts only affine transformations: it was easy to make. And most importantly the repeated transformations are easy to do, one needs only to map the control points, without creating any approximate Bezier curves. But I think I know how to make rather easily a similar plugin that accepts Perspective transformations if we restrict it to straight-edge paths. And then, if we want to generalize that further, to accept curved paths, then we need some approximation algorithm and that means harder work. Who knows, perhaps later? |