Skip to content

Instantly share code, notes, and snippets.

@nataliefreed
Created February 10, 2017 18:54
Show Gist options
  • Save nataliefreed/fac624fbaf2f305d992ea68c52f3a5ca to your computer and use it in GitHub Desktop.
Save nataliefreed/fac624fbaf2f305d992ea68c52f3a5ca to your computer and use it in GitHub Desktop.
Color gradient example using lerpColor
var color1, color2;
var gradientHeight = 300; //change this to change how far down the screen the gradient goes
function setup() {
createCanvas(800, 800);
color1 = color('#e67e22');
color2 = color('#2ecc71');
var lineNum = 0;
while (lineNum < gradientHeight) {
stroke(lerpColor(color1, color2, 1 / gradientHeight * lineNum));
line(0, lineNum, width, lineNum);
lineNum += 1;
}
}
function draw() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment