assignment2_saurabh

Changing of colours in squares according to the key pressed.
int Length = 600; // dimentions of the canvas
int Width = 650;

void setup()
{
size (Width, Length);
background(0,0,0);
}

int value =255;

void draw() {
fill(255);
rect(150, 250, 150, 100);
fill(255);
rect(250, 250, 150, 100);
fill(255);
rect(350, 250, 150, 100);
fill(255);
rect(450, 250, 150, 100);

if(keyPressed) {
if (key == '1' ) {
fill(255,255,0);
}
else {
fill(255);
}
rect(150, 250, 150, 100);

if (key == '2' ) {
fill(0,124,255);
}
else {
fill(255);
}
rect(250, 250, 150, 100);

if (key == '3' ) {
fill(255,125,255);
}
else {
fill(255);
}
rect(350, 250, 150, 100);

if (key == '4') {
fill(255,125,0);
}
else {
fill(255);
}
rect(450, 250,150, 100);
}
fill(255);

}

output.jpg
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License