If you find yourself looking for the VCR control on some of the animations (like pause and frame advance), here's a mini VCR function. Useful on fast animation sequence like Listing 5.7 spiral sphere:
// Instruction: append to end of program
// Press right_arrow to advance frame
// Hit any other key to toggle play and pause
int _go = 1;
void keyPressed(){
if (_go == 1){
noLoop();
_go = 0;
}
else if (key == CODED) {
if (keyCode == RIGHT) {
redraw();
}
}
else {
loop();
_go = 1;
}
}
Enjoy.
|