13,050,429 members (133,337 online)
Rate this:
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 28-Nov-12 3:08am

Rate this:

## Solution 1

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
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

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)
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

Top Experts
Last 24hrsThis month
 OriginalGriff 308 Sheila Pontes 125 Graeme_Grant 81 Kornfeld Eliyahu Peter 70 omerkamran 40
 OriginalGriff 5,271 RickZeeland 1,944 ppolymorphe 1,758 F-ES Sitecore 1,566 Dave Kreskowiak 1,389