Help me How Exacrly i can use the pathGradiant brush
-
Hi please Tell me the code about how exactly i used the pathgradiant brush to draw a sphere Thanks. Eman Ali Moughal Senior Software Engineer Soon Soft (pvt) Ltd www.soonsoft.com
-
Hi please Tell me the code about how exactly i used the pathgradiant brush to draw a sphere Thanks. Eman Ali Moughal Senior Software Engineer Soon Soft (pvt) Ltd www.soonsoft.com
Eman, I just hacked this code out of my own C# project, hoping thatit will be of use to you. It may help clarify a few quirky things about PathGradientBrush. I think, by altering the focus parameter of SetTriangle... or SetSigma... in the code below, that you may be able to present a highlite at a position in a circle which approximates the look of a sphere. I honestly dont think you will get anything high quality though without breaking the sphere into triangles and shading each one appropriately, and that's way beyond me. Another kludge you might use is to take a bitmap of a sphere, drawn in a 3D package or using Photopaint etc., and scaling it. Well, for what its worth, here is my code, you will have to hack out my variables and try follow what's going on quite closely. This method returns a brush that you can use on Graphics.FillPath. prPath is a GraphicsPath prFlip just flips a start and end color around prBrushType is my enumeration which controls whether blends or triangle or bell type fills public PathGradientBrush CreatePathBrush(GraphicsPath prPath) { Color lStart, lEnd; // Start and end color PathGradientBrush lBrush; // Brush to assign to lStart = Your Start Color; lEnd = Your End Color; // Create the linear brush lBrush = new PathGradientBrush(prPath); lBrush.CenterColor = lEnd; // Create an array of colors which are the end color at each point Color []lColors = new Color[prPath.PointCount]; for(int lCount = 0 ; lCount < prPath.PointCount ; lCount ++) { lColors[lCount] = lStart; } lBrush.SurroundColors = lColors; // Experiment with the 0.5F figure, it should change the highlight on the shape you fill // Of course you will want to fill a circle or ellipse would be better still. lBrush.SetSigmaBellShape(0.5F); return lBrush; } --------------- Hope this makes some kind of sense to you. Nursey
-
Eman, I just hacked this code out of my own C# project, hoping thatit will be of use to you. It may help clarify a few quirky things about PathGradientBrush. I think, by altering the focus parameter of SetTriangle... or SetSigma... in the code below, that you may be able to present a highlite at a position in a circle which approximates the look of a sphere. I honestly dont think you will get anything high quality though without breaking the sphere into triangles and shading each one appropriately, and that's way beyond me. Another kludge you might use is to take a bitmap of a sphere, drawn in a 3D package or using Photopaint etc., and scaling it. Well, for what its worth, here is my code, you will have to hack out my variables and try follow what's going on quite closely. This method returns a brush that you can use on Graphics.FillPath. prPath is a GraphicsPath prFlip just flips a start and end color around prBrushType is my enumeration which controls whether blends or triangle or bell type fills public PathGradientBrush CreatePathBrush(GraphicsPath prPath) { Color lStart, lEnd; // Start and end color PathGradientBrush lBrush; // Brush to assign to lStart = Your Start Color; lEnd = Your End Color; // Create the linear brush lBrush = new PathGradientBrush(prPath); lBrush.CenterColor = lEnd; // Create an array of colors which are the end color at each point Color []lColors = new Color[prPath.PointCount]; for(int lCount = 0 ; lCount < prPath.PointCount ; lCount ++) { lColors[lCount] = lStart; } lBrush.SurroundColors = lColors; // Experiment with the 0.5F figure, it should change the highlight on the shape you fill // Of course you will want to fill a circle or ellipse would be better still. lBrush.SetSigmaBellShape(0.5F); return lBrush; } --------------- Hope this makes some kind of sense to you. Nursey
-
Hi cnurse thanks for the help buddy. i have now my concept bcome bit improve about the path gradiant brush. Thanks for your help.
You're very welcome. I'm glad I can offer back to a system I have gained so much from. By the way. Watch out for my Theme system which will be released in the next few weeks. It lets you edit and manage gradients and will show you lots of ways to use them. Regards, Nursey