frameRate(frameRateValue);
cellsize = ( width - (2 * margin) - gutter * (gridSize - 1) ) / (gridSize - 1);
for (int i=0; i<gridSize; i++) {
for (int j=0; j<gridSize; j++) {
circleNumber = (i * gridSize) + j;
float centerpointX = margin + cellsize * i + gutter * i;
float centerpointY = margin + cellsize * j + gutter * j;
movingCircle(centerpointX, centerpointY, cellsize, circleNumber);
void movingCircle(float centerpointX, float centerpointY, float size, int circleNum) {
finalAngle = frameCount + circleNum;
float endpointX = centerpointX + (size / 2) * sin(PI / frameRateValue * finalAngle);
float endpointY = centerpointY + (size / 2) * cos(PI / frameRateValue * finalAngle);
fill(map(endpointX,0,500,0,255), 122, 121, 20);
if (sin(PI / frameRateValue * finalAngle) == 1) {
rect(endpointX, endpointY, frameRateValue, 100);
if (cos(PI / frameRateValue * finalAngle) == 1) {
rect(endpointY, endpointX, 100, frameRateValue);
ellipse(endpointX, endpointY, size/5, size/5);
stroke(map(endpointX,0,500,0,255), 122, 121, 20);
line(endpointX, endpointY, centerpointY, endpointX-100);
if (keyCode == RIGHT && frameRateValue < 60) {
if ( keyCode == LEFT && frameRateValue > 1) {
frameRate(frameRateValue);
println("Current frame Rate is: " + frameRateValue);