COMP 1005 Lecture Notes - Frame Rate, Global Variable, Ellipse
Document Summary
The draw function: unusual function which introduces a time element into the code. Called automatically from after setup() and is like an infinite loop. It executes the code inside the function perpetually. Can be stopped by stopping the program or calling the noloop() function from within the function. The number of times n the draw() function executes in each second may be controlled with the framerate() function. The default frame rate is 60 frames per second but you can e. g. make it say 30 frames per second as follows: framerate(30) // make these variables global int x= 20; int y =250; int radius=20; void setup(){ size(500,500); framerate (60); // the draw function void draw(){ drawcircle( ); void drawcircle(){ background(0); // set background to zero wipes out previous circle ellipse(x, y, radius, radius); //when circle gets to the right hand side reset it to the left hand side if(x>480){ x=20;} else.