首页 > WPF入门(三)-几何图形之不规则图形(PathGeometry) (2)

WPF入门(三)-几何图形之不规则图形(PathGeometry) (2)

WPF入门(三)->几何图形之不规则图形(PathGeometry) (2)
原文:WPF入门(三)->几何图形之不规则图形(PathGeometry) (2)

上一节我们介绍了PathGeometry中LineSegment是点与点之间绘制的一条直线,那么我们这一节来看一下点与点之间绘制曲线ArcSegment

先来看一段代码

<Window x:Class="WPF.SimpleGraph.PathFill.Window1"

        xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"

        Title
="Window1" Height="300" Width="300">

    
<Canvas>

        
<Path Stroke="DarkGray" StrokeThickness="2">

            
<Path.Data>

                
<PathGeometry>

                    
<PathFigure StartPoint="40,40" IsClosed="True">

                        
<LineSegment Point="40,130">LineSegment>

                        
<ArcSegment Point="60,150" Size="20,20" >ArcSegment>

                        
<LineSegment Point="200,150">LineSegment>

                        
<ArcSegment Point="220,130" Size="20,20">ArcSegment>

                        
<LineSegment Point="220,40">LineSegment>

                        
<ArcSegment Point="200,20" Size="20,20">ArcSegment>

                        
<LineSegment Point="60,20">LineSegment>

                        
<ArcSegment Point="40,40" Size="20,20">ArcSegment>

                    
PathFigure>

                
PathGeometry>

            
Path.Data>

        
Path>

    
Canvas>

Window>

执行结果:

 

其中ArcSegment表示一条点到点之间的曲线

 

例如该代码它

 

<PathFigure StartPoint="40,40" IsClosed="False">

                        
<ArcSegment Point="40,80" Size="20,20" >ArcSegment>

                    
PathFigure>

 

它的效果是从点(40,40)到点(40,80)之间绘制一条曲线

ArcSegment的Size属性表示该曲线的弧度及形状,详细弧度与值的关系请查考msdn

 

 

<LineSegment Point="40,130">LineSegment>

<ArcSegment Point="60,150" Size="20,20" >ArcSegment>

该代码表示画一条从StartPoint到40,130的直线,再从40,130到60,150的曲线

 

依次类推,我们便可画出一个弧形角的矩形。

posted on 2019-01-11 14:12 NET未来之路 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/lonelyxmas/p/10254872.html

更多相关: