Como: Criar um Shape usando um PathGeometry
Este exemplo mostra como criar uma forma usando a PathGeometry classe. PathGeometryobjetos são compostos de um ou mais PathFigure objetos; cada PathFigure representa a "Figura" diferente ou forma. Each PathFigure is itself composed of one or more PathSegment objects, each representing a connected portion of the figure or shape. Segment types include LineSegment, ArcSegment, and BezierSegment.
Exemplo
The following example uses a PathGeometry to create a triangle. The PathGeometry is displayed using a Path element.
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure IsClosed="True" StartPoint="10,100">
<PathFigure.Segments>
<PathSegmentCollection>
<LineSegment Point="100,100" />
<LineSegment Point="100,50" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
The following illustration shows the shape created in the previous example.
A triangle created with a PathGeometry
The previous example showed how to create a relatively simple shape, a triangle. A PathGeometry can also be used to create more complex shapes, including arcs and curves. For examples, see Como: Criar um arco de elipse, Como: Criar uma curva cúbica de Bézier, and Como: Criar uma curva Bézier quadrática..
Este exemplo é parte de uma amostra maior; Para obter o exemplo completo, consulte o A amostra de geometrias.