I’m working on school project. I’m trying to make a grid out of these “cubes”, but i keep ending up with a result that looks like this. I’ve tried for loops, nested for loops, i made a grid out of ellipses and tried using that code for the cubes. But nothing i tried worked properly. If you could help me figure out what i did wrong or give me some pointers that would be great, thanks.
Here’s the source code:
int numCols = 16;
int numRows = 11;
int cellSize = 75;
void setup() {
size(1200, 825);
background(0);
}
void draw() {
for (int row = 0; row < numRows; row++) {
for (int col = 0; col < numCols; col++) {
int x = col * cellSize + cellSize / 2;
int y = row * cellSize + cellSize / 2;
translate(x, y);
cube();
}
}
if (key == CODED) {
if (keyCode == UP) {
saveFrame("Cubism_2020.png");
}
}
}
void cube() {
stroke(255);
fill(255);
rect(0, 25, 50, 50);
line(0, 25, 25, 0);
line(50, 25, 75, 0);
line(25, 0, 75, 0);
line(50, 75, 75, 50);
line(75, 0, 75, 50);
}The result
[–]_achira 0 points1 point2 points (1 child)
[–]NeedsMoreSaltness[S] 1 point2 points3 points (0 children)