I'm stuck at this problem for few hours but can't seem to make progress.
I have a perfect annulus (Fig 1), but when I increase the inner ellipse, I'm loosing the drawing (Fig 2)
I guess that I need to scale Blend.Factor and/or Blend.Positions, but I don't know hoy to do it.
This is my Factor and Position arrays:
_Factors = new float[] { 0f, 1f, 0f, 0f };
_Positions = new float[] { 0f, 0.25f, 0.5f, 1f };
And this is my Paint function:
using (Brush oInnerBrush = new SolidBrush(_InnerColor))
{
using (Pen oBaseBrush = new Pen(_BaseColor, 2))
{
using (GraphicsPath oGraphPath = new GraphicsPath())
{
// Outside
oGraphPath.AddEllipse(oRect);
// Inside
oGraphPath.AddEllipse(oRect.Shrink(_InnerWidth));
using (PathGradientBrush oGradBrush = new PathGradientBrush(oGraphPath))
{
Blend oBlend = new Blend();
oBlend.Factors = _Factors;
oBlend.Positions = _Positions;
oGradBrush.Blend = oBlend;
oGradBrush.CenterColor = ((SolidBrush)oInnerBrush).Color;
oGradBrush.SurroundColors = new Color[] { oBaseBrush.Color };
Area.FillPath(oGradBrush, oGraphPath);
}
}
}
}
Any ideas? Thank you.
EDIT: I'm using the code in this question by BlueMonkMN