Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a static Processing sketch that draws circles on the screen. Your program

ID: 661996 • Letter: W

Question

Write a static Processing sketch that draws circles on the screen. Your program should have a variable called numBalls declared and initialized at the top of your code. This value determines how many balls will be drawn. The first row has numBalls, the next row has one less ball, the next row has two less, etc. Use a window size of 500x500. All the balls should be visible in the output window. There should be a little bit of space between each ball on the screen.The output of your program when numBalls is 5 and 11 will look something like the following:

Explanation / Answer

int numBalls = 11; //numBalls initialization

void setup(){
size(500 ,500); //setting up window size
}
void draw(){

int diameter = (500 / numBalls); //divide screen size by number of balls gives the diameter
int radius = diameter/2; //diameter divided by 2 gives radius

for (int i = radius; i < 500; i = i+diameter) { //select each row
for (int j = i; j < 500; j = j+diameter) { //select each column
ellipse(i, j, radius, radius); //draws circle ar (i,j) with 'radius' values as radius
}
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote