画两个半圆 [英] Draw two semi-circles

查看:24
本文介绍了画两个半圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用两个半圆填充一个圆.一个在左侧,另一个在右侧.左侧的圆圈应为黑色,另一侧应为蓝色.

I want to fill a circle with two semi-circles. One on the left side and the other one on the right side. The circle on the left side should be black and the other side should be blue.

我如何实现这一目标?我试图填充一个椭圆,然后在它的一半上画一个矩形.这适用于圆的一半.但是对于另一半我有问题.

How do i achieve this? I tried to fill an ellipse and then draw a rectangle over the half of it. This works for one half of the circle. But with the other halfe i have a problem.

任何想法如何绘制完整的圆圈?

Any ideas how can draw the complete circle?

推荐答案

您可以使用 Graphics.DrawArc 来实现这一点.

You can use Graphics.DrawArc to achieve this.

创建一个 windows 窗体应用程序并将此代码放入窗体中进行测试.

Create a windows forms application and drop this code into the form to test.

protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);
    Rectangle rect = new Rectangle(10, 10, 320, 320);
    e.Graphics.DrawArc(new Pen(new SolidBrush(Color.Black), 10), rect, 90, 180);
    e.Graphics.DrawArc(new Pen(new SolidBrush(Color.Blue), 10), rect, 270, 180);
}

然后更改矩形坐标以满足您的需要.

Then change the rectangle coordinates to suit your needs.

您可能想要查看的其他内容包括 DrawPieFillPie.从逻辑上讲,一个有两半的馅饼应该"画两个半圆.上面的例子只是绘制了两个半圆的轮廓.

Other things you might want to look at are, DrawPie, FillPie. Thinking logically, a pie which has two halves "should" draw two filled semi circles. The example above will just draw an outline of two semi-circles.

这篇关于画两个半圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆