Hi,
I have created this code to make a poster.
But I really want to make the code shorter, since it is the same for loop again and again only different placing and the amount of circles it creates.
But I don’t know how I can combine them, can someone help me?
The small circles in the corners make 8 circles and de bigger ones in the center of the edges makes 13.
Thankss
int a = 0;
final int MAX = 350; // max size big circles
final int MAXs = 250; // max size small circles in corners
int[] x = new int[250]; // array x value fits 250
int[] y = new int[250]; // array y value fits 250
void setup() {
size(800, 800); // size canvas
colorMode(HSB, 255); // colormode such that there is a gradient
// Loop for color gradient
for (int c = 0; c < 799; c++) { // for loop that creates gradient
line(0, c, width, c);
stroke(150 + c/3.02/3, 255/6, 255); // color transition from blue to purple to pink
}
// Loop for dots
for (int s = 0; s < x.length; s++) { // for loop that creates dots
x[s] = (int)random(width); // variable random x value
y[s] = (int)random(height); // variable random y value
}
}
void draw() {
// Loop for ellipses center
for (int z = 0; z < 150; z = z+10) { // for loop that creates ellips center horizontal
strokeWeight(1);
noFill();
stroke(255); // color lines white
ellipse(400, 400, 220+z, 100+z);
}
for (int z = 0; z < 150; z = z+10) { // for loop that creates ellipse center vertical
strokeWeight(1);
noFill();
stroke(255); // color lines white
ellipse(400, 400, 100+z, 220+z);
}
for (int z = 0; z < 150; z = z+10) { // for loop that creates ellips center horizontal rotated PI/4
pushMatrix();
translate(400, -170); // translate to center
rotate(PI/4); // rotate PI/4, 45 degrees
strokeWeight(1);
noFill();
stroke(255); // color lines white
ellipse(400, 400, 220+z, 100+z);
popMatrix();
}
for (int z = 0; z < 150; z = z+10) { // for loop that creates ellipse center vertical rotated PI/4
pushMatrix();
translate(400, -170); // translate to center
rotate(PI/4); // rotate PI/4, 45 degrees
strokeWeight(1);
noFill();
stroke(255); // color lines white
ellipse(400, 400, 100+z, 220+z);
popMatrix();
}
// Loops for circles
for (int p = 0; p < MAX; p = p+20) { // for loop that creates circles left
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(0, 400, 100+p, 100+p); // origin point and growth diameter
}
for (int k = 0; k < MAX; k = k+20) { // for loop that creates circles right
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(800, 400, 100+k, 100+k); // origin point and growth diameter
}
for (int l = 0; l < MAX; l = l+20) { // for loop that creates circles tupper
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(400, 0, 100+l, 100+l); // origin point and growth diameter
}
for (int m = 0; m < MAX; m = m+20) { // for loop that creates circles lower
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(400, 800, 100+m, 100+m); // origin point and growth diameter
}
for (int n = 0; n < MAXs; n = n+20) { // for loop that creates circles left/upper corner
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(0, 0, 100+n, 100+n); // origin point and growth diameter
}
for (int o = 0; o < MAXs; o = o+20) { // for loop that creates circles right/upper corner
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(800, 0, 100+o, 100+o); // origin point and growth diameter
}
for (int p = 0; p < MAXs; p = p+20) { // for loop that creates circles left/lower corner
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(0, 800, 100+p, 100+p); // origin point and growth diameter
}
for (int q = 0; q < MAXs; q = q+20) { // for loop that creates circles right/lower corner
strokeWeight(3);
noFill();
stroke(255); // color lines white
ellipse(800, 800, 100+q, 100+q); // origin point and growth diameter
}
// Loop for dots
for (int s = 0; s < x.length; s++) { // for loop that creates dots
ellipse(x[s], y[s], 2, 2); // dots with diameter 2 and location x,y
}
}