2 dimensional array for shapes
in
Programming Questions
•
1 year ago
hey there,
i am doing another sketch, and i have a doubt.
i need to create 3 rows of 9 circles with 40mm of separation among them horizontally and 50 vertically (total 27 circles or ellipses).
i can't adapt this sketch to my work
i attached code
---------------------------------------------------------------------------------
int numCircles = 27;
int [][] circles; // a two-dimensional array
void setup() {
size(500, 300);
smooth();
noStroke();
circles = new int [numCircles][3]; // define the array, every circle needs three parameters (xPos, yPos, circleDiameter)
// fill array only once
for (int i=0; i<numCircles; i++) {
int circleDiameter = int(20);
int xPos = int(50); // keep distance from border
int yPos = int(50); // keep distance from border
circles[i][0]= xPos;
circles[i][1]= yPos;
circles[i][2]= circleDiameter;
}
}
void draw() {
for (int i=0; i<numCircles; i++) {
fill(0);
ellipse(circles[i][0], circles[i][1], circles[i][2],circles[i][2]);
}
}
1