ArcSegment的旋转和方向

时间:2011-02-22 21:25:00

标签: wpf silverlight geometric-arc pathgeometry

有没有办法让ArcSegment在特定方向上绘制?据我所知,它始终是自上而下的。例如,我有一个ArcSegment,以180度(270度为北)开始,并绘制一个几乎椭圆形到180度。现在,绘图顺时针方向......好吧,对不起,让我告诉你。

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 个答案:

答案 0 :(得分: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>

就这么简单。