Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Using the following code, I get a line drawing effect.

C#
Line newLine = new Line();
newLine.StrokeThickness = 1;
newLine.Stroke = Brushes.Black;
newLine.X1 = 50;
newLine.X2 = 50;
newLine.Y1 = 50;
newLine.Y2 = 50;
DoubleAnimation lineXAnimation = new DoubleAnimation();
lineXAnimation.From = newLine.X2;
lineXAnimation.To = 500;
lineXAnimation.Duration = TimeSpan.FromSeconds(2);

newLine.BeginAnimation(Line.X2Property, lineXAnimation);


How can I get the effect of drawing a circle made in the same style?

What I have tried:

I'm looking for how to get the effect of drawing a circle?
Posted
Updated 23-May-20 22:43pm

 
Share this answer
 
Comments
Member 12618031 21-May-20 11:26am    
You offer simple static drawing methods. I'm asking about animation. Do not draw a circle, but get a drawing effect. Look carefully at the line code.
Richard Deeming 21-May-20 11:27am    
Look at the documentation again. Animating a shape is the same, regardless of the shape you're drawing.
Member 12618031 21-May-20 11:34am    
Pay attention to the effect of line drawing. Line Drawing Example[^]
Maciej Los 21-May-20 16:33pm    
5ed!
Member 12618031 22-May-20 1:36am    
Do you have a link where this is described? I can not find.
Strangely enough, but the Japanese helped to resolve the issue. The class Microsoft.Expression.Shapes.Arc makes drawing circles easier.

C#
using Microsoft.Expression.Shapes;

Arc a = new Arc();
a.ArcThicknessUnit = Microsoft.Expression.Media.UnitType.Pixel;
a.ArcThickness = 10;
a.StrokeThickness = 1;
a.Fill = new SolidColorBrush(Colors.Aqua);
a.Stroke = new SolidColorBrush(Colors.DarkMagenta);
a.StartAngle = 0;
a.EndAngle = 0;
a.Width = 200;
a.Height = 200;
a.Stretch = Stretch.None;
stp.Children.Add(a);

DispatcherTimer dt = new DispatcherTimer();
dt.Interval = TimeSpan.FromMilliseconds(10);
dt.Tick += (s, e) => { a.EndAngle = a.EndAngle + 4; };
dt.Start();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900