WPF:是否可以使用 GeometryDrawing 渲染一个圆? [英] WPF: is it possible to render a circle using GeometryDrawing?

查看:16
本文介绍了WPF:是否可以使用 GeometryDrawing 渲染一个圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似这样的 GeometryDrawing:

I've got a GeometryDrawing similar like this:

<DrawingImage x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type wpfhlp:FokusGroupBox},ResourceId=IconTest}">
  <DrawingImage.Drawing>
    <DrawingGroup>
      <GeometryDrawing Brush="Black" Geometry="M0,260 L0,600 L110,670 L110,500 L190,550 L190,710 L300,775 L300,430 L150,175"/>
    </DrawingGroup>
  </DrawingImage.Drawing>
</DrawingImage>

现在我想画一个圆,但我只能找到移动、画线的命令,没有画圆的命令.

Now I'd like to draw a circle instead, but I only can find commands to move, draw a line, nothing to draw a circle.

有什么方法可以让 GeometryDrawing 画一个圆吗?

Is there some way to get the GeometryDrawing to draw a circle?

推荐答案

....
<GeometryDrawing Brush="Black">
    <GeometryDrawing.Geometry>
        <EllipseGeometry Center="0,0" RadiusX="1" RadiusY="1" />
    </GeometryDrawing.Geometry>
</GeometryDrawing>

或者,您也可以使用 路径标记语法绘制两条椭圆弧(圆的上半部分和下半部分):

Alternatively, you can also use Path Markup Syntax to draw two elliptic arcs (upper and lower half of the circle):

<GeometryDrawing Brush="Black" Geometry="M -1,0 A 1,1 0 1 1 1,0 M -1,0 A 1,1 0 1 0 1,0" />

这篇关于WPF:是否可以使用 GeometryDrawing 渲染一个圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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