2011-02-22 163 views
2

有沒有辦法讓ArcSegment在特定的方向繪製?據我所知,它總是從上到下。例如,我有一個ArcSegment,其中在180度(270度爲北)時開始,並將幾乎橢圓繪製到180度。現在,繪圖順時針從....順便說一句,對不起,讓我給你看看。ArcSegment的旋轉和方向

things

左邊的一個是我從一個轉換設定值接收的值,但我需要它像右邊的一個行動。

<Canvas Background="#FDB" Width="720" Height="540"> 
    <Path Canvas.Left="100" Canvas.Top="100" Stroke="#385D8A" StrokeThickness="2" StrokeLineJoin="Round" Fill="#4F81BD"> 
    <!-- this is the LEFT shape that I need drawn like the other one --> 
    <Path.Data> 
     <GeometryGroup> 
     <PathGeometry> 
      <PathGeometry.Figures> 
      <PathFigure StartPoint="0,51" IsClosed="True"> 
       <PathFigure.Segments> 
       <LineSegment Point="51,51" /> 
       </PathFigure.Segments> 
      </PathFigure> 
      <PathFigure StartPoint="25.5,0"> 
       <PathFigure.Segments> 
       <LineSegment Point="25.5,102" /> 
       </PathFigure.Segments> 
      </PathFigure> 
      <PathFigure StartPoint="25.5,51" IsClosed="True" > 
       <PathFigure.Segments> 
       <ArcSegment Size="25.5,25.5" IsLargeArc="True" SweepDirection="Clockwise" Point="25.49,51" /> 
       </PathFigure.Segments> 
      </PathFigure> 
      </PathGeometry.Figures> 
     </PathGeometry> 
     </GeometryGroup> 
    </Path.Data> 
    </Path> 
    <Path Canvas.Left="200" Canvas.Top="100" Stroke="#385D8A" StrokeThickness="2" StrokeLineJoin="Round" Fill="#4F81BD"> 
    <!-- this is the RIGHT shape, the way it should behave, but notice the different StartPoint and Point --> 
    <Path.Data> 
     <GeometryGroup> 
     <PathGeometry> 
      <PathGeometry.Figures> 
      <PathFigure StartPoint="0,51" IsClosed="True"> 
       <PathFigure.Segments> 
       <LineSegment Point="51,51" /> 
       </PathFigure.Segments> 
      </PathFigure> 
      <PathFigure StartPoint="25.5,0"> 
       <PathFigure.Segments> 
       <LineSegment Point="25.5,102" /> 
       </PathFigure.Segments> 
      </PathFigure> 
      <PathFigure StartPoint="51,25.5" IsClosed="True" > 
       <PathFigure.Segments> 
       <ArcSegment Size="25.5,25.5" IsLargeArc="True" SweepDirection="Clockwise" Point="50.99,25.5" /> 
       </PathFigure.Segments> 
      </PathFigure> 
      </PathGeometry.Figures> 
     </PathGeometry> 
     </GeometryGroup> 
    </Path.Data> 
    </Path> 
</Canvas> 

我試着RotationAngle玩弄左右,但似乎並沒有產生任何影響,因爲它僅適用於X軸,而不是Y軸。

第一個Path的值來自轉換例程,所以並不是我可以輕鬆修改它們。

回答

1

我想我已經想通了 - 只需要縮短Y軸而不是X軸。所以:

<PathFigure StartPoint="51,25.5" IsClosed="True" > 
    <PathFigure.Segments> 
     <ArcSegment Point="50.99,25.5" Size="25.5,25.5" IsLargeArc="True" SweepDirection="Clockwise" /> 
    </PathFigure.Segments> 
</PathFigure> 

應該是:

<PathFigure StartPoint="51,25.5" IsClosed="True" > 
    <PathFigure.Segments> 
     <ArcSegment Point="51,24.99" Size="25.5,25.5" IsLargeArc="True" SweepDirection="Clockwise" /> 
    </PathFigure.Segments> 
</PathFigure> 

至於這麼簡單。