Rick Brewster

CodeLab v4.3 (for advanced users) Released July 13, 2019

Recommended Posts

I may eventually change the Texture Shader to a VS project. The only reason I don't usually make VS plugins is that I prefer to make the code easily available, and if other people are like me (which they may not be), I'm more likely to experiment with plugins I can build in CodeLab the ones that I've got to make a VS project for.

 

I think having the control change the position without showing any change in the control values might be somewhat confusing. Maybe Rick will consider adding some precision control to the double vector control, or just make it three places, which I think is more useful than two.

Share this post


Link to post
Share on other sites

I have a suggestion for CodeLab which I think would be a very useful, but which I suspect may have already been considered and rejected. What I'd like is some way to call a method from OnSetRenderInfo. Something like:

In generated code:

protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs)
{
    Amount1 = (byte)((int)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.Amount1).Value);
    Amount2 = (byte)((int)newToken.GetProperty<StaticListChoiceProperty>(PropertyNames.Amount2).Value);
    Amount3 = newToken.GetProperty<DoubleProperty>(PropertyNames.Amount3).Value;
    Amount4 = newToken.GetProperty<Int32Property>(PropertyNames.Amount4).Value;
    Amount5 = newToken.GetProperty<BooleanProperty>(PropertyNames.Amount5).Value;

    InitializeRender(dstArgs.Surface, srcArgs.Surface);
    base.OnSetRenderInfo(newToken, dstArgs, srcArgs);
}

In user code:

void InitializeRender(Surface dst, Surface src)
{
      .
      .
      .
}

The addition of the call in OnSetRenderInfo could either be based on detecting the presence of a method with a distinctive name (in my example, "InitializeRender"), or by a flag in the comment at the top of the CodeLab code.

 

Currently, computing  the setup values based on the UI variables must be repeated for every ROI, even though generally the computed values are always the same. I've written a number of plugins where the setup computations are complex, and probably add significantly to the time to process each of the many ROIs. There are also operations in some plugins that need to be done once; for instance, computing the average color of the selection.

 

Adding this feature would provide flexibility for those who want to use it, and would be invisible to those who don't.

Edited by MJW

Share this post


Link to post
Share on other sites

MJW, I could code up something like what you want, but it wouldn't work when inside of CodeLab.

The problem is that when tinkering with a CodeLab script from within CodeLab it doesn't have a UI and therefore the OnSetRenderInfo method never gets called.

EDIT: I suppose I could hack something together, I'll think about it...

EDITEDIT: Looking around inside of the CodeLab source, I just noticed a bug in the "using" statement handling code. :roll:

EDITEDITEDIT: Bah! I tried some things and couldn't get anything to work.

Share this post


Link to post
Share on other sites

I admit, I didn't consider whether it would work within CodeLab. I'd be happy to live with, and work around, that limitation, but I'm not sure if it would make the solution a little too messy to be released.

 

EDIT: I realize this is making it more and more complex, but might it be possible when CodeLab initiates running the plugin, it could call the InitilaizeRender function first. I can't recall how that stuff works (and perhaps never knew).

Edited by MJW

Share this post


Link to post
Share on other sites

EDIT: I suppose I could hack something together, I'll think about it...

EDITEDIT: Looking around inside of the CodeLab source, I just noticed a bug in the "using" statement handling code. :roll:

EDITEDITEDIT: Bah! I tried some things and couldn't get anything to work.

^^ this is a development cycle I can relate to :D

Share this post


Link to post
Share on other sites

If I leave the Description box empty when compiling to DLL, it will generate a description without telling me.

 

The description will read as: Menu Name + " selected pixels"

 

ex: The DLL for my 'Text Window' plugin has the description of "Text Window selected pixels" in paint.net, even though the description box was left empty in CodeLab.

Share this post


Link to post
Share on other sites

CodeLab 2.7 Released

This is only for Paint.NET 4.0.6+!

Changes:

▪ UI controls now have custom types. This means the Angle control can now have a specified default angle instead of always 45. (Requested by MJW)

▪ Cleaned up all of the File New template code generation for the new types.

▪ Fixed the Intellisense code to work better with UI variables.

▪ Fixed a couple of dialog box issues.

 

 

Grab the CodeLab DLL here:

http://www.boltbait.com/pdn/CodeLab/

Conversion:

You can open and work with older style scripts without a problem. If you want to convert an older script to the new style, just open it in CodeLab and press Ctrl-I, Enter. This will open the UI Designer and update the UICode block.

Example:

The older UI control block looked like this:

#region UICode
int Amount1 = 4; // [0,100] Shadow radius
Pair<double, double> Amount2 = Pair.Create( 0.02 , 0.02 ); // Offset
ColorBgra Amount3 = ColorBgra.FromBgr(0,0,0); // Shadow color
double Amount4 = 0.5; // [0,1] Shadow strength
bool Amount5 = false; // [0,1] Keep shadow only
#endregion
The new UI Custom Types look like this:

#region UICode
IntSliderControl Amount1 = 4; // [0,100] Shadow radius
PanSliderControl Amount2 = Pair.Create( 0.0 , 0.0 ); // Offset
ColorWheelControl Amount3 = ColorBgra.FromBgr(0,0,0); // Shadow color
DoubleSliderControl Amount4 = 0.5; // [0,1] Shadow strength
CheckboxControl Amount5 = false; // [0,1] Keep shadow only
#endregion
  • Upvote 5

Share this post


Link to post
Share on other sites

CodeLab 2.7 in Russian

You can find the new version of CodeLab in Russian here.

Вы можете найти новую версию CodeLab на русском языке здесь.

Edited by ReMake
  • Upvote 1

Share this post


Link to post
Share on other sites

In first post there is written that CodeLab could perform complicated filters and render fractal. Can be there a tutorial on how to do that. Which tells how to create a filter which is fully made in Codelab instead of just calling PDN's inherent Effects.

Share this post


Link to post
Share on other sites

In first post there is written that CodeLab could perform complicated filters and render fractal. Can be there a tutorial on how to do that. Which tells how to create a filter which is fully made in Codelab instead of just calling PDN's inherent Effects.

Why are you opposed to calling paint.net's built-in effects as part of an effect?

Share this post


Link to post
Share on other sites

CodeLab 2.8 Released

This is only for Paint.NET 4.0.6+!

Changes:

▪ Install.bat files are now good enough to ship with your .dll files.

 

 

Grab the CodeLab DLL here:

http://www.boltbait.com/pdn/CodeLab/

Notes:

In the past, when you saved an effect to a .dll file, the .dll file was placed on your desktop and a small install.bat file was also put on your desktop to simplify the act of installing the effect into paint.net. This batch file was customized for your system and was not suitable to ship with your effect.

With this build of CodeLab, these install.bat files are flexible enough to be shipped with your effect. Just zip up the .dll file along with the install.bat file and distribute that package.

I'm sure that plugin pack owners will be smart enough to modify the install.bat file to install all effect plugins, filetype plugins, and shapes included in their plugin packs. I'm off to do that very thing with my plugin pack. In fact, mine even installs a palette file.

Anything that makes installing effects easier is a huge step forward!

  • Upvote 1

Share this post


Link to post
Share on other sites

I got this plugin before school this morning and because of that made this account and plan to make effect plugins for PDN. Don't know when I will chack back on this comment but for when I do, here's my question.

 

Would I have to put some credit for CodeLab in my plugin page and such (though I think I will anyway), or are you fine if I forget to?

Share this post


Link to post
Share on other sites

Would I have to put some credit for CodeLab in my plugin page and such (though I think I will anyway), or are you fine if I forget to?

Nope, no credit required.

BTW, when you are ready to learn how to code plugins, check out this series of tutorials:

http://boltbait.com/pdn/CodeLab/help/

Share this post


Link to post
Share on other sites

Awesome! Made a rather iffy cell-shader already...

spray.png -> spraycell.png

It works better on video-game looking images, but this is the only one I had to work with at the moment; short on time. Plus this image is from YouTube and the blurring kindof hurts the edge detection.

 

Also, a question. If there's a way, how would I prevent PDN from doing the sectional program running (where it breaks the selection into several different rectangles then runs the program multiple times), which is causing some problems in my first-try edge detection?

Share this post


Link to post
Share on other sites

If there's a way, how would I prevent PDN from doing the sectional program running (where it breaks the selection into several different rectangles then runs the program multiple times), which is causing some problems in my first-try edge detection?

Read this thread: http://forums.getpaint.net/index.php?/topic/29428-

Share this post


Link to post
Share on other sites

Also, a question. If there's a way, how would I prevent PDN from doing the sectional program running (where it breaks the selection into several different rectangles then runs the program multiple times), which is causing some problems in my first-try edge detection?

 

You could use the selection bounds instead of the ROI in your loops.

 

Just keep in mind:

-Not using the ROI will result in lower performance

-It will not work on irregular selections (non-rectangular). ie: elliptical selections, freeform selections, ect

-It's not recommended

void Render(Surface dst, Surface src, Rectangle rect)
{
    Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

    for (int y = selection.Top; y < selection.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = selection.Left; x < selection.Right; x++)
        {

        }
    }
}

Share this post


Link to post
Share on other sites

Since I would be using said cell-shader on entire images or maybe rectangular selections only, this method could help me out, right? Other than the fact that the dll will run more than once, slowing the entire process down for no gain at all except for removing the occasional mistake, would there be many drawbacks, for my purposes, to this method? I do understand that, since PDN seems to be breaking a blank canvas with a line drawn down it into about 10 separate ROI's, the runtime should be around 10 times longer...

 

Or maybe I can trash my crappy edge-detection and go for a more accurate built-in edge-detection (is it emboss, or is it actually called edge detection... eh, cant remember) and pull out the differences between that and the original image...

Dont have PDN with me at the moment, but maybe some of what I have in my head...

I did see the tutorial page on these, but just sketching the concept. Please mind the obviously fake code written in 2 minutes :P :

 

dst = someFunctionThatWillEdgeDetect(src);

that built-in for loop on the pixels{

    if(CurrentPixel != dst[x,y]){ makePixelBlack }

}

 

Just showing the concept there.

Share this post


Link to post
Share on other sites

You can call the Gaussian blur and use the difference between that and the Src to get an Inksketch effect if it is above a threshold. If you use the amount of the difference for the amount of added colour, you can get 'pencil sketch' effects too.
The way to call the Gaussian Blur (and other built-in effects) is in BoltBait's tutorials.

 

Hope that made sense. ;)

Share this post


Link to post
Share on other sites

CodeLab 2.9 Released

This is only for Paint.NET 4.0.6+!

Changes:

▪ Fixed a bug in the help system that was causing plugins that contained help to fail to build. (Bug reported by MJW)

 

 

Grab the CodeLab DLL here:

http://www.boltbait.com/pdn/CodeLab/

  • Upvote 4

Share this post


Link to post
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.