Skip to content

Instantly share code, notes, and snippets.

@behreajj
Created June 25, 2017 19:03
Show Gist options
  • Select an option

  • Save behreajj/d49e22ce90ffec6e64eda6a3767e478a to your computer and use it in GitHub Desktop.

Select an option

Save behreajj/d49e22ce90ffec6e64eda6a3767e478a to your computer and use it in GitHub Desktop.
Color Gradients 3-4
void blendLinGrad(PImage pg, Gradient gradient, float blend,
int orx, int ory, int dex, int dey) {
color clr;
int w = pg.width;
int h = pg.height;
pg.loadPixels();
for (int y = 0, x, i = 0; y < h; ++y) {
for (x = 0; x < w; ++x, ++i) {
clr = gradient.evaluate(
project(orx, ory, dex, dey, x, y));
pg.pixels[i] = lerpColor(pg.pixels[i], clr, blend);
}
}
pg.updatePixels();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment