WPF里的几何图形Path绘制

Shape类

2、Ellipse

3、Rectangle

4、Line

5、Polyline

6、Polygon

7、Path

|-------------------|----------|-----------------------------------------------------------------------------------|
| 名称 | | |
| LineGeometry | 简单几何 | 作用类似于Shape中的Line |
| RectangleGeometry | 简单几何 | 作用类似于Shape中的Rectangle |
| EllipseGeometry | 简单几何 | 作用类似于Shape中的Ellipse |
| GeometryGroup | 用于创建复合几何 | 为单个路径添加任意多个Geometry对象,使用EvenOdd或NonZero填充规则来确定要填充的区域。 |
| CombinedGeometry | 用于创建复合几何 | 将两个几何图形合并为一个形状。可使用CombineMode属性选择如何组合两个几何图形。 |
| PathGeometry | 路径几何 | 代表更复杂的弧线、曲线以及直线构成的图形,并且既可以是闭合的,也可以是不闭合的。 |
| StreamGeometry | 路径几何 | 相当于PathGeometry的只读轻量级。StreamGeometry图形可节省内存,因为它不在内存中同时保存路径的所有分段。并且这类图形一旦被创建就不能再修改 |

LineGeometry

XML 复制代码
<Line X1="10" Y1="10" X2="100" Y2="50" Stroke="Orange" StrokeThickness="4"  StrokeStartLineCap="Round" StrokeEndLineCap="Round"></Line>
<Path Stroke="Green" StrokeStartLineCap="Round" StrokeThickness="4" StrokeEndLineCap="Round">
    <Path.Data>
        <LineGeometry StartPoint="10,10" EndPoint="100,50"></LineGeometry>
    </Path.Data>
</Path>

EllipseGeometry

RectangGeometry

XML 复制代码
<Ellipse Height="40" Width="40" Stroke="Orange" StrokeThickness="4" Fill="Green" HorizontalAlignment="Left"></Ellipse>
<Path Stroke="Green" StrokeThickness="4" Fill="Red">
    <Path.Data>
        <EllipseGeometry Center="20,50" RadiusX="20" RadiusY="20"></EllipseGeometry>
    </Path.Data>
</Path>    
XML 复制代码
 <Path Fill="Orange">
     <Path.Data>
         <RectangleGeometry Rect="10 5 100 50"></RectangleGeometry>
     </Path.Data>
 </Path>

ArcGeometry

IsLargeArc,SweepDirection属性介绍

IsLargeArc 为true选择大的那个圆弧,否则选择小的

SweepDirection="Clockwise" 选择顺时针的路线,为CounterClockwise则是逆时针

XML 复制代码
<Path Stroke="LightGreen" Fill="Red" StrokeThickness="5">
    <Path.Data>
        <PathGeometry>
            <PathGeometry.Figures>
                <PathFigure StartPoint="50,50">
                    <PathFigure.Segments>
                        <ArcSegment Size="100,50" IsLargeArc="False" RotationAngle="0" SweepDirection="Clockwise" Point="50,10" />
                    </PathFigure.Segments>
                </PathFigure>
            </PathGeometry.Figures>
        </PathGeometry>
    </Path.Data>
</Path>

<Path Stroke="LightGreen" Fill="Red" StrokeThickness="5">
    <Path.Data>
        <PathGeometry>
            <PathGeometry.Figures>
                <PathFigure StartPoint="50,50">
                    <PathFigure.Segments>
                        <ArcSegment Size="100,50" IsLargeArc="True" RotationAngle="0" SweepDirection="Clockwise" Point="50,10" />
                    </PathFigure.Segments>
                </PathFigure>
            </PathGeometry.Figures>
        </PathGeometry>
    </Path.Data>
</Path>
<Path Stroke="LightGreen" Fill="Red" StrokeThickness="5">
    <Path.Data>
        <PathGeometry>
            <PathGeometry.Figures>
                <PathFigure StartPoint="50,50">
                    <PathFigure.Segments>
                        <ArcSegment Size="100,50" IsLargeArc="True" RotationAngle="0" SweepDirection="Counterclockwise" Point="50,10" />
                    </PathFigure.Segments>
                </PathFigure>
            </PathGeometry.Figures>
        </PathGeometry>
    </Path.Data>
</Path>
<Path Stroke="LightGreen" Fill="Red" StrokeThickness="5">
    <Path.Data>
        <PathGeometry>
            <PathGeometry.Figures>
                <PathFigure StartPoint="50,50">
                    <PathFigure.Segments>
                        <ArcSegment Size="100,50" IsLargeArc="False" RotationAngle="0" SweepDirection="Counterclockwise" Point="50,10" />
                    </PathFigure.Segments>
                </PathFigure>
            </PathGeometry.Figures>
        </PathGeometry>
    </Path.Data>
</Path>

RotationAngle

沿着切口面顺时针旋转,效果如下

这几个属性对以后画 圆环进度条非常有帮助,后面的有空再写

相关推荐
bugcome_com1 天前
WPF样式进阶实战:外置样式+MVVM主题切换+样式优先级全解析
c#·.net·wpf
lalala_Zou2 天前
场景题:电商平台订单未支付过期如何实现自动关闭订单?
wpf
czhc11400756632 天前
wpf 16
wpf
cn_mengbei2 天前
鸿蒙PC原生应用开发实战:ArkTS与DevEco Studio从零构建跨端桌面应用全栈指南
华为·wpf·harmonyos
lingxiao168883 天前
WebApi详解+Unity注入--上篇:基于Framework的WebApi
c#·wpf·web
是一个Bug3 天前
Java后端开发面试题清单(50道) - 分布式基础
java·分布式·wpf
无心水3 天前
【分布式利器:腾讯TSF】4、TSF配置中心深度解析:微服务动态配置的终极解决方案
分布式·微服务·架构·wpf·分布式利器·腾讯tsf·分布式利器:腾讯tsf
lingxiao168883 天前
WebApi详解+Unity注入--下篇:Unity注入
unity·c#·wpf
无心水4 天前
【分布式利器:腾讯TSF】6、TSF可观测性体系建设实战:Java全链路Metrics+Tracing+Logging落地
java·分布式·架构·wpf·分布式利器·腾讯tsf·分布式利器:腾讯tsf
故事不长丨4 天前
C#字典(Dictionary)全面解析:从基础用法到实战优化
开发语言·c#·wpf·哈希算法·字典·dictionary·键值对