Rick Brewster Posted March 10, 2006 Posted March 10, 2006 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). 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: Overview Tutorial 1 of 4 Tutorial 2 of 4 Tutorial 3 of 4 Tutorial 4 of 4 Tutorial 5 of 4 Tutorial 6 Tutorial 7 Sample Code 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: Parametric images: High resolution fractals: 1 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
SearedIce Posted March 10, 2006 Posted March 10, 2006 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 Quote
Rick Brewster Posted March 10, 2006 Author Posted March 10, 2006 Visual Studio is not required. Everything is built-in to the .NET Framework that you've already got installed. 1 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
BuzzKill Posted March 11, 2006 Posted March 11, 2006 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! Quote - DO NOT contact me asking for the .pdn of my avatar or the PDN logo. Thank you. Have a nice day.
SearedIce Posted March 12, 2006 Posted March 12, 2006 To where should bug reports and the like for the CodeLab utility itself be directed? Quote
Tom Jackson Posted March 13, 2006 Posted March 13, 2006 To where should bug reports and the like for the CodeLab utility itself be directed? This topic will do fine, what's the bug? Quote This post is made "AS IS" without warranties and confers no rights.
SearedIce Posted March 13, 2006 Posted March 13, 2006 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! Quote
SearedIce Posted March 13, 2006 Posted March 13, 2006 Also, when I press the "Delete" key instead of "Backspace" to delete code, the code is not recompiled after .5 sec. Quote
Rick Brewster Posted March 18, 2006 Author Posted March 18, 2006 Moved to new Plugins forum Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Tom Jackson Posted April 6, 2006 Posted April 6, 2006 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 Quote This post is made "AS IS" without warranties and confers no rights.
Illnab1024 Posted April 13, 2006 Posted April 13, 2006 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 Quote ~~
Rick Brewster Posted April 13, 2006 Author Posted April 13, 2006 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] Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Illnab1024 Posted April 13, 2006 Posted April 13, 2006 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. Quote ~~
Illnab1024 Posted October 3, 2006 Posted October 3, 2006 Here's a big fat bug: Go and dispose the source surface. It crashes it. I suppose a keyhook before it renders would do. Quote ~~
Rick Brewster Posted October 3, 2006 Author Posted October 3, 2006 So don't dispose the surface. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Illnab1024 Posted October 3, 2006 Posted October 3, 2006 I see your point, but...well you do say at the top "for advanced users"... Quote ~~
BoltBait Posted October 4, 2006 Posted October 4, 2006 I've just started playing with this today and still haven't made anything remotely useful yet. Its still fun, though. One annoying thing... In the code editor, Ctrl-A doesn't select all. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Illnab1024 Posted October 4, 2006 Posted October 4, 2006 It rebuilds, which I find more useful. Quote ~~
BoltBait Posted October 10, 2006 Posted October 10, 2006 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! Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Rick Brewster Posted October 10, 2006 Author Posted October 10, 2006 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 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
BoltBait Posted October 10, 2006 Posted October 10, 2006 Ouch! I could feel that one from here. Well, I give my input for free... and I'm sure it's worth every penny. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Train Posted January 13, 2007 Posted January 13, 2007 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. Quote
Illnab1024 Posted January 13, 2007 Posted January 13, 2007 The source for CodeLab is in the 'extras' folder of the Paint.NET source... Read the first post Quote ~~
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.