Answered by:
XAML C# How to draw curve

Question
-
Is there any method like
canvas.drawCurve(angel, width, height);
to produce the curve in the following image
?
Monday, September 16, 2013 1:16 PM
Answers
-
I think with the ArcSegment it's not as easy. You need to do a little bit of calculation to get the values you need to draw a 45° curve. The easiest way is to take a look at this blog-post. It animates a pie. There you can read how he creates the arcsegment with different angles.
http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-slice.html
Thomas Claudius Huber
"If you can´t make your app run faster, make it at least look & feel extremly fast"
twitter: @thomasclaudiush
homepage: www.thomasclaudiushuber.com
author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook- Marked as answer by Anne Jing Wednesday, September 25, 2013 1:12 AM
Tuesday, September 17, 2013 9:39 AM
All replies
-
Hi N2V,
you can do this like below:
<Path Stroke="White" StrokeThickness="10" Margin="0"> <Path.Data> <PathGeometry> <PathFigure StartPoint="0,0"> <ArcSegment Point="200,300" Size="200,200" IsLargeArc="True" SweepDirection="Counterclockwise"/> </PathFigure> </PathGeometry> </Path.Data> </Path>
Of course, you could use the PathGeometry-class and corresponding classes also in C#.
Thomas
Thomas Claudius Huber
"If you can´t make your app run faster, make it at least look & feel extremly fast"
twitter: @thomasclaudiush
homepage: www.thomasclaudiushuber.com
author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook- Proposed as answer by Anne Jing Tuesday, September 17, 2013 6:08 AM
Monday, September 16, 2013 1:31 PM -
Thank you Thomas, but what each property do? can I draw based on angel (say 45) and to be changed in code?.Tuesday, September 17, 2013 6:56 AM
-
By "based on angle" you mean you want to draw a circle and based on your code just a specific angle of it? So like having a "Pacman" opening and closing his mouth? :)
Thomas Claudius Huber
"If you can´t make your app run faster, make it at least look & feel extremly fast"
twitter: @thomasclaudiush
homepage: www.thomasclaudiushuber.com
author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbookTuesday, September 17, 2013 7:36 AM -
I mean if I pass 180 as to angel parameter I'll produce the right shape in the attached image bellow, if 45 the left shape will be produced
Tuesday, September 17, 2013 9:11 AM -
I think with the ArcSegment it's not as easy. You need to do a little bit of calculation to get the values you need to draw a 45° curve. The easiest way is to take a look at this blog-post. It animates a pie. There you can read how he creates the arcsegment with different angles.
http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-slice.html
Thomas Claudius Huber
"If you can´t make your app run faster, make it at least look & feel extremly fast"
twitter: @thomasclaudiush
homepage: www.thomasclaudiushuber.com
author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook- Marked as answer by Anne Jing Wednesday, September 25, 2013 1:12 AM
Tuesday, September 17, 2013 9:39 AM