Add color x to color y if event A occurs
in
Programming Questions
•
2 years ago
Hello,
What I am trying to do is to tell the program to fill the rectangle with color #F9C5D7 if the word "love" is used in the loaded txt file. Then, if the word "sky" is used, add color #A7A72E to #F9C5D7; else do not add it.
int value = 0;
...........
void setup()
...........
if(key.equals("love") ){
value = #F9C5D7;
value = #F9C5D7;
}
if(key.equals("sky")){
value = #F9C5D7 + #A7A72E;
if(key.equals("sky")){
value = #F9C5D7 + #A7A72E;
void draw()
{
fill(value);
rect(50,50,50,50);
{
fill(value);
rect(50,50,50,50);
}
However, even though both words are within the text content, the program always colors the rectangle in #F9C5D7 (the color corresponding to the first word) and does not add the second color
The other way I tried, which gives the same results is:
color c1 = #F9C5D7;
color c2 = #A7A72E;
color c;
color c2 = #A7A72E;
color c;
...........
void setup()
...........
if(key.equals("love") ){
c = c1;
c = c1;
}
if(key.equals("sky")){
c = c + c2;
if(key.equals("sky")){
c = c + c2;
void draw()
{
fill(c);
rect(50,50,50,50);
{
fill(c);
rect(50,50,50,50);
}
This example mixes the colors correctly but I do not know how to adapt it in order to fit the requirement for present within the text word
color c1 = #A7A72E;
color c2 = #F9C5D7;
color c = c1+c2;
void setup() {
size(400,400);
}
void draw() {
size(400,400);
}
void draw() {
fill(c);
rect(50,50,50,50);
}
rect(50,50,50,50);
}
Any insight into how to adapt the code so that it mixes the colors when the events occur would be highly appreciated!
1