Jump to content
How to Install Plugins ×

CodeLab v6.12 for Paint.NET 5.0.12 (Updated February 11, 2024)


Rick Brewster

Recommended Posts

Here's an "effect" that Tom wrote. Basically what it does is let you write code that is compiled on the fly and that is then executed in the Paint.NET effect engine. This is the same plugin that we made available for Paint.NET v2.1, but it has been updated to work with Paint.NET v2.6 (and later). With this you can implement almost any type of effect you want if you have the programming and mathematical talent to do so. This plugin works by presenting you with a simple text editor that you can use to type in C# code that is then compiled and executed (rendered) as soon as you stop typing.

 

Please note that this is experimental technology and is not meant to provide a robust development environment. It is perfect for rapid prototyping and very useful for educational purposes including teaching computer graphics.

 

This plugin especially benefits from Paint.NET's extensive multiprocessor and multicore support. For instance, if you are interested in rendering high resolution fractals on an expensive workstation, this is the way to do it! The code you write is automatically multithreaded and the workload is spread across multiple CPU's resulting in near linear performance scaling (4 CPU's = almost 4x faster).

 

CodeLab.png

 

Download:

 

http://BoltBait.com/pdn/codelab/

Note: BoltBait is the current maintainer of CodeLab.

 

 

Help file:

 

http://BoltBait.com/pdn/codelab/help/

 

 

Help for non-programmers:

 

If someone gave you a CodeLab script and just want to know what to do with it, read this: 
https://forums.getpaint.net/topic/111233-codelab-for-average-users-a-laymans-guide/

 

 

 

Tutorials:

 

 

 

Russian

 

If you speak Russian, download here: http://forums.getpaint.net/index.php?/topic/29995-a

 

User ReMake maintains the Russian version. Post enhancement requests/bug reports of the Russian version on that thread.

 

 

With CodeLab, you can...

 

Work with complicated displacement filters:

chrome_before.jpgchrome_after.jpg

Parametric images:

radial.jpg

High resolution fractals:

mandelbrot.jpgjulia.jpg

 

  • Like 1
  • Upvote 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Very cool!

I've been wondering what CodeLab was. I still don't have Visual Studio installed...school is very busy.

To compile the code with this plugin, does Visual Studio or another compiler need to be installed or is the compiler built-in?

Thanks for the post! I'm all hyped up about writing plugins now!

*starts installing Visual Studio*

-John

Link to comment
Share on other sites

Thanks for the post!

For advanced users is correct! I myself have no idea how to write code.

However, there are some cool effects in the "Samples" folder included in the .zip file that you can fool around with. If for nothing else, grab this plugin for the included effects!

BK_BloodSaw_sig.png

- DO NOT contact me asking for the .pdn of my avatar or the PDN logo. Thank you. Have a nice day.

Link to comment
Share on other sites

To where should bug reports and the like for the CodeLab utility itself be directed?

This topic will do fine, what's the bug?

This post is made "AS IS" without warranties and confers no rights.

Link to comment
Share on other sites

I have several bugs/suggestions:

When a file is opened, it would be nice if the "Name: " text box were updated with the file name (minus the .cs). It does the opposite while saving, so I thought it would make sense to do this while loading.

Also, the ability to scroll sideways instead of wrapping text would be nice. Or, as in my copy of Visual Studio, have a small indication to the side of the text box that indicates that a line has been wrapped (I understand this is harder to implement).

I beleive this is more of a suggestion for Paint.Net and not CodeLab, but it would be nice if the image could be zoomed/panned while changing things in an open Effect dialog (or CodeLab).

When an error shows up in the error field, and I click on it, the text in the text box that is causing the error is highlighted. This is great, however, if the erroneous code is not currently visible, nothing happens. It would be nice if the code edit window were automatically scrolled to where the highlighted error can be seen...otherwise, it is hard to find the error.

One final thing:

The code line enumeration starts at line 13, and sometimes error messages refer to things on lines such as "10." For example, if I change something in the first line like if I change "Render" to "Rendxer" (for no reason, obviously), it reports an error on "line 10". I understand that this happens becuase there is actually more code above what can be seen. I don't think it can hurt to show this code.

Overall, however, I'm extremely pleased with CodeLab...it is a great tool!

Link to comment
Share on other sites

Also, when I press the "Delete" key instead of "Backspace" to delete code, the code is not recompiled after .5 sec.

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for the bugs, I'll look into those. I'm not sure about the wrapping thing, but I'll look at it. Don't count on a wrapping indicator, though.

Ideally, we would write a full-fledged code editor, but that would be a little overkill for these purposes.

-tjackson

This post is made "AS IS" without warranties and confers no rights.

Link to comment
Share on other sites

Wow.

I have only been programming with a general knowledge in Javascript. I understand this is C#? I took to it quickly and I love the flexibility. I need to learn a lot of the function, but nice none the less. creates nice functional colors.

Also, debuggers just give you a specific area. I think there is no 100% accuracy pinpoint on a processor > 80 MHz

~~

Link to comment
Share on other sites

Yup, it's C#. You'll find good reference for the Math functions here, btw (it uses the .NET Framework stuff):

http://msdn2.microsoft.com/en-us/library/system.math(VS.80).aspx

That URL doesn't seem to get linked up correctly with this forum software. D'oh. Copy and paste wins this round. Also, I recommend setting the language filter to just C#)[/url]

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Yup, it's C#. You'll find good reference for the Math functions here, btw (it uses the .NET Framework stuff):

http://msdn2.microsoft.com/en-us/librar ... math(VS.80).aspx[/url]

I was looking around last night for the random function (which I know now is a Random instance (here r), referenced:

byte c = (byte)(r.Next(0,255))

The system functions are almost foreign, also.

The sierpinski triangle example I did on 8192 x 6144 resolution. Zoomed in a good bit.

The fractals are fast.

~~

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

Here's a big fat bug: Go and dispose the source surface. It crashes it. I suppose a keyhook before it renders would do.

~~

Link to comment
Share on other sites

I would find it very useful if there was a checkbox (or something) that I could use to keep the compiler from starting automatically when I pause typing. Actually, the compiler is fine, but could the effect not be RUN until I press a button?

There are times when it would be useful to not run the effect until I press the Build button.

It would be useful if when the user presses the Build DLL button it asked for an icon file to be included in the effects menu.

It might be more helpful if the default text in the edit window were like this:

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
   long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left);
   long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top);
   ColorBgra CurrentPixel;
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
   for(int y = rect.Top; y     {
       for (int x = rect.Left; x         {
           if (selectionRegion.IsVisible(x, y))
           {
               CurrentPixel = src[x,y];
               // TODO: Add pixel processing code here
               // Access RGBA values this way, for example:
               // CurrentPixel.R = (byte)PrimaryColor.R;
               // CurrentPixel.G = (byte)PrimaryColor.G;
               // CurrentPixel.B = (byte)PrimaryColor.B;
               // CurrentPixel.A = (byte)PrimaryColor.A;
               dst[x,y] = CurrentPixel;
           }
       }
   }
}

Also, as someone else mentioned, it would be really handy if when you load a .cs file, the name box would be populated with the name of the file.

Finally, codelab needs a horizontal scroll bar on the error messages window. I know that when you click on the error message it shows the full text in a tooltip, but the tooltips are being shown *below* the codelab window, so you can't always read the message.

Thanks!

Link to comment
Share on other sites

Well, three things:

1) It says "Alpha" in the window title for a reason :) We just haven't spent the time to really make it a full, robust development environment.

2) We won't be spending much time to make it into a "full, robust development environment" because CodeLab is really intended for either simple things, experimenting, and / or rapid prototyping for effects that will be finished up using Visual Studio. It is so much faster to just type in code and to see that it works (or doesn't!) immediately then it is to sweat over 500 lines of code in Visual Studio with a long test cycle of build, run PDN, open image, open effect, hope it doesn't crash, etc.

3) CodeLab is not designed to hold the user's hand in the manner you propose with that code snippet :)

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

So is this plugin open sourced? I'm more interested in seeing how the code is compiled and executed on the fly, the concept is very interesting.

I knew .Net could compile code dynamically, however, I'm not sure how you added it to a running program. Is the code saved to a temp DLL and loaded via LoadAssembly() ? thats the only way I can think of doing something like this.

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...