Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have array of X,Y points that describe the motion of a 2 pendulum harmonograph. How can Paint the curve incrementally so that it mimics a physical harmonograph drawing with a pen on one pendulum and a table on the other?
Posted

1 solution

Makes no sense. You don't need PictureBox at all. Please see my past answers. You will find clear idea on what you can do:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^],
Append a picture within picturebox[^];
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].

This should be enough to get an idea on what to do. If not — your follow-up questions are welcome.

—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Mar-13 13:41pm    
[OP commented:]

Sergey
I have looked at your ideas but am too much of a novice to understand very much
I will recap. I have an array of points, graphicEnd, already scaled to fit in my PictureBox.

with this code in Sub PictureBox_Paint

pathrapid.AddLines(graphicEnd)
e.Graphics.DrawPath(penrapid, pathrapid)

all the lines are drawn at once.

What I want is for the lines to be drawn incrementally - in real time. I have tried this code

For n = LBound(graphicEnd) To UBound(graphicEnd) - 1
pathrapid.AddLine(graphicEnd(n).X, graphicEnd(n).Y, graphicEnd(n + 1).X, graphicEnd(n + 1).Y)
pathrapid.AddLines(graphicEnd)
e.Graphics.DrawPath(penrapid, pathrapid)
Next

but all the lines display at once. How can I slow the Sub Paint to show the lines
1 then 1& 2 then 1-3 then 1-4 etc.

Patrick
Sergey Alexandrovich Kryukov 11-Mar-13 13:46pm    
Patrick,

I did not get notification on your response. You should not post content like that as "solution". You can only get down-votes and abuse reports for that.

What do you mean "at once"? Do you mean you need changes step-by-step? Then this is called "animation". If you need such animation, you need to draw N steps in your rendering method, where N is a parameter (frame number). From a separate thread, update N and do Form.Invoke of some method which just calls Invalidate of the control where you render. It will trigger repainting, and it will be performed up to N steps.
Part of it (explanation of Invalidate) is in my referenced answers...

—SA

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