I need to do simple 2D modelling of atoms & molecules (random walk motion etc) but am not sure of the best approach as there seems to be many ways of animating on a form.
My own simple experiment was to use (in very basic outline):
Code:Dim graWindow As Graphics Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load graWindow = Me.CreateGraphics 'initialise "canvas" End Sub Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click iterations = 0 Do until iterations = maxIterations atoms = 0 Do Until atoms = numberOfAtoms <...code to calculate new "atom co-ords"...> graWindow.FillEllipse(<...some colour...>,<...new "atom" co-ords & size data...>) 'put atom on screen <...some sort of delay...> graWindow.FillEllipse(<...background colour...>,<...new "atom" co-ords & size data....>) 'delete atom from screen atoms += 1 Loop iterations += 1 Loop End Sub
However, I don't know if this is the accepted/standard way to animate things in VB. I've seen one code where animation was done (on a single image) using a picture box control to contain the drawn shape. But would this work for 500-1000 little picture boxes?
I'm (obviously) not experienced in VB 2012 so any detailed help on this would be great.
Thx




Reply With Quote