I am trying to fill in my two half circles. I want one side black and the other side white. What do I use?
Here is a snippet of my code:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle rect = new Rectangle(100, 100, 320, 320);
e.Graphics.DrawArc(new Pen(new SolidBrush(Color.Black), 10), rect, 90, 180);
e.Graphics.DrawArc(new Pen(new SolidBrush(Color.White), 10), rect, 270, 180);
}
What you expect to be called FillArc
is actually called FillPie
.
It takes the same parameters as DrawArc
, so this will do:
e.Graphics.FillPie(Brushes.White, rect, 90, 180);
e.Graphics.FillPie(Brushes.Black, rect, 270, 180);
If you want to use the same rectangle you can 'deflate' it by 1/2 the pen width:
rect.Inflate(-5, -5);
Using
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
you get this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With