2

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

事物

左侧是我从一组转换值中收到的值,但我需要它像右侧一样。

<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 的值来自转换例程,所以我不能轻易修改它们。

4

1 回答 1

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>

就如此容易。

于 2011-03-07T20:26:54.640 回答