自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Windows Phone開發(fā)(32):路徑之PathGeometry

移動開發(fā)
Windows Phone是微軟發(fā)布的一款手機操作系統(tǒng),它將微軟旗下的Xbox Live游戲、Xbox Music音樂與獨特的視頻體驗整合至手機中。

說起路徑這玩意兒,其實說的就是Path類,它藏在命名空間 System.Windows.Shapes下,應(yīng)該好找,它有一個很重要的屬性Data,你不妨在“對象瀏覽器”中把它抓出來看看,該屬性為 System.Windows.Media.Geometry類型,如果大家再查看一下,這個Geometry類是一個抽象類,就是因為它太抽象了,所以 不能被實例化。

然后,我們看看它有哪些派生類?

1、EllipseGeometry:好理解吧,一個幾何圖形,啥形狀的?圓 or 橢圓。

2、LineGeometry:這個家伙直來直去的,你更明白了,一條線的幾何圖形,兩點一線啊。

3、RectangleGeometry:這個也好說,二維矩形。

4、PathGeometry:這個東東就有些個復(fù)雜了,它可以由弧線,曲線、直線、橢圓、矩形等組成的復(fù)雜路徑。

5、GeometryGroup:如果上述幾何圖形滿足不了你貪婪的需求的話,不妨試試這個,它可以把上述的各種幾何圖形組合成一個幾何圖形。

平常人們總喜歡從易到難地去說明問題,那么今天我們何不反過來試試,從難到易地去學(xué)習(xí),如何?

在以上所列之圖形中,當(dāng)數(shù)PathGeometry最復(fù)雜,我們就拿它開刀,好不?只要把它干倒了,其實的就好學(xué)了。

首先,我們來看一看PathGeometry的結(jié)構(gòu)再說吧。它包含一個Figures 集合,而集合中每個元素都是一個PathFigure對象。然后,再往下拆,PathFigure類也有個集合屬性Segments,該集合中的每個元素 為PathSegment對象,但我們從“對象瀏覽器”中看到,PathSegment是一個抽象類,所以我們要繼續(xù)往下找到它的派生類。

PathSegment類的派生如下圖所示:

接下來,我們逐個演示一個它們的用法吧。

一、ArcSegment畫弧線

該類表示一個圓,IsLargeArc屬性指示圓弧是否大于180度,Point是圓弧的終點,Size是圓弧的大小……其實這些屬性不必要一個個介紹,大家有興趣自己玩一下就知道了,下面給出一個例子。

  1. <Grid> 
  2.     <Path HorizontalAlignment="Stretch" 
  3.           VerticalAlignment="Stretch" 
  4.           Stroke="{StaticResource grBrush}" 
  5.           StrokeThickness="12"
  6.         <Path.Data> 
  7.             <PathGeometry> 
  8.                 <PathFigure StartPoint="325,190"
  9.                     <ArcSegment IsLargeArc="True" Point="365,410" Size="100,200" /> 
  10.                 </PathFigure> 
  11.             </PathGeometry> 
  12.         </Path.Data> 
  13.     </Path> 
  14. </Grid> 

運行效果

 二、三次貝塞爾曲線

BezierSegment類具有兩個控制點和一個終點,如下面例子:

  1. <Grid> 
  2.     <Path HorizontalAlignment="Stretch" VerticalAlignment="Stretch" StrokeThickness="8" Stroke="{StaticResource grBrush}"
  3.         <Path.Data> 
  4.             <PathGeometry> 
  5.                 <PathFigure StartPoint="28,17"
  6.                     <BezierSegment Point1="250,25" Point2="-100,245" Point3="300,450"/> 
  7.                 </PathFigure> 
  8.             </PathGeometry> 
  9.         </Path.Data> 
  10.     </Path> 
  11. </Grid> 

運行效果如下圖所示。

三、兩點一線LineSegment

這個就更簡單了。

  1. <Grid> 
  2.     <Path HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stroke="{StaticResource grBrush}" StrokeThickness="8"
  3.         <Path.Data> 
  4.             <PathGeometry> 
  5.                 <PathFigure StartPoint="15,35"
  6.                     <LineSegment Point="120,245"/> 
  7.                     <LineSegment Point="370,385"/> 
  8.                 </PathFigure> 
  9.             </PathGeometry> 
  10.         </Path.Data> 
  11.     </Path> 
  12. </Grid> 

運行效果如下圖所示:

四、更復(fù)雜的三次貝賽爾曲線PolyBezierSegment

這個家伙與前面說的三次貝賽爾曲線相似,但可以定義一條或多條,Points集合中每三個點確定一段貝賽爾曲線。

  1. <Grid> 
  2.     <Path HorizontalAlignment="Stretch" VerticalAlignment="Stretch" StrokeThickness="8" Stroke="{StaticResource grBrush}"
  3.         <Path.Data> 
  4.             <PathGeometry> 
  5.                 <PathFigure StartPoint="250,38"
  6.                     <PolyBezierSegment> 
  7.                         <PolyBezierSegment.Points> 
  8.                             <Point X="16" Y="75"/> 
  9.                             <Point X="300" Y="100"/> 
  10.                             <Point X="92" Y="134"/> 
  11.                             <Point X="45" Y="200"/> 
  12.                             <Point X="23" Y="280"/> 
  13.                             <Point X="358" Y="460"/> 
  14.                         </PolyBezierSegment.Points> 
  15.                     </PolyBezierSegment> 
  16.                 </PathFigure> 
  17.             </PathGeometry> 
  18.         </Path.Data> 
  19.     </Path> 
  20. </Grid> 

運行效果如圖所示。

五、多線段集合PolyLineSegment

與前面所說的線不同的是,它可以包含多條線。

  1. <Grid> 
  2.     <Path HorizontalAlignment="Stretch" VerticalAlignment="Stretch" StrokeThickness="8" Stroke="{StaticResource grBrush}"
  3.         <Path.Data> 
  4.             <PathGeometry> 
  5.                 <PathFigure StartPoint="111,32"
  6.                     <LineSegment Point="79,133"/> 
  7.                     <LineSegment Point="122,298"/> 
  8.                     <LineSegment Point="365,277"/> 
  9.                     <LineSegment Point="22,399"/> 
  10.                     <LineSegment Point="380,458"/> 
  11.                 </PathFigure> 
  12.             </PathGeometry> 
  13.         </Path.Data> 
  14.     </Path> 
  15. </Grid> 

運行效果如下圖所示。

六、復(fù)合二次貝賽爾曲線PolyQuadraticBezierSegment

該復(fù)合曲線可包含一或N多個二次貝賽爾曲線,由于二次貝賽爾曲線只有一個控制點和終點,故Points是每兩個點決定一條貝賽爾曲線。

  1. <Grid> 
  2.     <Path VerticalAlignment="Stretch" HorizontalAlignment="Stretch" StrokeThickness="8" Stroke="{StaticResource grBrush}"
  3.         <Path.Data> 
  4.             <PathGeometry> 
  5.                 <PathFigure StartPoint="20,25"
  6.                     <PolyQuadraticBezierSegment  Points="96,111 137,60 220,250 330,420"/> 
  7.                 </PathFigure> 
  8.             </PathGeometry> 
  9.         </Path.Data> 
  10.     </Path> 
  11. </Grid> 

運行效果如下圖所示。

七、兩點決定一條二次貝賽爾曲線QuadraticBezierSegment

這個相信比上面那個好理解。

  1. <Grid> 
  2.     <Path HorizontalAlignment="Stretch" VerticalAlignment="Stretch" StrokeThickness="8" Stroke="{StaticResource grBrush}"
  3.         <Path.Data> 
  4.             <PathGeometry> 
  5.                 <PathFigure StartPoint="200,25"
  6.                     <QuadraticBezierSegment Point1="10,300" Point2="385,435"/> 
  7.                 </PathFigure> 
  8.             </PathGeometry> 
  9.         </Path.Data> 
  10.     </Path> 
  11. </Grid> 

運行效果如下圖所示。

責(zé)任編輯:閆佳明 來源: oschina
相關(guān)推薦

2013-04-23 16:55:15

Windows Pho路徑之其它Geomet

2013-04-23 16:59:22

Windows Pho路徑標(biāo)記語法

2013-07-31 13:13:50

Windows PhoMVVM模式

2013-04-24 13:19:06

Windows Pho動畫DoubleAni

2013-04-24 13:31:59

Windows Pho動畫之ColorAni

2013-04-24 13:43:10

Windows Pho動畫PointAnim

2013-07-31 13:36:07

Windows PhoVS調(diào)試技巧Windows Pho

2013-07-30 12:37:56

Windows PhoWindows Pho

2010-04-21 17:07:54

Windows Pho

2011-06-07 12:42:15

Windows Pho

2013-04-17 14:00:06

Windows PhoWindows Pho

2013-04-16 17:02:50

Windows Pho概論

2013-04-19 16:34:56

Windows PhoWindows Pho

2013-07-30 11:18:37

Windows PhoWindows Pho

2010-08-06 15:44:28

Windows PhoWindows PhoSilverlight

2010-04-08 17:40:23

Windows Pho

2013-04-17 13:27:04

Windows PhoWindows Pho

2011-06-07 11:35:38

Windows Pho

2012-08-16 10:35:50

Windows Pho

2013-04-17 14:47:19

Windows PhoWindows Pho
點贊
收藏

51CTO技術(shù)棧公眾號