wpf的path画三角形、四边形

PathFigure表示几何图形的一个子部分、一系列单独连接的二维几何线段。

以StartPoint为原点,画坐标轴,Y轴箭头向下;按顺序画图。StartPoint原点始终在控件左上角,当其他点的坐标值比原点的值小,原点会偏移。 

通常为: ArcSegment 、BezierSegment, LineSegment, PolyBezierSegment, PolyLineSegment, PolyQuadraticBezierSegment, QuadraticBezierSegment.

例子1:

  

 <Path Grid.Row="0" x:Name="pathLeft" Fill="LightSkyBlue" Stretch="Fill"

HorizontalAlignment="Left" VerticalAlignment="Bottom">

<Path.Data>

<PathGeometry>

<PathFigure StartPoint="0,40">

<PathSegmentCollection>

<LineSegment Point="100,30" />

<LineSegment Point="100,60" />

</PathSegmentCollection>

</PathFigure>

</PathGeometry>

</Path.Data>

</Path>

例子2:((0,0)为控件的左上角坐标)

<Path Grid.Row="0" x:Name="pathLeft" Fill="LightSkyBlue" Stretch="Fill"

HorizontalAlignment="Left" VerticalAlignment="Bottom">

<Path.Data>

<PathGeometry>

<PathFigure StartPoint="0,0" >

<PathSegmentCollection>

<LineSegment Point="0,60" />

<LineSegment Point="100,40" />

<LineSegment Point="100,80" />

<LineSegment Point="0,60" />

</PathSegmentCollection>

</PathFigure>

</PathGeometry>

</Path.Data>

</Path>

例子3:

<Path Grid.Row="0" x:Name="pathLeft" Fill="LightSkyBlue" Stretch="Fill"

HorizontalAlignment="Left" VerticalAlignment="Bottom">

<Path.Data>

<PathGeometry>

<PathFigure StartPoint="0,0" >

<PathSegmentCollection>

<LineSegment Point="0,60" />

<LineSegment Point="100,40" />

<LineSegment Point="100,100" />

<LineSegment Point="0,100" />

</PathSegmentCollection>

</PathFigure>

</PathGeometry>

</Path.Data>

</Path>


版权声明:本文为xiaoyu812289718原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。