Hey there, i need help!
I’m trying to fill a rectangle. It can’t be that hard, can it???!!!
I created an object - Rect rectRed;
then i created the class.
but when i want to fill rectRed using - rectRed.fill(255,0,0); - it won’t let me!
Here’s my code (so far). Can anyone help me please!!!
import processing.serial.;
import cc.arduino.;
Arduino arduino;
int ledPin10 = 10;
int ledPin11 = 11;
int ledPin12 = 12;
Rect rectRed, rectWhite, rectBlue;
void setup() {
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0]); // v2
arduino.pinMode(ledPin10, Arduino.OUTPUT);
arduino.pinMode(ledPin11, Arduino.OUTPUT);
arduino.pinMode(ledPin12, Arduino.OUTPUT);
size(200,200);
noStroke();
frameRate(10);
background(255);
smooth();
noLoop();
rectRed = new Rect();
rectWhite = new Rect(75,25,25,25);
rectBlue = new Rect(125,25,25,25);
}
void draw() {
background(255);
rectRed.display();
rectWhite.display();
rectBlue.display();
if (mouseOverRectRed() == true) {
rectRed.fill(255,0,0);
arduino.digitalWrite(ledPin10, Arduino.HIGH);
}
else {
rectRed.fill(0);
arduino.digitalWrite(ledPin10, Arduino.LOW);
arduino.digitalWrite(ledPin11, Arduino.LOW);
arduino.digitalWrite(ledPin12, Arduino.LOW);
}
}
boolean mouseOverRectRed() {
return ((mouseX >= 25) && (mouseX <= 50) && (mouseY >= 25) && (mouseY <= 50));
}
class Rect {
int x,y,w,h;
Rect() {
x = 25;
y = 25;
w = 25;
h = 25;
}
Rect(int xpos, int ypos, int width, int height) {
x = xpos;
y = ypos;
w = width;
h = height;
}
void display() {
rect(x,y,w,h);
}
}