Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
It might sound silly, But I would like to slow down the drawing of polygons and lines in my picCanvas_Paint event.

I'm very novice at programming.
I'm using visual studio and writing in c#.

I draw polygons in the paint event from a list of points and would like it to draw slowly, like an old dos drawing program
I would like the user to be able to change the speed, but I can program the input part as a variable.
thanks for any help

What I have tried:

Haven't tried anything yet. Don't even know where to start.
Posted
Updated 29-Jan-23 5:30am
Comments
Dave Kreskowiak 29-Jan-23 10:51am    
Are you looking to see the line being drawn, slowly, from one endpoint to the other?

Or are you looking to slow down the drawing so each line pops up, slowing the drawing of the shape by line segments?
Thomas Matson 29-Jan-23 10:52am    
From one endpoint to the other....

There is no way to "slow down" the existing drawing functions.

So, you're going to have to come up with your own line drawing algorithm, like "Bresenhams line algorithm". You'll be calculating the position of each pixel in the line and drawing them yourself. But, this will NOT be so straight forward as you also have to understand how Windows interacts with your app to draw stuff. You'll have to keep track of where you are in the line drawing algorithm, like what you've drawn and current position and values, and draw SOME pixels in the line, then wait for your Paint method to be called again, draw some more pixels, and repeat until complete. Failure to understand this and properly implement it will just result in the entire line being drawn and shown on the screen all at once.
 
Share this answer
 
Quote:
How can I slow down the drawing of lines

As "drawing a line" is a single event (from Paint point of view), you can't slow it down.

The only way is to multiply the number of events, and luckily, a line is made of a lot of points.
So your solution is to set the points of a line one by one, and you play with the delay between each point.
 
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