Color interpolation
in
Programming Questions
•
11 months ago
Hello.
I would like to try color interpolation from one value to the other based on a time counter.
I have tried the following but it doesn't work.
Maybe some help?
- color one = #ff0000;
- color two = #00ff00;
- boolean clicked = false;
- int count = 0;
- void setup() {
- size(400, 100);
- }
- void draw() {
- for (int i = 0; i < width; i++) {
- if (clicked) {
- count++;
- if (count>=100) {
- clicked = false;
- count = 0;
- }
- }
- float newCount = map(count, 0, 100, 0., 1.);
- stroke(lerpColor(one, two, newCount, HSB));
- line(i, 0, i, height);
- }
- }
- void mousePressed() {
- clicked = true;
- }
1