0

In WPF Path, I have the following value set for Data property:

Path="M0,0 L300,0 A300,300 X 0 1 210.7,210.7 z"

where X is the rotation angle according to the documentation. No matter what value I specify for X, the resulting shape remains the same. What am I doing wrong here?

Here is simple reproducible sample if anyone would like to try. Simply create a new WPF application project in Visual Studio and paste the following in Window1:

<Window x:Class="DiagramDesigner.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window2" Height="500" Width="500">
    <Canvas>
        <Path Canvas.Left="100" Canvas.Top="100" Data="M0,0 L300,0 A300,300 X 0 1 210.7,210.7 z" Stroke="Black"></Path>
    </Canvas>
</Window>

Type whatever number you wish in place of X above and you'll get the same results.

dotNET
  • 33,414
  • 24
  • 162
  • 251

1 Answers1

0

The arc that is drawn is part of the outline of an ellipse. WPF draws part of an ellipse from the previous point in the path to the new point. The rotation angle controls the angle at which that the ellipse that the arc is part of is rotated, as the ellipse may not necessarily have its major and minor axes in the horizontal and vertical directions.

In your case, the X-radius and the Y-radius of the ellipse are both 300, so you have a circular arc. It doesn't matter how you rotate a circle, it will always look the same. So if you want to take an arc that is part of a circle, the rotation angle makes no difference.

For a clearer demonstration of what happens with non-circular ellipses, try changing the angle in the following path:

    <Path Canvas.Left="100" Canvas.Top="100" Data="M0,0 A100,50 0 0 1 0,200" Stroke="Green" StrokeThickness="4" />
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
  • I see. I was hoping to use that angle value to control how wide my arc would be (e.g. 90 degrees would create a quarter pie, and 180 would create a half-circle). But it looks like we cannot use angle for that purpose. Is there any alternate way of doing that, so that I don't know the ending point of my arc, but I do know where the center of the arc is, how long are the two sides of the arc and what is the angle between the two sides. Can I use that info to create a pie? – dotNET Jul 10 '15 at 23:04
  • Feeling lucky. My problem has been address [here](http://stackoverflow.com/questions/16667072/how-to-draw-arc-with-radius-and-start-and-stop-angle). Thanks for your help. – dotNET Jul 10 '15 at 23:40