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

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

问题描述

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

现在我想绘制一个圆圈,但我只能找到移动,绘制

有没有办法让GeometryDrawing绘制一个圆圈?

解决方案

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

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

 < GeometryDrawing Brush =BlackGeometry =M -1,0 A 1,1 0 1 1 1,0 M -1,0 A 1,1 0 1 0 1,0/> 


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.

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天全站免登陆