Jump to content

Newbie Question Re: Plugins


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

  • 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
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);
}

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

 Share

×
×
  • Create New...