我正在尝试填满我的两个半圆。我想要一侧黑色,另一侧白色。我用什么?
这是我的代码片段:
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);
}
最佳答案
您期望称为 FillArc
的实际上称为 FillPie
.
它采用与 DrawArc
相同的参数,所以这样做:
e.Graphics.FillPie(Brushes.White, rect, 90, 180);
e.Graphics.FillPie(Brushes.Black, rect, 270, 180);
如果你想使用相同的矩形,你可以将它缩小 1/2 的笔宽:
rect.Inflate(-5, -5);
使用
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
你明白了:
关于c# - 我如何填写我的半圈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33715855/