Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created December 7, 2011 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/1443458 to your computer and use it in GitHub Desktop.
Save atduskgreg/1443458 to your computer and use it in GitHub Desktop.
Generating a gradient with Processing and an OpenGL texture
import processing.opengl.*;
void setup(){
size(500, 500, OPENGL);
noStroke();
}
void draw(){
background(0);
fill(255,0,0);
rect(0,0,500,500);
float percentHidden = map(mouseY, 0, 500, 0, 1);
beginShape(QUADS);
fill(0,255);
vertex(0,0);
vertex(500,0);
fill(0,0);
vertex(500, 500 * percentHidden);
vertex(0, 500 * percentHidden);
endShape();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment