Your code above is not correct. If you want to draw with setup only, you need to put all your code inside setup:
void setup() {
size(500, 500, P2D);
background(20);
strokeWeight(2);
beginShape(LINES);
stroke(255, 0, 0);
vertex(100, 100);
stroke(0, 255, 0);
vertex(400, 400);
endShape();
for (int a=1; a<6; ++a)
for (int b=1; b<6; ++b)
for (int c=1; c<6; ++c)
for (int d=1; d<6; ++d) {
ellipse(a*100, b*100, 10, 10);
line(a*100, b*100, c*100, d*100);
}
}
Also, because you are a beginner, I recommend that you always use braces “{}” when you use for()
. Write your code like this – it is easier for you to understand:
void setup() {
size(500, 500, P2D);
background(20);
strokeWeight(2);
beginShape(LINES);
stroke(255, 0, 0);
vertex(100, 100);
stroke(0, 255, 0);
vertex(400, 400);
endShape();
for (int a=1; a<6; ++a) {
for (int b=1; b<6; ++b) {
for (int c=1; c<6; ++c) {
for (int d=1; d<6; ++d) {
ellipse(a*100, b*100, 10, 10);
line(a*100, b*100, c*100, d*100);
}
}
}
}
}
Also, you are using drawing one line with vertex, then all your other lines with your for loops. If you want to use vertex for all your other lines, you need to put it in your for loops.
If you are a complete beginner (to loops, color, points and lines), I might also recommend starting with easier projects first!
For example, try modifying this: