BoltBait Posted July 2, 2010 Share Posted July 2, 2010 I've never been happy with the C# Code Syntax Highlighter here on this site, so this tutorial has been moved here: How to Write an Effect Plugin (Part 3 of 4 - Complex)This tutorial contains an overview of how to use effect composition in CodeLab to create complex effects. If you have questions about the tutorial, you can post them here in this thread and I will address them. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted July 3, 2010 Share Posted July 3, 2010 Woah! What a marvelous tutorial! Now we'll get a landslide of new plugins from a host of new authors Thank you for explaining it so well. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted July 11, 2010 Share Posted July 11, 2010 As an amendment to BoltBait's excellent tutorial, here a codelab script that renders clouds based on @Sepcot's original Perlin Noise code. Note that this cloud effect is not exactly the same as the Cloud effect built in to PDN. /* ===================== */ /* */ /* Perlin Noise.cs */ /* */ /* Description: Draws clouds based on Sepcot's Perlin Noise routines */ /* */ /* ==================== */ // Name: Sepcot's Perlin Noise // Author: Ego Eram Reputo // Submenu: Render // URL: http://www.getpaint.net/redirect/plugins.html #region UICode double Amount1 = 1.5; // [1, 12] Frequency double Amount2 = 65; // [20, 70] Persistence (edge blur) double Amount3 = 8.0; // [2,14] Octaves double Amount4 = 1.0; // [0,5] Amplitude (brightness or density) double Amount5 = 0.0; // [-2,3] cloudCoverage double Amount6 = 1.0; // [0,4] cloudDensity #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need 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 PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor; int BrushWidth = (int)EnvironmentParameters.BrushWidth; // ColorBgra srcBgra; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { ColorBgra srcBgra = src[x, y]; byte c = (byte)(PerlinNoise2d(x, y) * 255); dst[x, y] = ColorBgra.FromBgra(srcBgra.B, srcBgra.G, srcBgra.R, c); } } } static Random r = new Random(); int r1 = r.Next(1000, 10000); int r2 = r.Next(100000, 1000000); int r3 = r.Next(1000000000, 2000000000); double PerlinNoise2d(int x, int y) { double total = 0.0; double frequency = Amount1/100; // was .015; // USER ADJUSTABLE double persistence = Amount2/100; // was .65; // USER ADJUSTABLE double octaves = Amount3; // was 8; // USER ADJUSTABLE double amplitude = Amount4; // was 1; // USER ADJUSTABLE double cloudCoverage = Amount5; // was 0; // USER ADJUSTABLE double cloudDensity = Amount6; // was 1; // USER ADJUSTABLE for(int lcv = 0; lcv < octaves; lcv++) { total = total + Smooth(x * frequency, y * frequency) * amplitude; frequency = frequency * 2; amplitude = amplitude * persistence; } total = (total + cloudCoverage) * cloudDensity; if(total < 0) total = 0.0; if(total > 1) total = 1.0; return total; } double Smooth(double x, double y) { double n1 = Noise((int)x, (int)y); double n2 = Noise((int)x + 1, (int)y); double n3 = Noise((int)x, (int)y + 1); double n4 = Noise((int)x + 1, (int)y + 1); double i1 = Interpolate(n1, n2, x - (int)x); double i2 = Interpolate(n3, n4, x - (int)x); return Interpolate(i1, i2, y - (int)y); } double Noise(int x, int y) { int n = x + y * 57; n = (n<<13) ^ n; return ( 1.0 - ( (n * (n * n * r1 + r2) + r3) & 0x7fffffff) / 1073741824.0); } double Interpolate(double x, double y, double a) { double val = (1 - Math.Cos(a * Math.PI)) * .5; return x * (1 - val) + y * val; } Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
ninja Posted July 18, 2010 Share Posted July 18, 2010 (edited) Lol, this is heavily confusing need a cup of tea now Where did you learn to do this stuff?. Edited July 18, 2010 by ninja Quote Link to comment Share on other sites More sharing options...
csm725 Posted July 18, 2010 Share Posted July 18, 2010 BoltBait, thank you for 4 amazing tutorials. I am learning .NET C# and these examples help me understand the basics of writing a plugin. Thank you. Quote My deviantART | Sig Battles | My Tutorials | csm725.com Click to enter or vote in the official Paint.NET competitions! COMPETITIONS: LOGO OF THE WEEK Link to comment Share on other sites More sharing options...
RFX Posted February 15, 2013 Share Posted February 15, 2013 Is there a list or examples of the actions in Paint.net similar to the composite effects list / effects examples that were given such as "gaussian blur", "emboss", "add noise", etc. ? In particular things like "cut selection", "copy selection", "delete selection", and "paste selection" is what I'm trying to find or is that something completely different? I know that copying and such are actions and emboss and whatnot are effects but I can't find any examples which explains how to use actions, or maybe I just missed / overlooked them. Quote Link to comment Share on other sites More sharing options...
pyrochild Posted February 15, 2013 Share Posted February 15, 2013 None of those are possible. Only effects and adjustments. Quote ambigram signature by Kemaru [i write plugins and stuff] If you like a post, upvote it! Link to comment Share on other sites More sharing options...
BoltBait Posted February 15, 2013 Author Share Posted February 15, 2013 None of those are possible. Only effects and adjustments. What he said ^^ Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
RFX Posted February 16, 2013 Share Posted February 16, 2013 lol well there goes my idea There is an alternate method to what I have in mind however there are a few plug ins that already exist and sort of relate to it, just nothing I've seen that does exactly what I had in mind. Thanks though for the info guys, I'll do a bit more research on it. Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 16, 2013 Share Posted February 16, 2013 Have a look at this list of what plugins can and cannot do: plugin limitations 1 Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
RFX Posted February 26, 2013 Share Posted February 26, 2013 Thanks EER! I checked it out and I think what I had in mind is just not possible, an plotted section cutter similar to Gimp's path tool. As it can't cut or make the selected area transparent, perhaps I can try a different approach from those 2 ideas and try an area-to-fill but I'm not sure if a plotted path is even possible to do as an effect. Something like this: Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted February 27, 2013 Share Posted February 27, 2013 Looks like you need to write a tool interface like Smudge or Liquify. Possible, but very difficult compared to 'standard' plugins. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
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.