Display and for loop
in
Programming Questions
•
2 years ago
I have made a pentagon. When I draw it on its own, I can see it. When I put it inside a for loop it disappears. Anything I have not understood ? I have tried to translate the sketch in different ways, and still nothing shows.
Can anyone help ?
Here is the code :
float cos18 = cos(radians(18));
float cos36 = cos(radians(36));
float cos54 = cos(radians(54));
float cos72 = cos(radians(72));
void setup()
{
size(800,600);
smooth();
noLoop();
background(255);
translate(width/2, height/2);
}
void draw() {
translate(300,200);
for (int i = 0; i > 6; i = i + 1)
{
fill(255,0,0);
pentagone(80);
rotate(radians(72));
}
}
void pentagone(int longueur)
{
beginShape();
rotate(radians(180));
vertex(0,0);
vertex(longueur * cos36, longueur * cos54);
vertex((longueur * cos36) - (longueur * cos72), (longueur * cos54) + (longueur * cos18));
vertex((longueur * cos36) - (longueur * cos72) - longueur, (longueur * cos54) + (longueur * cos18));
vertex(-longueur * cos36, longueur * cos54);
endShape(CLOSE);
}
BTW no final answer to my other problem after I posted the code as you suggested:
Thanks for you help.
1