character input colur output

Objective :

The objective of the assignment was to develop a program in processing language such that it will output a particular unique colour one for each of 4 different alphabets inputed from the keyboard.

Processing Language code:

void setup()
{
size(575,300);

}

void draw()
{

fill(255,255,255);
rect(50,100,100,100);
rect(175,100,100,100);
rect(300,100,100,100);
rect(425,100,100,100);

if (keyPressed == true)
{
if (key == 'a' || key == 'A')
{
fill(255,0,0);
rect(50,100,100,100);
}

}
else
{
fill(255);
rect(50,100,100,100);

}

if (keyPressed == true)
{
if (key == 'b' || key == 'B')
{
fill(0,0,255);
rect(175,100,100,100);
}
}
else
{
fill(255);
rect(175,100,100,100);
}

if (keyPressed == true)
{
if (key == 'c' || key == 'C')
{
fill(0,255,0);
rect(300,100,100,100);
}
}
else
{
fill(255);
rect(300,100,100,100);
}

if (keyPressed == true)
{
if (key == 'd' || key == 'D')
{
fill(242,244,97);
rect(425,100,100,100);
}
}
else
{
fill(255);
rect(425,100,100,100);
}

}

Output:

For input character "A"
red22.jpg
For input character "B"
blue.jpg
For input character "C"
green.jpg
For input character "D"
yellow.jpg

Dhananjay Govekar homepage

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