![]() |
|
[.NET] [Tutorial] Radial Gradients in GDI - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] [Tutorial] Radial Gradients in GDI (/showthread.php?tid=1812944) |
[Tutorial] Radial Gradients in GDI - Tedd - Oct 11, 2011 A lot of the times I have come across people not knowing how to do radial gradients, so this is the explanation. In GDI, it isn't called radial gradient, it is a PATH GRADIENT <- REMEMBER THAT NAME! 1. Define a path with a circle Now, first of all we need to declare us a new graphics path, like this: Code Dim path As New GraphicsPath()and second, add a new ellipse to it (this is our RADIAL part) Code path.AddEllipse(0, 0, 140, 70)2. Make a brush! (To fill our gradient) First, we use the path to make our brush. Code Dim pthGrBrush As New PathGradientBrush(path)3. Set your colors! Now, we set the center color of the gradient Code pthGrBrush.CenterColor = Color.WhiteNow, we set the outside color (this can be as many colors as you want, however the gradient we want only consists of an inside and outside color, so we only make one) Code Dim colors As Color() = {Color.Red}4. Draw the radial gradient! Now, we use our graphics to fill the ellipse (radial gradient) Code e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70)This will produce something like this: [img]http://www.blackhax.com/iqa/xBxGpdbtTstRCcNtvbIi.png[/img] Now, to make it fade out just set your inside color to something, and out outside color to Color.Transparent Complete Code: Code I will not post this complete code because if you want to learn, reading through this will teach you how, if you just copy we will know you are just a noob, and will never be able to code, no hard feelings.This is a leading example of why you should use MSDN, I found this in little under 5 minutes ( http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.pathgradientbrush.aspx ) * - Facebook Inc - Oct 11, 2011 Good job Tedd, so proud of you! <3. * - Sapientia - Oct 11, 2011 Nice job tedd, looks pretty cool 🙂 * - Tedd - Oct 11, 2011 (Oct 11, 2011 07:53 PM)¢aявøn ғιвєя Wrote: Nice job tedd, looks pretty cool 🙂Hey thanks man :) (Oct 11, 2011 07:44 PM)Facebook Inc Wrote: Good job Tedd, so proud of you! <3. Thanks really appreciate the comment :) * - 6e756c6c - Oct 11, 2011 I actually added radial gradient into 1.5.3 of the theme base! DrawRadial. :) * - Tedd - Oct 11, 2011 (Oct 11, 2011 08:07 PM)Aeonhack Wrote: I actually added radial gradient into 1.5.3 of the theme base! DrawRadial. :) Awesome, been waiting on that haha kept having to write it myself :) * - Gh0st-Zer0 - Oct 11, 2011 That's actually a very good tutorial! Also now that AeonHack Added this feature at ThemeBase 1.5.3 its getting better and better! * - SoulZeh - Oct 11, 2011 Nice tutorial Tedd :) glad to see you making the effort again <3 * - Penthos - Oct 12, 2011 Nice one tedd, Awesome share and an even better tutorial +10 for not supplying full code, It's much better to teach :) * - Fuffu - Oct 12, 2011 Erhm.. Dont hate me if i ask for something stupid now..! Is it only possible to do like .red or .green, or is it possible to make a user difined color like in html (black) etc.? * - Tedd - Oct 12, 2011 (Oct 12, 2011 01:40 AM)Fuffu Wrote: Erhm.. Dont hate me if i ask for something stupid now..! You may do any of the following: Code Color.Red, Color.Blue 'and things like thatAs far as an actual HTML color code goes, you would have to build a script to convert it to RGB. |