Hello Sam,
here's a piece of code that does what you need.
First it creates an empty list "red_dots", then it append an X,Y value as a tuple to the list at every frame of the animation. Then draws the entire list using the X,Y values as origins of the red dots.
(and it has a limit "maxdots" that set the maximum number of dots that are going to be drawn).
The problem with my code is that it does work ok, but redrawing the entire list gets very slow after few iterations.
Does anybody know a FASTER way to achieve this?
Thanks. Giorgio
size(400,400) background() speed(100) red_dots = [] maxdots = 1000 def setup(): pass def draw(): fill(1,0,0) x = random(WIDTH) y = random(HEIGHT) if (len(red_dots) <= maxdots): append_dot( (x, y) ) draw_dot() def append_dot( (x, y) ): red_dots.append( (x, y) ) def draw_dot(): for i in range( len(red_dots) ): #print red_dots[i] oval_centered(red_dots[i], 10) def oval_centered( (x, y) ,d): r = d/2.0 oval(x-r,y-r,d,d)
Giorgio,
This is great. It is exactly what I needed. I want to study the code a bit and may have some questions but in the meantime thanks.
A faster way may be to cache the canvas each frame and draw it the next frame, as well as drawing a dot over it. Like the "Feedback.py" example. I tried this, but without success.
I can not find the "Feedback.py" example, can you point me a link? thanks.
It's in the advanced folder… You need V1.9.x for it to be there. The script should be in your Applications/NodeBox/Examples/Advanced/Feedback.py (replace Applications with wherever you installed NB)
I think what would make this growth animation more realistic is if it grew like a bacteria, growing out from the center. For instance if every new red dot landed within a certain distance from an existing red dot while still being random. Does anyone have recommendations for doing this?
This has allready been done, but not in NB: www.jwz.org/xscreensaver
See the "Petri" saver.
animation
Posted by Sam on Oct 27, 2007I need help creating an animation that will eventually simulate a growth patten. In order to learn the software, I'm starting by randomly placing red dots in the field but cannot get the red dots to accumulate. The code i've started with below places a dot but each new frame erases the previous dot. The result i'm looking for is where over time the whole field will be covered in red dots. Thanks.