|
-
May 3rd, 2010, 12:42 PM
#1
Error with GDI+ Sample
Hi Guys,
I am try to draw line and i want to make line rotate 360 degree and each degree changed regarding as timer intervals.
Code:
double x1, y1, r;
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red);
g.DrawEllipse(p, 0, 0, 398, 398);
Pen p1 = new Pen(Color.Black);
for (double theta = 20; r < 360; theta++)
{
theta = theta * (Math.PI / 360);
x1 = r * (Math.Cos(theta));
y1 = r * (Math.Sin(theta));
g.DrawLine(p1, (float)x1, (float)y1, 200, 198);
}
}
-
May 3rd, 2010, 12:48 PM
#2
Re: Error with GDI+ Sample
You should not be doing all of the drawing inside of a loop in the paint event. That code will run very quickly and you won't see anything at all. Painting is an incremental process; for each tick of the time you should redraw the line once. So, store the last point on the edge of the circle externally from the paint method and increment it before calling Invalidate() once again. Each call to OnPaint() should be a single refresh, a single frame.
If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.
Yes; I have a blog too - http://the-angry-gorilla.com/
-
May 3rd, 2010, 02:59 PM
#3
Re: Error with GDI+ Sample
I am try to do this change but error .......
-
May 3rd, 2010, 03:06 PM
#4
Re: Error with GDI+ Sample
What error? You could at least tell us what error you are encountering, we are not psychic.
If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.
Yes; I have a blog too - http://the-angry-gorilla.com/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|