There are several ways to accomplish this task:
You could do it in two steps, first filling the circle and then filling a triangle with the circle set as the ClippingPath
(Graphics.SetClip(path)
) of the Graphics
object.
You could do it in two steps, first rotating the Graphics object by your angle, then filling the circle and then filling a Rectangle
, again with the circle set as the ClippingPath
of the Graphics
object. Finally rotate back.
Or you can do it in one step: Create a multicolored LinearGradientBrush
, and set the positions so that the green area starts with next to no transition.
Here are two solutions using the third method (left image) and the second one (right image):


Solution one using the third method with a multicolored gradient:
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(Color.White);
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Rectangle linearGradientregion = new Rectangle(10, 10, 150, 150);
Rectangle pathRegion = new Rectangle(15, 15, 140, 140);
GraphicsPath path = new GraphicsPath();
path.AddEllipse(pathRegion);
LinearGradientBrush linearGradientBrush =
new LinearGradientBrush(linearGradientregion, Color.Red, Color.Yellow, 45);
ColorBlend cblend = new ColorBlend(4);
cblend.Colors = new Color[4] { Color.Red, Color.Yellow, Color.Green, Color.Green };
cblend.Positions = new float[4] { 0f, 0.65f, 0.65f, 1f };
linearGradientBrush.InterpolationColors = cblend;
e.Graphics.FillPath(linearGradientBrush, path);
}
Note that I didn't use your coordinate setup.. I'm sure you can adapt the numbers.
Also note that the Colors
from the constructor are not used by the Brush
!
Solution two using the second method. Note the sharp transition to green:
private void panel3_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(Color.White);
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Rectangle linearGradientregion = new Rectangle(10, 10, 95, 95);
Rectangle pathRegion = new Rectangle(15, 15, 140, 140);
int centerX = pathRegion.X + pathRegion.Width / 2;
int centerY = pathRegion.Y + pathRegion.Height / 2;
GraphicsPath path = new GraphicsPath();
path.AddEllipse(pathRegion);
LinearGradientBrush linearGradientBrush =
new LinearGradientBrush(linearGradientregion, Color.Red, Color.Yellow, 45);
e.Graphics.FillPath(linearGradientBrush, path);
e.Graphics.SetClip(path);
e.Graphics.TranslateTransform(centerX, centerY);
e.Graphics.RotateTransform(45f);
e.Graphics.FillRectangle(Brushes.Green, 25, -90, 240, 240);
e.Graphics.ResetTransform();
}
Again it is up to you to figure out the best numbers..