Click here to Skip to main content
13,050,429 members (133,337 online)
Rate this:
Please Sign up or sign in to 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 28-Nov-12 3:08am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

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.

Sergey Alexandrovich Kryukov 11-Mar-13 13:41pm
[OP commented:]

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)

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.

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

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


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100