2011-05-19 126 views
3

我怎麼能在它創建一個橢圓(路徑,...)有孔:橢圓有孔

Ellipse with hole

的任務是創建一個三態指示器的可視化。通過將控制器向左或向右旋轉幾度,可以看到不同的狀態。

回答

3

=>

<Path Stroke="Red" StrokeThickness="20"> 
     <Path.Data> 
      <PathGeometry> 
       <PathFigure StartPoint="80,0"> 
        <ArcSegment x:Name="ArcSeg1" Size="100,100" RotationAngle="0" IsLargeArc="True" 
       SweepDirection="Clockwise" Point="20,0" > 
        </ArcSegment> 
       </PathFigure> 
      </PathGeometry> 
     </Path.Data> 
    </Path> 

有幾個相關屬性這裏,瞭解數學背後看到 http://www.charlespetzold.com/blog/2008/01/Mathematics-of-ArcSegment.html 但基本上你給兩個橢圓的交點座標:intersection

StartPoint和Point表示相交點,而Size是完整橢圓的大小。其餘的很自我解釋。 如果你想旋轉它,最簡單和最好的方法是使用RotateTransform。

0

會使'洞'成爲一個白色的三角形整圓的幫助?這可以與「指針」(線)一起圍繞圓的中心旋轉。

I can only apologise for my crude rendering

+0

我不知道。這就是我問的原因。 ;) – PVitt 2011-05-19 06:55:15

0

您可以使用CombinedGeometryGeometryCombineMode="Exclude"

documentation有一個很好的例子。 example of combined geometry

+0

就我所瞭解的CombinedGeometry而言,第二個橢圓也是可見的,因爲可見性是通過環繞路徑控制的,而不是兩個組合的幾何對象。 – PVitt 2011-05-19 07:15:57

+0

這是不正確的。 GeometryCombineMode ='Exclude'完全符合它所說的內容,而CombinedGeometry是從輸入計算得出的'新'幾何圖形。我真的認爲這是一個更靈活的方法,然後手動計算ArcSegment。 – 2012-04-12 00:03:54