Popular Post Rei Posted October 13, 2014 Popular Post Share Posted October 13, 2014 OK, well this is my first plugin. Hope it's useful for more than just me. This plugin will allow you to make your image gradually transparent going from the center to the edges (or vice-versa). The transparency gain over distance to the center is modulable, as well as the circle size. If you have any feedback or suggestions, please share your opinion This is what the UI looks like : Before: After : The main difference between this and the gradient tool is the 'Fade Rate' slider, i.e. the modulability of the transparency gain over distance. Made with the CodeLab plugin for Paint.NET. Installation guide : Download the dll here: RadialFade.zip To install, either disregard the .bat and put the .dll in C:\Program Files\paint.net\Effects or put both files on your desktop and double-click the .bat. The second method is preferred if you are updating the plug-in. It will be installed under Effects\Render. PdN 3.5.11 users : Maximilian has come to your rescue! Download link in his post on page 2, make sure to upvote! Changelog : Hidden Content: 1.1 : + Added panning (thanks to MikeRobe for the idea!) - Changed Fade Rate slider from integer values to real values 1.2 : + Fade-in (rather than out) checkbox - Commented source code for readability 1.3 : + Made circle size adjustable Source Code : Hidden Content: // Submenu: Render // Name: Radial Fade // Title: Rei's Radial Fade // Author: Rei #region UICode double Amount1 = 3; // [0,10] Fade Rate double Amount2 = 0; // [-100,100] X Pan % double Amount3 = 0; // [-100,100] Y Pan % double Amount4 = 100; // [0,1000] Circle Size % bool Amount5 = false; // [0,1] Invert Alpha #endregion double distanceTo(int xPos, int yPos, int xTarget, int yTarget){ //Pythagorean theorem return Math.Sqrt((double)((xTarget-xPos)*(xTarget-xPos)+(yTarget-yPos)*(yTarget-yPos))); } double getRadius(Rectangle bounds){ //the Diameter is by default the biggest dimension (x or y) of the selection. //thus the Radius is half of that. return (Math.Max((bounds.Right-bounds.Left),(bounds.Bottom-bounds.Top))/2); } void Render(Surface dst, Surface src, Rectangle rect) { Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); int centerX = ((selection.Right - selection.Left) / 2)+selection.Left; int centerY = ((selection.Bottom - selection.Top) / 2)+selection.Top; //centerX and centerY represent the coordinates of the center of the fade circle, //which is by default the center of the selection centerX += (int) ((Amount2 *(selection.Left-centerX))/100.0); centerY += (int) ((Amount3 *(selection.Bottom-centerY))/100.0); double radius=getRadius(selection)*(Amount4/100.0); ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { //here, we find out how far we are from the center of the fade circle to calculate alpha double distanceToCenter = distanceTo(x,y,centerX,centerY); CurrentPixel = src[x,y]; if(!Amount5){ if(distanceToCenter > radius) CurrentPixel.A = (byte) 0; else //distanceToCenter / radius gives us a raw representation of where the pixel is in the circle => how transparent it should be //this value is taken to the 'Amount1'th power so our alpha distribution is customizable and non-linear //we multiply this by 255 to scale from a [0.0,1.0] value to a byte //255.0-<expression> will invert this value (without this it fades in) CurrentPixel.A = (byte) Math.Min((CurrentPixel.A),((255.0)-(Math.Pow((distanceToCenter / radius),Amount1) * 255.0))); } else CurrentPixel.A = (byte) Math.Min((CurrentPixel.A),((Math.Pow((distanceToCenter / radius),Amount1) * 255.0))); dst[x,y] = CurrentPixel; } } } You are free to edit, use and publish this source in any way, whether you make or don't make profit off of it ; as long as I am mentioned as the original author and a link to this thread is provided. EDIT : New license : Do what you want. 10 Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted October 13, 2014 Share Posted October 13, 2014 Well done..... but can't this be done with the transparent option of the Gradient tool (in Radial mode)? 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...
Rei Posted October 13, 2014 Author Share Posted October 13, 2014 It can indeed. I didn't even see that option, and feel like an idiot for having gone through all that.Meh, at least I got some experience out of it. That being said, it seems to me the transparency gain over distance to center can't be tampered with, so I guess this still can be useful... -ish. Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted October 14, 2014 Share Posted October 14, 2014 You made a nice job of your first plugin. A good learning experience! I'm sure some users will find it useful due to the slight differences between the two. Are you going to compile the dll and upload it (zipped)? If you are, there are a few nice features you can include in the source before compiling. See http://www.boltbait.com/pdn/codelab/help/buildingdll.asp (under heading DEFAULTS). 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...
Rei Posted October 14, 2014 Author Share Posted October 14, 2014 (edited) Thanks Strangely, I thought I added the zip with the dll and a .bat that installs it ; but it's obviously not there. Something must've gone wrong, I'll try it again. If you are, there are a few nice features you can include in the source before compiling. See http://www.boltbait.com/pdn/codelab/help/buildingdll.asp (under heading DEFAULTS). Thanks, I'll do that next time, but I already have the zip on my desktop, so I won't go through the whole recompiling process. EDIT : OK, I added the dll to my first post. Thanks for pointing that out, Ego. Edited October 14, 2014 by Rei Quote Link to comment Share on other sites More sharing options...
Nai Posted October 14, 2014 Share Posted October 14, 2014 Puzzled. How to install another file ? In effects folder or somewhere else ? Quote Link to comment Share on other sites More sharing options...
MikeRobe Posted October 14, 2014 Share Posted October 14, 2014 Sometimes I find the transparent gradient tool a bit tricky to use (lol), so I'm sure this plugin will come in handy! Perhaps an option to pan the effect would also be useful! 1 Quote I baked another one... Link to comment Share on other sites More sharing options...
Rei Posted October 14, 2014 Author Share Posted October 14, 2014 (edited) Puzzled. How to install another file ? In effects folder or somewhere else ? I'm not sure what you mean. If you're wondering which submenu you can find the effect after installation; it should be Effects\Render. Sometimes I find the transparent gradient tool a bit tricky to use (lol), so I'm sure this plugin will come in handy! Perhaps an option to pan the effect would also be useful! Great to know it's useful! I'll try working on a panning system ; but in the meantime you can select the area you want to fade ; since this works by selection : it will fade from the center to the edge of the selection. You might be able to make do with that until I implement the panning. Thanks for the idea! EDIT : Implemented panning Edited October 14, 2014 by Rei Quote Link to comment Share on other sites More sharing options...
nitenurse79 Posted October 14, 2014 Share Posted October 14, 2014 Where does the Windows Batch File go please ? Quote Link to comment Share on other sites More sharing options...
Rei Posted October 14, 2014 Author Share Posted October 14, 2014 Where does the Windows Batch File go please ? You put both files on your desktop and double-click the .bat. Or you put the dll file in Program Files\paint.net\Effects and the bat in the recycle bin. Quote Link to comment Share on other sites More sharing options...
nitenurse79 Posted October 14, 2014 Share Posted October 14, 2014 You put both files on your desktop and double-click the .bat. Or you put the dll file in Program Files\paint.net\Effects and the bat in the recycle bin. Thanks for the prompt reply Rei Quote Link to comment Share on other sites More sharing options...
Rei Posted October 14, 2014 Author Share Posted October 14, 2014 Thanks for the prompt reply Rei No problem~ if you have any suggestions or feedback, please do leave a comment Quote Link to comment Share on other sites More sharing options...
Nai Posted October 15, 2014 Share Posted October 15, 2014 You put both files on your desktop and double-click the .bat. Or you put the dll file in Program Files\paint.net\Effects and the bat in the recycle bin. Hey, you're actually giving the answer I need. Thanks ! Cheerio ! Quote Link to comment Share on other sites More sharing options...
Rei Posted October 15, 2014 Author Share Posted October 15, 2014 Hey, you're actually giving the answer I need. Thanks ! Cheerio ! Oh, great! Quote Link to comment Share on other sites More sharing options...
Twig Posted November 6, 2014 Share Posted November 6, 2014 Yeah got it added and it took 1 min instead hours and hours from a much earlier time. Thank you! Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted January 2, 2015 Share Posted January 2, 2015 I see you've posted the source code, but I'm not seeing any sort of license. Please let us know what freedoms, if any, are available to us in relation the code. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted January 3, 2015 Share Posted January 3, 2015 My guess is you're free to modify, obfuscate, and build on the posted code. Even though no license or conditions have been mentioned, the author is still entitled to be credited with the original idea and code. A solid attribution and perhaps a link to this thread would be a good idea. 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...
SAND33P Posted January 3, 2015 Share Posted January 3, 2015 (edited) Love this plugin, i can finally do this:Going to put a request in to have this baked into the gradient tool Edited January 3, 2015 by SAND33P Quote Link to comment Share on other sites More sharing options...
Rei Posted January 5, 2015 Author Share Posted January 5, 2015 (edited) I see you've posted the source code, but I'm not seeing any sort of license. Please let us know what freedoms, if any, are available to us in relation the code. Done, thanks. Edited January 5, 2015 by Rei Quote Link to comment Share on other sites More sharing options...
Billydean Posted June 29, 2015 Share Posted June 29, 2015 This doesn't show up under Effects. I have re-downloaded and replaced the .dll file, but nothing works. Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted June 29, 2015 Share Posted June 29, 2015 You're using paint.net 3.5.11. This plugin only works with paint.net 4.0+ You should upgrade. It's free. Go to http://www.getpaint.net/download.html to get it (noting the system requirements). 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...
Maximilian Posted June 29, 2015 Share Posted June 29, 2015 In case Billy can't upgrade yet, here's a version of the plugin I've compiled for Paint.NET 3.5.11 Radial Fade 1.3 for PdN 3.5.11.zip 4 Quote Link to comment Share on other sites More sharing options...
Billydean Posted June 30, 2015 Share Posted June 30, 2015 Ah, thanks for the replies. My computer is a bit of a mess at the moment. I'm in Bali on my laptop, which came with Windows 7 plus free upgrade to 8 and 8.1. Earlier in the year I installed Windows 10 with the Insider Program, but after too many gliches returned to Win 7. Unfortunately I now only have Win 7, I can no longer use free Win 8. Now, for some reason, my laptop refuses to install Win 7 SP1, which Paint.net 4.0 needs. So thanks for the 3.5 version, I'll install when I get home. Quote Link to comment Share on other sites More sharing options...
Maximilian Posted June 30, 2015 Share Posted June 30, 2015 Welcome and best of lucks with that mess! Quote Link to comment Share on other sites More sharing options...
lynxster4 Posted November 27, 2015 Share Posted November 27, 2015 @Rei...I use this plugin all the time. Thank you so much for making it! Quote My Art Gallery | My Shape Packs | ShapeMaker Mini Tut | Air Bubble Stained Glass Chrome Text with Reflections | Porcelain Text w/ Variegated Coloring | Realistic Knit PatternOpalescent Stained Glass | Frosted Snowman Cookie | Leather Texture | Plastic Text | Silk Embroidery Visit my Personal Website "Never, ever lose your sense of humor - you'll live longer" 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.