NSD Posted November 15, 2020 Share Posted November 15, 2020 The value of the angle of inclination does not matter. Just a True or False flag. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted November 15, 2020 Share Posted November 15, 2020 I don't think so... What is the difference between a square selection that is rotated 45* and a diamond shaped selection made using the magic wand? Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
NSD Posted November 15, 2020 Author Share Posted November 15, 2020 None, except that one shape is rotated and the other is not. Thanks for your answer. Quote Link to comment Share on other sites More sharing options...
MJW Posted November 15, 2020 Share Posted November 15, 2020 As BoltBait also seems to be, I'm curious about what use you'd like to put this information. Unless it's a rectangular selection, why does it matter whether the selection was rotated or not? In what significant way is a rotated non-rectangular selection different from a non-rotated non-rectangular selection? And if you want to check if a selection is an unrotated rectangle, that doesn't seem to be too difficult. You could confirm that the selection matches its bounding box. You've asked this question twice, so it apparently matters to you, but I don't quite see why. EDIT: I remembered that there's a very easy and efficient method to tell if the selection is a singe rectangle, oriented to the X and Y axes, if that happens to be what you want to determine. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted November 16, 2020 Share Posted November 16, 2020 If you are wanting to have an effect (like directional blur, for example) follow the angle you've rotated the selection to, I think you're better off using an angle chooser control. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
toe_head2001 Posted November 16, 2020 Share Posted November 16, 2020 5 hours ago, MJW said: I remembered that there's a very easy and efficient method to tell if the selection is a singe rectangle, oriented to the X and Y axes, if that happens to be what you want to determine. Please share. Quote June 9th, 2023: Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
MJW Posted November 16, 2020 Share Posted November 16, 2020 5 minutes ago, toe_head2001 said: Please share. I believe the following works. Call: Rectangle[] selectionRectangles = EnvironmentParameters.GetSelectionAsPdnRegion().GetRegionScansInt(); This returns a list of rectangles that together cover the selection. If it has only one rectangle, it's a rectangular selection. 1 Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted November 16, 2020 Share Posted November 16, 2020 16 minutes ago, MJW said: If it has only one rectangle, it's a rectangular selection. So, that would be: bool isOneRectangle = EnvironmentParameters.GetSelectionAsPdnRegion().GetRegionScansInt().Length == 1; Quote June 9th, 2023: Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
MJW Posted November 16, 2020 Share Posted November 16, 2020 I think so. I admit I can't say with absolute certainty that it does work. Quote Link to comment Share on other sites More sharing options...
MJW Posted November 16, 2020 Share Posted November 16, 2020 It's definitely true that if there's only one rectangle, it must be a rectangular selection. I believe the converse is also true, but I don't know if I've ever confirmed it. Whenever I've stepped through code calling the routine, it's only returned one rectangle for rectangular selections. The only case I've used it was to determine if I could use a simpler method, so if it had failed, and said a rectangular region was non-rectangular, the only result would be slightly worse performance. Quote Link to comment Share on other sites More sharing options...
NSD Posted November 16, 2020 Author Share Posted November 16, 2020 (edited) Thanks MJW! This code seems to work fine only for rectangular selection: Rectangle sel = EnvironmentParameters.SelectionBounds; //check if selection is tilted Rectangle[] selectionRectangles = EnvironmentParameters.GetSelectionAsPdnRegion().GetRegionScansInt(); if(selectionRectangles[0].X != sel.X) { //selection is tilted } Edited November 17, 2020 by NSD added info Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted November 17, 2020 Share Posted November 17, 2020 That's not a very good way to do that Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
MJW Posted November 17, 2020 Share Posted November 17, 2020 1 hour ago, Rick Brewster said: That's not a very good way to do that Could you please elaborate; or at least clarify whether "that" refers to determining if the selection is tilted (as NSD wishes to do), or to determining if the selection is a non-tilted rectangle (as the method I proposed attempts to do), or to both. If the method I suggested doesn't work because a non-tilted rectangle may produce more than one rectangle in the returned list, an alternate method would be to sum the area of the returned rectangles and compare that to the bounding-box area. I realize there are cases where a minutely-tilted rectangular selection (or similar) could produce a false positive, since the rectangles and bounding box have integer coordinates, but that seems impossible to avoid without access to the actual selection path (the one that can be written to the clipboard). As far as I could determine, that isn't available to plugins, though you once mentioned that you might consider providing it. (I don't see how tilted versus not-tilted is very meaningful for anything but a rectangular selection. I suppose it could have meaning for any symmetric selection, but I can't see to what good use the information could be put.) Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted November 18, 2020 Share Posted November 18, 2020 I'm referring to @NSD's code. You can't just compare X and conclude that the selection is "tilted". Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
MJW Posted November 18, 2020 Share Posted November 18, 2020 33 minutes ago, Rick Brewster said: You can't just compare X and conclude that the selection is "tilted". Thanks. I certainly agree there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.