captainruss Posted March 14, 2016 Share Posted March 14, 2016 I have used Paint.NET extensively in making instrument graphics for flight simulators. I am brand new to the forum though. I need to place objects by coordinates in the Lua code I write to create these instruments. I need the left. top. width. height valuse to include in functions. Now I copy these values when a rect is selected with the selection tool. The are at the bottom of the window where it says "selection Top Left: <left> <top> and Bounding rectangle size; <width> X <height> Ironically the text says Top Left but the values are reversed but are exactly in the order I need, (see attached pic) I end up writing these values in a piece of paper and later typing then into my scripts. WOULD IT BE POSSIBLE... either via Plug-In that might already exist, a feature I don't know about, or with the addition of a feature TO have some button or contextual menu to copy these four coordinates , comma delimited, into the clipboard. I right click and select a rect area and a contextual menu pops up with "copy coords". Selecting would copy the string " left , top, width, height " (without the quotes of course) into the clipboard so I could paste them. Anyone know if this exists, is possible, or how to get such a feature added to paint,NET? ANyone want to write such a simple plugin if that is possible? Any help greatly appreciated. ps. see our work at www.siminnovations.com Quote Link to comment Share on other sites More sharing options...
david.atwell Posted March 14, 2016 Share Posted March 14, 2016 Not possible by plugins; they can only do effects, adjustments, and filetypes. Not context menus. EDIT: By not possible, I meant the context menus. Good on you, toe, for jumping in so fast! Quote The Doctor: There was a goblin, or a trickster, or a warrior... A nameless, terrible thing, soaked in the blood of a billion galaxies. The most feared being in all the cosmos. And nothing could stop it, or hold it, or reason with it. One day it would just drop out of the sky and tear down your world.Amy: But how did it end up in there?The Doctor: You know fairy tales. A good wizard tricked it.River Song: I hate good wizards in fairy tales; they always turn out to be him. Link to comment Share on other sites More sharing options...
toe_head2001 Posted March 14, 2016 Share Posted March 14, 2016 (edited) Here's a plugin. Effects -> Tools -> Copy Selection Coords <snip> Outputs to Clipboard: left, top, width, height Edited August 5, 2019 by toe_head2001 Removed download for outdated plugin 5 Quote (September 25th, 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...
captainruss Posted March 14, 2016 Author Share Posted March 14, 2016 Ask and Ye shall receive.... in minutes. Awesome...Thanks. I will share with the rest of our instrument builder community. I like this forum! Here's a plugin. Effects -> Tools -> Copy Selection Coords CopySelectionCoords.zip Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted March 25, 2016 Share Posted March 25, 2016 (edited) Here's the source code for those interested. Just a few lines of code (excluding the usually boilerplate stuff). https://github.com/toehead2001/pdn-copy-selection-coords EDIT: Here's the code for CodeLab: void PreRender(Surface dst, Surface src) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); string selectionCoords = selection.Left + ", " + selection.Top + ", " + selection.Width + ", " + selection.Height; Services.GetService<IClipboardService>().SetText(selectionCoords); } void Render(Surface dst, Surface src, Rectangle rect) { dst.CopySurface(src, rect.Location, rect); } Edited August 5, 2019 by toe_head2001 Posted code for CodeLab Quote (September 25th, 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...
BoltBait Posted March 25, 2016 Share Posted March 25, 2016 Here's the source code ... I'm not sure it is a good idea to have an empty Render function. You should probably be writing to the DST surface for every pixel. Something like this: void Render(Surface dst, Surface src, Rectangle rect) { // Call the copy function dst.CopySurface(src,rect.Location,rect); } Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
toe_head2001 Posted March 25, 2016 Share Posted March 25, 2016 I'm not sure it is a good idea to have an empty Render function. You should probably be writing to the DST surface for every pixel... Oh, you're probably right. I've heard that mentioned many times here on the forum. I'd be interested the technical reason for this. What sort of issues could arise from not writing to any of the pixels? Rick seems to have made it somewhat idiot proof, as the original canvas is preserved even though the dst is full of null colors. Just a curiosity, I'll still fix the code. Quote (September 25th, 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...
Seerose Posted April 2, 2016 Share Posted April 2, 2016 Thank you so much for the plugin and your effort Toe_head! Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi 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.