We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I'm trying to change the tint value based on certain BPM. When it hits a new value I want the tint to fade from the old value to the new. I am very beginner with coding and would like to be help as if I were a baby! goo goo gag gag. Here's the code I'm struggling with. Thanks
`if (avgBPM > 75) {
if (fillColor < 215) {
fillColor+=colorIncrement;
tint(fillColor, 0, 0, 200);
} else
fillColor-=colorIncrement;
tint(fillColor, 0, 0, 200);
if (avgBPM < 75){
if ((fillColor < 215)&&(fillColor > 175)) {
fillColor+=colorIncrement;
tint(fillColor, 0, 0, 200);
} else
fillColor-=colorIncrement;
tint(fillColor, 0, 0, 200);
}`
What am I doing wrong?
Answers
Try indenting the code properly using ctrl-t in the editor. What do you see?
It auto formatted.
But only because you added extra curly brackets. Before then lines 8 and 19 (in the original code) were unconditional but we're indented so they looked conditional, which could cause errors.
That said, in this case, all the unconditional bits were the same so it didn't matter (in fact you can replace the last two lines of each condition with two lines outside the condition)
Is line 4 correct? Why += when the others are - ?
Also, what happens when the value is exactly 80 or 85 or 90?
Relevant post: https://forum.processing.org/two/discussion/21604/how-to-make-gradation-ellipse-using-three-color#latest
Kf