【问题标题】:Rotation and Direction of ArcSegmentArcSegment 的旋转和方向
【发布时间】:2011-07-02 07:59:02
【问题描述】:

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

【问题讨论】:

    标签: wpf silverlight geometric-arc pathgeometry


    【解决方案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>
    

    就这么简单。

    【讨论】:

      猜你喜欢
      • 2015-09-30
      • 1970-01-01
      • 2021-09-30
      • 1970-01-01
      • 2015-07-07
      • 2015-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多