2012-11-27 47 views
0

我要畫,看起來像我的例子(油漆我的意思大致drawed)的橢圓形(或別的東西嗎?)WPF橢圓切割頂部和底部關閉

Ellipse

任何建議如何發展這個 ?

我想剪輯,但我只能切斷頂部或底部,那麼(還是我做某事錯?)

<Canvas Width="16" Height="16"> 
    <Ellipse Fill="Red" MinHeight="16" Name="ellipse1" Stroke="White" StrokeThickness="1" MinWidth="16" > 
     <Ellipse.Clip> 
      <RectangleGeometry Rect="0,0,16,10"/> 
     </Ellipse.Clip> 
    </Ellipse> 
</Canvas> 

最好的是,如果它是一個圓形的dynamiclly的大小發生變化的內容

感謝馬庫斯

+0

你能畫一個矩形,並將其夾在其與橢圓相交? –

+0

RadiusX和RadiusY設置的矩形幾乎可以做任何你想做的事情,除非你想*尖銳的邊緣。下面的路徑答案可以用一個更簡單的矩形重複。 –

回答

3

我愛的是你提供的屏幕截圖!剪輯應該能夠提供我認爲你在之後的頂部和底部剪輯,請參見下文。

enter image description here

<Canvas Width="16" Height="16" Margin="80,50,421,254"> 
    <Ellipse Fill="Red" MinHeight="16" Name="ellipse1" Stroke="White" StrokeThickness="1" MinWidth="16" Height="100" Width="100" > 
     <Ellipse.Clip> 
      <RectangleGeometry Rect="0,25,100,50"/> 
     </Ellipse.Clip> 
    </Ellipse> 
</Canvas> 

的RectangleGeometry的性質是(按順序)左偏移,頂部補償,寬度,高度。因此請啓動您希望頂部切割的剪輯區域,然後將其停在要切割底部的位置。

5

使用Path

<Canvas> 
    <Path Data="M 30, 0 A 10,10 90 0 1 30,20 H 10 A 10,10 90 0 1 10,0 Z" 
      Fill="Red" Stroke="Black"/> 
</Canvas> 

enter image description here

+0

+1,這也給出了尺寸的變化 – Andy