Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi every one

kindly can any body help me to draw a gradient transparent circle which has four colors
(violet,red,yellow,and green) these colors starts from the center one after one till the edge of the circle and also has a transparent look ?

all what i can achieve till now is

VB
Dim g As Graphics = e.Graphics
       Dim width As Integer = Me.ClientRectangle.Width / 2
       Dim height As Integer = Me.ClientRectangle.Height / 2

       Dim b As PathGradientBrush
       Dim x As Integer = 0
       Dim y As Integer = 0
       Dim circle As GraphicsPath = New GraphicsPath()
       circle.AddEllipse(0, 0, width, height)
       b = New PathGradientBrush(circle)
       b.WrapMode = WrapMode.Tile

       b.SurroundColors = New Color() {Color.Yellow}
       b.CenterColor = Color.Red
       g.FillRectangle(b, x, y, width, height)
Posted
Updated 14-Dec-13 12:56pm
v3
Comments
Sergey Alexandrovich Kryukov 14-Dec-13 16:24pm    
It depends on what graphics library/framework you are using. You also should understand transparency. This notion only makes sense if yo can see through. What are those objects you need to see through your image?
And what's your problem? What have you tried so far?

—SA
zeus1985 14-Dec-13 18:47pm    
my friend my idea is to open an image on picture box and also draw small circles on this image using the Mouse Down event and my application has a button(name=Active) when i press this button the program should draw the gradient transparent circle around each small circle
Sergey Alexandrovich Kryukov 14-Dec-13 22:04pm    
Why PictureBox, not some control directly? Better forget PictureBox; it would add you hassles and won't help at all.
Do you want transparent in for following sense: you controls behind would be seen through? (Then better forget about it with Forms, use WPF.) Or you want to draw some images/patterns on the same control, and they would be visible through your circle? Then it's easy.
—SA

1 solution

Please see my comments to the question. If you need the transparency manifested in the second sense, as I mentioned it, the way to do it is very simple, use the alpha-channel for the colors you use. This channel defines transparency. Here is how:
http://msdn.microsoft.com/en-us/library/at1k42eh%28v=vs.110%29.aspx[^].

Also, consider not using PictureBox. Please see my past answers:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900