Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Selection and canvas bounds?
#1
Is it possible to have the selection extend outside of the canvas?

In some of my plugins I have the following situation: The plugin works on a path. I want to restrict the effect to some part of the path. For this I use a selection. But a path can go outside of the canvas. Does this mean that anchors outside of the canvas cannot be chosen using a selection?
Reply
#2
(06-27-2021, 09:47 AM)Ottia Tuota Wrote: Is it possible to have the selection extend outside of the canvas?
Yes and No.
Yes while using a selection tool you will be able to go outside of the canvas, but what's really selected is on the canvas (marching ants will tell you what's really selected).

(06-27-2021, 09:47 AM)Ottia Tuota Wrote: In some of my plugins I have the following situation: The plugin works on a path. I want to restrict the effect to some part of the path. For this I use a selection. But a path can go outside of the canvas. Does this mean that anchors outside of the canvas cannot be chosen using a selection?

The plugin works on a path ... Which plugin?
by anchors do you mean "nodes" / "control point"? if so, you can select multiple nodes with Shift down then click the control points you need to select, even outside of the canvas

I need you to be more explicit about what exactly you would like to achieve... screenshot are often worth thousands words Wink .
because I can't picture out why you do need to go outside the canvas with a selection on a path ... => what does your plugin do?

Paths can go outside because paths can be used for many purpose other than path, like a guide (for a vanishing point for example) and you can even activate "snap to path"

https://docs.gimp.org/2.10/en/gimp-tool-path.html
Reply
#3
A quick test and I think not without temporarily increasing the size of the canvas, otherwise plenty of error messages.
Using the simple smooth plugin, canvas size increased using crop tool (allow growing mode). https://i.imgur.com/jVukQBf.jpg
Apply to selection. https://i.imgur.com/8RhQfhn.jpg
Revert the canvas back with Image -> Crop to content. https://i.imgur.com/Z7Wd0Pa.jpg

Ofnuts will have more idea.
Reply
#4
(06-27-2021, 11:25 AM)rich2005 Wrote: Ofnuts will have more idea.

Not this time around. The selection mask is always clipped by the canvas.
Reply
#5
I am talking about my three plugins under Tools > Modify path (in the Paths tab): "Round corners", "Simple smooth", and "Simplify"; see the threads:

https://www.gimp-forum.net/Thread-Roundi...-edge-path

https://www.gimp-forum.net/Thread-Smooth...ple-plugin

https://www.gimp-forum.net/Thread-Simplifying-a-path

If you look at the first or third of these threads, there are pictures where the selection is used to restrict the effect to some nodes (and yes, node = anchor).

About selecting nodes by Shift-click: I doubt that that could be done in a plugin?

Thank you Rich, I didn't know that the canvas can be enlargened so easily with the Crop tool. Your method is a good workaround. But it is a little clumsy and an inconvenience in the plugins. But I suppose that is the only way.

About those error messages: They come probably from a certain bug in the plugins. I hadn't remembered this difficulty and hadn't taken it into account in the code. The plugins will be fixed soon. But even with the fixed versions this problem remains: Anchors outside of the canvas cannot be selected without extending the canvas first.

Thanks for the quick replies.
Reply
#6
(06-27-2021, 12:17 PM)Ottia Tuota Wrote: I am talking about my three plugins under Tools > Modify path (in the Paths tab): "Round corners", "Simple smooth", and "Simplify"; see the threads:

https://www.gimp-forum.net/Thread-Roundi...-edge-path

https://www.gimp-forum.net/Thread-Smooth...ple-plugin

https://www.gimp-forum.net/Thread-Simplifying-a-path

If you look at the first or third of these threads, there are pictures where the selection is used to restrict the effect to some nodes (and yes, node = anchor).

About selecting nodes by Shift-click: I doubt that that could be done in a plugin?

Thank you Rich, I didn't know that the canvas can be enlargened so easily with the Crop tool. Your method is a good workaround. But it is a little clumsy and an inconvenience in the plugins. But I suppose that is the only way.

About those error messages: They come probably from a certain bug in the plugins. I hadn't remembered this difficulty and hadn't taken it into account in the code. The plugins will be fixed soon. But even with the fixed versions this problem remains: Anchors outside of the canvas cannot be selected without extending the canvas first.

Thanks for the quick replies.

Oh, now I understand, you are developing a plugin and if people put a control point outside you need to be able to reach it...

I'm not plugin dev.... so I cannot help
But I saw that many plugin rezise the canvas while working (some even when there is nothing outside...)
So I think Rich is right with resizing the canvas to be able to reach what you need outside

If I may suggest...
Short suggestion (a lazy one, has limitation)
Take the width/height of the canvas (image / canvas size) you multiply by 2 (or more) align center, do what you need to do and then divide the canvas width/height by 2 align center at the end...

Longer one, (but cleaner as no limitation)
Take the width/height of the canvas, search the farthest node outside the canvas, resize the canvas proportionally 2-3 pixels bigger than the farthest node, do what your plugin need to do, then resize canvas to original size at the end...
Reply
#7
(06-27-2021, 02:06 PM)PixLab Wrote: If I may suggest...
Short suggestion (a lazy one, has limitation)
Take the width/height of the canvas (image / canvas size) you multiply by 2 (or more) align center, do what you need to do and then divide the canvas width/height by 2 align center at the end...

Longer one, (but cleaner as no limitation)
Take the width/height of the canvas, search the farthest node outside the canvas, resize the canvas proportionally 2-3 pixels bigger than the farthest node, do what your plugin need to do, then resize canvas to original size at the end...

Yes, you are right, that would be the best thing to do. Now it is up to the user to extend the canvas temporarily, and I am not doing about it anything now. Too much work and experimenting for a quick job. But perhaps some  day. Thanks for the idea.

Edit: No, that is impossible after all. The user must make the selection before calling the plugin. And at that point the selection cannot go outside of the canvas and cannot be made large enough to contain some out-of-canvas anchors. Then if inside the plugin the canvas is enlargened, it is of no use - the plugin does not know which anchors the user wanted to select.

So it is Rich's workaround, and it is up to the user to do it.
Reply
#8
Isn't it possible to use the path coordinates (Ofnuts Path summary tool)
- calculate with this values the length of the part outside the canvas
- enlarge the canvas by the calculated value
- make a new dummy layer 
- Image / Fit Canvas to Layers
- delete dummy layer
The path is now on the border of the new layer (canvas)
Reply
#9
But the idea is that the user would choose which part of the path should be manipulated and which part should be kept as it is. That information should be passed to the plugin, and I wanted to use a selection for that purpose. But if the selection is always bounded by the canvas, all out-of-canvas anchors are out of reach. And the user may want some of those out-of-canvas anchors to be manipulated and some others not.
Reply
#10
(06-27-2021, 05:58 PM)Ottia Tuota Wrote: But the idea is that the user would choose which part of the path should be manipulated and which part should be kept as it is. That information should be passed to the plugin, and I wanted to use a selection for that purpose. But if the selection is always bounded by the canvas, all out-of-canvas anchors are out of reach. And the user may want some of those out-of-canvas anchors to be manipulated and some others not.

In your plugin, you can just tell the user that everything outside the canvas cannot be manipulated, and if they want to manipulate the control points outside the canvas they need to temporarily increase the size of the canvas a bit like this plugin (for the help):

   

I found this (see the code below) in the plugin's code, if it can help to write the help (it seems that you don't need to put the octothorp (pound sign, hash), IMHO it's ugly and disturb the reading Big Grin Big Grin )

Code:
register(
    "python-fu-bd", # name
    _(u'''Comic Book
# If black specks bother you in the result, try "despeckle" (Be careful, this generally gives a bad result on buildings).
# If double lines bother you in the result, try "brightness" in "edge desaturation method" (by decreasing a little "parasitic suppression").
# If jagged lines bother you in the result, try "antialias at every flattening" (decreasing strongly "antialias").
# If you want more computer style traits, set "antialias" to 0.
# If you don't like the color change, set "saturation increase" to 0.
# If some colors have rubbed off on neighboring areas, try decreasing "final flattening".
    '''),

(the plugin is there if you want to take a look at the source > https://www.gimpscripts.net/2021/04/phot...lugin.html )

If the user is aware that s/he cannot select the control point outside of the canvas, but s/he can increase the size of the canvas to reach those control point, the user will be happy and should never complain that's it's "not" working Wink
Reply


Forum Jump: