Skip to content

Instantly share code, notes, and snippets.

@nick3499
Created April 19, 2016 15:04
Show Gist options
  • Save nick3499/50631c4476e491c100bf389af42dc421 to your computer and use it in GitHub Desktop.
Save nick3499/50631c4476e491c100bf389af42dc421 to your computer and use it in GitHub Desktop.
Lerp Color. Using p5.js library.
function setup() {
createCanvas(720, 400);
background(255);
noStroke();
}
function draw() {
background(255);
from = color(255, 0, 0, 0.2 * 255);
to = color(0, 0, 255, 0.2 * 255);
c1 = lerpColor(from, to, .33);
c2 = lerpColor(from, to, .66);
for (var i = 0; i < 15; i++) {
fill(from);
quad(random(-40, 220), random(height), random(-40, 220), random(height),
random(-40, 220), random(height), random(-40, 220), random(height));
fill(c1);
quad(random(140, 380), random(height), random(140, 380), random(height),
random(140, 380), random(height), random(140, 380), random(height));
fill(c2);
quad(random(320, 580), random(height), random(320, 580), random(height),
random(320, 580), random(height), random(320, 580), random(height));
fill(to);
quad(random(500, 760), random(height), random(500, 760), random(height),
random(500, 760), random(height), random(500, 760), random(height));
}
frameRate(5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment