Blake81
Well-known member
I made an analog clock in GDI and I am trying to fill a circle in the center using a gradient brush to cover up the fact that the clock hands don't meet exactly in the same place. I'm noticing a strange effect on the right side of the circle when I do this. Could someone look at my code and tell me if they can see where the problem is? Thanks.
VB.NET:
Public Sub draw(ByVal imgDraw As Graphics)
Dim x As New Drawing.Drawing2D.PathGradientBrush(Path)
Dim mycolor(3) As Color
If filled Then
mycolor.SetValue(Color.Black, 0)
mycolor.SetValue(Color.Gold, 1)
mycolor.SetValue(Color.Black, 2)
x.CenterColor = Color.White
x.SurroundColors = mycolor
imgDraw.FillPath(x, Path)
imgDraw.DrawPath(Pens.Black, Path)
ElseIf secfilled Then
imgDraw.DrawPath(New Pen(Color.Red, 2), Path)
End If
mycolor.SetValue(Color.Black, 0)
mycolor.SetValue(Color.Gold, 1)
mycolor.SetValue(Color.Black, 2)
Dim cpath As New Drawing2D.GraphicsPath()
Dim cpoint As Point
cpoint.X = 130
cpoint.Y = 130
Dim rect As Rectangle
rect.Location = cpoint
rect.Width = 35
rect.Height = 35
cpath.AddEllipse(cpoint.X, cpoint.Y, rect.Width, rect.Height)
cpath.FillMode = Drawing2D.FillMode.Alternate
Dim cgrad As New Drawing.Drawing2D.PathGradientBrush(cpath)
cgrad.CenterColor = Color.Black
Dim mycolortwo(3) As Color
mycolortwo.SetValue(Color.Black, 0)
mycolortwo.SetValue(Color.Gold, 1)
mycolortwo.SetValue(Color.Black, 2)
cgrad.SurroundColors = mycolortwo
imgDraw.DrawEllipse(Pens.Black, rect)
imgDraw.FillEllipse(cgrad, cpoint.X, cpoint.Y, rect.Width, rect.Height)
End Sub