Home | Pictures of 3D objects

# Limiting the Animation Rate rate( frequency, wait ) Halts computations until 1/frequency seconds after the previous call to rate(). For example, rate(50, wait) will halt computations long enough to make sure that at least 1.0/50.0 second has elapsed since the last execution. If this much time has already elapsed, no halt is performed. If you place rate(50, wait) inside a computational loop, the loop will execute at a maximum of 50 times per second, even if the computer can run faster than this. This makes animations look about the same on computers of different speeds, as long as the computers are capable of carrying out 50 computations per second. Functions and "wait" For technical reasons, a function that contains statements that include the wait keyword must also contain this keyword among the arguments to that function: def pause(T,wait): scene.caption.text('Wait '+T+' sec') sleep(T,wait) b = box() pause(3,wait) b.color = color.red scene.caption.text('Done') Related options sleep(2,wait) # wait 2 seconds update(wait) # let web page update # Wait for a click, with an icon prompt: scene.pause(wait) # Wait for a click, with a text prompt: scene.pause("Click to proceed",wait) # Wait till next web page update: scene.waitfor("redraw",wait) # Wait till end of next web page update: scene.waitfor("draw_complete",wait) The difference between update(wait) and scene.waitfor("redraw",wait) is that if the browser has nothing to do, update takes only a few milliseconds, whereas scene.waitfor("redraw",wait) waits until the start of the next canvas update to be performed, which may wait for as much as 1/60th of a second (about 16 milliseconds). scene.waitfor("draw_complete",wait) waits until the end of the next canvas update

Top of page