How to scale factors and position for blending
I have been stuck with this issue for hours but cannot make any progress.
I have a perfect ring (Fig. 1), but when I enlarge the inner ellipse, I lose the drawing (Fig. 2)
I am guessing that I need to scale the Blend.Factor and / or Blend.Positions, but I don't know how.
These are 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.
EDIT: I am using the code from this BlueMonkMN question
+3
source to share
No one has answered this question yet
See similar questions:
or similar: