Jump to content

Newbie Question Re: Plugins


captainruss

Recommended Posts

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

Link to comment
Share on other sites

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!

 

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

Here's a plugin.

 

Effects -> Tools -> Copy Selection Coords

<snip>

 

Outputs to Clipboard:

left, top, width, height

 

Edited by toe_head2001
Removed download for outdated plugin
  • Upvote 5

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

  • 2 weeks later...

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 by toe_head2001
Posted code for CodeLab

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

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);
}
Link to comment
Share on other sites

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.

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

  • 2 weeks later...

 

 

Thank you so much for the plugin and your effort Toe_head!  :cake:  :mtdew:

Live as if you were to die tomorrow. Learn as if you were to live forever.

Gandhi

 

mae3426x.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...