Why wont this work?
in
Programming Questions
•
11 months ago
So I am fairly new to processing. But I though I could have and inside an IF condition, so I am confused why this isn't working?
- int colour = (int) random(3);
- int rectcolour;
- void setup() {
- size(600, 600);
- rectMode(CENTER);
- smooth();
- }
- void draw() {
- switch(colour) {
- case 0:
- fill(255, 0, 0);
- break;
- case 1:
- fill(0, 255, 0);
- break;
- case 2:
- fill(0, 0, 255);
- break;
- }
- //rect(width/2, height/2, 200, 100);
- fill(255, 0, 0);
- rect(125, 525, 100, 50);
- fill(0, 255, 0);
- rect(300, 525, 100, 50);
- fill(0, 0, 255);
- rect(475, 525, 100, 50);
- rectColour;
- rect(width/2, height/2, 200, 100);
- }
- void mousePressed() {
- if(mouseX > 0 && < 300) {
- rectColour = fill(0, 255, 0);
- }
- if(mouseX > 300 && < 600) {
- rectColour = fill(0, 0, 255);
- }
- }
1