Simon Brown Posted April 19, 2008 Share Posted April 19, 2008 In the process of creating the fire effect plugin, emulating the curves effect is necessary. However, when I type into VS "CurvesEffect." intellisense doesn't come up so there is no way I can configure the effect. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
I Like Pi Posted April 19, 2008 Share Posted April 19, 2008 Search the Paint.NET source for "curves" and you'll find the following: namespace PaintDotNet.Effects { [EffectCategory(EffectCategory.Adjustment)] public sealed class CurvesEffect : Effect { I don't know why it isn't visible through intellisense though Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted April 19, 2008 Author Share Posted April 19, 2008 I will try typing it in and see if there is a compilation error. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted April 19, 2008 Share Posted April 19, 2008 Try... CurvesEffect cs = new CurvesEffect(); cs. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Simon Brown Posted April 19, 2008 Author Share Posted April 19, 2008 The problem is that that doesn't give me the appropriet constant - just the plugin settings. Edit: Intellisense also finds no method in the created object called "CreatePropertyCollection()" as in other effects. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted April 19, 2008 Share Posted April 19, 2008 Curves is not made with IndirectUI. BTW, I bet pyrochild could help you. If you have a copy of Reflector, you might want to look around Scriptlab... Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Simon Brown Posted April 19, 2008 Author Share Posted April 19, 2008 If you have a copy of Reflector, you might want to look around Scriptlab... I don't decompile other peoples' programs unless I have their permission. Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted April 19, 2008 Author Share Posted April 19, 2008 OK, I think I understand how to automate non-IndirectUI plugins - but I have another question specifically about Curves. The config token has an array called "ControlPoints" with several collection objects for the points inside - am I right that the items of that array are for each channel? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted April 19, 2008 Share Posted April 19, 2008 I'm not sure. I've never played with curves from that side of the screen. (That is, from the CPU side. ) Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
Simon Brown Posted April 19, 2008 Author Share Posted April 19, 2008 The problem is that it appears this array has only one item - even after I change the config token to RGB mode. Quote Link to comment Share on other sites More sharing options...
I Like Pi Posted April 19, 2008 Share Posted April 19, 2008 Looking at Paint.NET's code is probably the easiest way to figure this out. Take a look at how the dialog generates the token. Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted April 19, 2008 Author Share Posted April 19, 2008 Just one thing: Whenever I attempt to change the colour transfer mode an exception is thrown. Quote Link to comment Share on other sites More sharing options...
Tanel Posted April 20, 2008 Share Posted April 20, 2008 Simon, I guess you are following Tom Jackson's "How to start a fire" tutorial. In this case I suggest you to use linear transformation instead of curves. That is just few lines of code, easy to handle and basically same result. Here is a codelab code that imitates linear "curve" with middle control points located as: Red: 0, 0 Green: 150, 0 Blue: 215, 0 // Author: Tanel Rüütli int Amount1=0; //[0,255]Red Control Point int Amount2=150; //[0,255]Green Control Point int Amount3=215; //[0,255]Blue Control Point void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); ColorBgra CurrentPixel; for(int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; // initial rgb values that you have after clouds effect byte r = (byte)CurrentPixel.R; byte g = (byte)CurrentPixel.G; byte b = (byte)CurrentPixel.B; byte a = (byte)CurrentPixel.A; // Return multipliers from our "Control Point" values double rx = 255 / (255 - Amount1 + 0.01); // there is + 0.01 to avoid divide-by-zero exception when Amount is 255 double gx = 255 / (255 - Amount2 + 0.01); // there is + 0.01 to avoid divide-by-zero exception when Amount is 255 double bx = 255 / (255 - Amount3 + 0.01); // there is + 0.01 to avoid divide-by-zero exception when Amount is 255 // Calculate new rgb values double r1 = 255 - rx * (double)(255 - r); double g1 = 255 - gx * (double)(255 - g); double b1 = 255 - bx * (double)(255 - ; // Final RGBA CurrentPixel.R = Utility.ClampToByte(r1); CurrentPixel.G = Utility.ClampToByte(g1); CurrentPixel.B = Utility.ClampToByte(b1); CurrentPixel.A = a; dst[x,y] = CurrentPixel; } } } You can test it on the gray fire image from Tom's tutorial. Effectively my code does the same as applying following curves setup (I used Curves+ for this example, because it allows "straight curves"): If you tie the above Amount1, Amount2 and Amount3 with your plugin controls, or even better, a color wheel control (through opposite RGB values)* then user can easily change color of fire. * Edit: by "opposite RGB values" I mean Amount1=255-ColorWheel.R; Amount2=255-ColorWheel.G; Amount3=255-ColorWheel.B; this way the color of fire turns to same range as the selection in ColorWheel. Quote 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.