[solved] I dont get behaviour of random in setup
in
Programming Questions
•
8 months ago
hi,
i need your help, i dont understand why this won't work.
I tried to have random-colored circles in a row, but my code
won't work with my variables r and r1.
If I edit fill(0, r, r1, 50);
to
fill(0, random(255), random(50, 100), 50);
I get exactly what i want (with the exception that my ellipses are drawn new every frame). I don't understand
why my ellipses are black-colored if if use my variables r and r1.
Can you help me to understand this?
For my understanding r and r1 are set once random but this isn't the case.
Thanks!
i need your help, i dont understand why this won't work.
I tried to have random-colored circles in a row, but my code
won't work with my variables r and r1.
- float r;
float r1;
void setup() {
float r = random(255);
float r1 = random(50, 100);
}
void draw() {
int i = 0;
while (i <= width) {
fill(0, r, r1, 50);
ellipse(i, height/2, 70, 70);
i = i + 40;
}
If I edit fill(0, r, r1, 50);
to
fill(0, random(255), random(50, 100), 50);
I get exactly what i want (with the exception that my ellipses are drawn new every frame). I don't understand
why my ellipses are black-colored if if use my variables r and r1.
Can you help me to understand this?
For my understanding r and r1 are set once random but this isn't the case.
Thanks!
1