Learn creative coding writing simple programs

82. Program a gradient of colors

With the lerpColor() function we can find a color that is between two other colors. The lerpColor() function takes three parameters. The first two are colors. The third parameters indicates if the new color we get should be closer to the first color or to the second. 0.5 means right in the middle of the two. Numbers below 0.5 mean closer to the first color, and number greater than 0.5 mean closer to the second.
What we do in our program is getting all the possible colors between the first color and the second one by slowly increasing the third parameter from 0 to 1. With each color we get we draw one line. After filling the screen with lines of different colors we get a nice looking vertical gradient.

Tags: gradient, colors, lerpColors

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus