【问题标题】:Drawing a circle using a PointF as its center c#以PointF为中心绘制圆c#
【发布时间】:2011-04-05 09:03:43
【问题描述】:

我正在寻找这个,但我找不到任何东西。这个想法是我有一个像 (52.66, 60.11) 这样的 PointF,我想以这个 PointF 为中心画一个空圆。我试图用 DrawEllipse 做,但它不关心中心!它只是一个矩形...我认为应该使用某种转换公式?

【问题讨论】:

  • 画一个空的圆圈?

标签: c# bitmap draw picturebox geometry


【解决方案1】:

您可以从中心和半径计算矩形的坐标:

float x = center.X - radius;
float y = center.Y - radius;
float width = 2 * radius;
float height = 2 * radius;
graphics.DrawEllipse(pen, x, y, width, height);

【讨论】:

    【解决方案2】:

    心不在焉:

    RectangleF circle2Rect(Point midPoint, float radius) {
       return new RectangleF(midPoint.X-radius,
                            midPoint.Y-radius,
                            radius*2,
                            radius*2); 
    }
    

    (未测试) 使用它将圆的参数转换为矩形进行绘制。

    【讨论】:

      【解决方案3】:

      如果你画一个具有相同高度和宽度的椭圆,你会得到一个圆,如果你需要知道绘制圆的正方形的左上角和右下角的坐标,那么知道中间点就很平庸了(中)。

      【讨论】:

        猜你喜欢
        • 2019-01-21
        • 1970-01-01
        • 2017-02-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多