Fun Programming

Fun programming 82: Program a gradient of colors


Listen Later

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.

...more
View all episodesView all episodes
Download on the App Store

Fun ProgrammingBy