Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 4:08am

1 solution

Rate this: bad
good
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.
 
—SA
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 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)

  Print Answers RSS
0 OriginalGriff 690
1 Maciej Los 280
2 Suvendu Shekhar Giri 229
3 Richard Deeming 195
4 Sascha Lefévre 164
0 Sergey Alexandrovich Kryukov 9,678
1 OriginalGriff 9,135
2 Peter Leow 5,082
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,606


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2015
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