PJayTycy Posted December 4, 2007 Share Posted December 4, 2007 Hello, for a plug-in I'm trying to write, I would like to be able to use complex numbers. I have a rudimentary version, where I changed all mathematics to work on a set of 2 doubles (either {real, imag} or {radius, theta}). I used 2 custom functions : PolarToRect() and RectToPolar(), to change between [real, imag] and [radius, theta] information. However, as complex numbers are so common, and some complex number libraries exist for C#, I was wondering if Paint.NET already includes one of those libraries or has some functions to work with complex numbers from itself. Thanks, PJay Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted December 4, 2007 Share Posted December 4, 2007 No, there is no built-in library or class in Paint.NET that handles this. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
PJayTycy Posted December 4, 2007 Author Share Posted December 4, 2007 Thanks for your answer. I tried to use MathNet Iridium as library and do some testing in Codelabs, but I cannot put "using" statements in CodeLabs. I could copy/paste the complex number class into my CodeLabs script for prototyping, but will I be able to use the compiled dll of an external library if I create a "real" plugin from it ? Or are there plans for CodeLabs to allow us to use external libraries ? Thanks, PJay Quote Link to comment Share on other sites More sharing options...
Andrew D Posted December 4, 2007 Share Posted December 4, 2007 Thanks for your answer.I tried to use MathNet Iridium as library and do some testing in Codelabs, but I cannot put "using" statements in CodeLabs. I could copy/paste the complex number class into my CodeLabs script for prototyping, but will I be able to use the compiled dll of an external library if I create a "real" plugin from it ? Or are there plans for CodeLabs to allow us to use external libraries ? Thanks, PJay CodeLab automatically uses the refrences which you would need to build a plug-in, the ones which come with PDN itself. Adding an ability to allow your own choice of resources would make it more complicated than needed, and if you want to make a complex plug-in, I would seriously have to turn you towards Visual Stduio C# Express Edition 2008. Quote Link to comment Share on other sites More sharing options...
PJayTycy Posted December 4, 2007 Author Share Posted December 4, 2007 Thanks for your answers. I can succesfully compile and use my plugin with the external library when using Visual Studio. So, using an external library makes me lose the rapid prototyping in CodeLabs, but it is possible. After I've debugged my plugin, I'll post the results here. For now, let's just say I'm trying to do advanced versions of this. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted December 4, 2007 Share Posted December 4, 2007 This plugin may be of use to you... http://boltbait.googlepages.com/shapes It includes source code that includes a method for converting from polar to rect coordinates. 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...
Rick Brewster Posted December 6, 2007 Share Posted December 6, 2007 Also, instead of using your own AddColor() method, I recommend making use of PaintDotNet.Data.UserBlendOps.AdditiveBlendOp: UserBlendOp addOp = new AdditiveBlendOp(); result = addOp.Apply(lhs, rhs); // result = lhs + rhs It will do all the work of ensuring the alpha channel is handled correctly (which is trickier than you may think). Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
PJayTycy Posted December 6, 2007 Author Share Posted December 6, 2007 Also, instead of using your own AddColor() method, I recommend making use of PaintDotNet.Data.UserBlendOps.AdditiveBlendOp: UserBlendOp addOp = new AdditiveBlendOp(); result = addOp.Apply(lhs, rhs); // result = lhs + rhs It will do all the work of ensuring the alpha channel is handled correctly (which is trickier than you may think). Is this AdditiveBlendOp also asymetrical ? My addColor function will give the first color full priority over the second color (ie: only add a little bit of the second color if they both have only a little bit of transparency) (0, 0, 0, 200) + (255, 255, 255, 200) => (55, 55, 55, 255) (255, 255, 255, 200) + (0, 0, 0, 200) => (200, 200, 200, 255) I thought the normal Paint.Net functions would give (127, 127, 127, 255) in both cases. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted December 6, 2007 Share Posted December 6, 2007 AdditiveBlendOp implements the OVER operation with addition. It's as if 'rhs' is blended "on top of" lhs. If rhs is fully opaque, the result will be rhs regardless of what lhs is. I can almost guarantee you that this is what you want -- it's what Paint.NET uses for its layer composition when you choose the Additive blend mode. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
PJayTycy Posted December 7, 2007 Author Share Posted December 7, 2007 AdditiveBlendOp implements the OVER operation with addition. It's as if 'rhs' is blended "on top of" lhs. If rhs is fully opaque, the result will be rhs regardless of what lhs is. I can almost guarantee you that this is what you want -- it's what Paint.NET uses for its layer composition when you choose the Additive blend mode. As I can not see in the source code what it does, I tested the layer composition. It is not exactly what I want. What it does: black@50% + white@50% => 2/3 white@75% So, the lhs is only counted for 25% (rhs_remaining_alpha*lhs_alpha). I want it to be counted for 50% (minimum(rhs_remaining_alpha,lhs_alpha)) and have the result be 1/2 white@100%. Maybe one of the other blends works like that ? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted December 7, 2007 Share Posted December 7, 2007 Maybe one of the other blends works like that ? All of the layer blend modes use the same math for the alpha channel handling, so no. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html 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.