Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
731 views
in Technique[技术] by (71.8m points)

geometry - WPF: is it possible to render a circle using 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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
....
<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" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...