Animation

The graphical interface allows you to animate the displayed scene. Example:

s = box(10, center=True)
controller = disp(s)
nulltime = time.time()

def animate(widget):
trans = rotateZ(time.time() - nulltime) * right(30)
controller.relocate(trans)

show(animate=animate)

Here we use a special animation function animate, which, using the controller object returned by the disp function, updates the location of the controlled object based on the current moment in time. The transformation object is used as a parameter of the relocate method. (More details in Transformations, Transformations)

In addition to the animate parameter, the show function has associatedpreanimate and close_handle parameters. preanimate takes a function that is called once before the first iteration ofanimate, but after the graphical environment has been created. close_handle is called as a handler when the process ends.