Random Color Problem
in
Programming Questions
•
3 months ago
Hey all,
I've done my research to solve this problem but without any success.
I want my rectangle to switch its fill randomly black or white, but all I
can see is a black rectangle.
Who has a suggestion?
I've done my research to solve this problem but without any success.
I want my rectangle to switch its fill randomly black or white, but all I
can see is a black rectangle.
Who has a suggestion?
- float x;
- float y;
- color white =color(255);
- color black =color(0);
- color[] colors = { //random selects one of above colors
- white, black
- };
- color c1 = (colors(random(0,1)));
- void setup() {
- noStroke ();
- size(1000, 1000);
- smooth();
- background (255,0,0);
- rectMode (CENTER);
- }
- void draw() {
- fill(c1);
- translate(mouseX, mouseY);
- rotate((mouseX + mouseY)* 300.0);
- rect(x, y, 30, 30);
- }
1