In the top
public static GraphicsPath path;
PointF p;
double anglecounter;
In paint event
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
DrawRectangle(e, pictureBox1, 3, Color.Blue);
anglecounter += 1;
DrawLine(e.Graphics, anglecounter);
}
DrawLine
private void DrawLine(Graphics g, double angle)
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
int r = pictureBox1.Size.Width / 2;
int X1 = pictureBox1.Size.Width / 2;
int Y1 = pictureBox1.Size.Height / 2;
Point pStart = new Point(X1, Y1);
int X2 = (int)(X1 + r * Math.Cos((double)angle / Math.PI / 180));
int Y2 = (int)(Y1 + r * Math.Sin((double)angle / Math.PI / 180));
Point pEnd = new Point(X2, Y2);
g.DrawEllipse(new Pen(Color.Red, 2f), 0, 0, pictureBox1.Size.Width, pictureBox1.Size.Height);
Rectangle rec = new Rectangle(0, 0, pictureBox1.Size.Width, pictureBox1.Size.Height);
path = new GraphicsPath();
path.AddPie(rec, (int)angle, -50);
PathGradientBrush brush = new PathGradientBrush(path);
brush.CenterPoint = pStart;
brush.CenterColor = Color.LightGreen;
brush.SurroundColors = new Color[] { Color.Empty };
g.FillPath(brush, path);
p = path.GetLastPoint();
}
It's drawing the pie and the pie is moving in circles in the pictureBox1, the problem is the pie not moving in circles smooth enough, it seems that there is some stuttering or delay small one but there is.
The second problem is how to increase/decrease the rotation in circles speed ? if I change the paint event this line for example to 10
anglecounter += 10;
then it will rotate in circles faster but also in "jumps" of 10 each time. it's not really increasing the speed.