Hi, I am hoping someone can help me again with my Processing assignment. This is a red and black checker board. The question is “add one line of code that will create a circle using the ellipse function and place it on the black square as shown by the illustration.”
Here is what I have so far. The last line is the one that I can’t figure out. Thanks in advance for any help.
int squareSize = 50; // Dimensions ask for 40x40
int cols, rows;
void setup() {
size(500, 500); // Specified by assignment
// Initialize columns and rows
cols = 10; // Specified by assignment | size/squareSize
rows = 10; // Specified by assignment | size/squareSize
}
void draw() {
// Begin loop for columns
for (int i = 0; i < cols; i++) {
// Begin loop for rows
for (int j = 0; j < rows; j++) {
// Scaling up to draw a rectangle at (x,y)
int x = i*squareSize; // width
int y = j*squareSize; // height
// Begin fill controls
if ((i+j) % 2 == 0) { // Even is red
fill(250, 0, 0);
} else { // Odd is black
fill(0);
}
// For every column and row, a rectangle is drawn at an (x,y) location scaled and sized by videoScale.
rect(x, y, squareSize, squareSize);
fill(0,0,0);
fill(255);
ellipse(x,y, 40,40); **// How do I move these to be only in the black squares?**
}
}
}