4-Color Gradient

edited May 2014 in How To...

Hi guys, I am trying to get a 4 points gradient, having control over the location of the points in order to animate/interact with them... but I can't get anywhere closer of doing this.

Please see attached screen shot as reference.

Any advice or hint is more than welcome, thanks.

Screen Shot 2014-05-28

Tagged:

Answers

  • You can get a similar effect using vertex() in P2D/P3D and setting a fill colour per-vertex, although I'm not sure it will get you the level of control you need.

    void setup(){
      size(500, 500, P2D);
      noStroke();
    }
    
    void draw(){
    
      beginShape();
      fill(255, 0, 0);
      vertex(0, 0);
      fill(0, 255, 0);
      vertex(width, 0);
      fill(0, 0, 255);
      vertex(width, height);
      fill(255, 255, 0);
      vertex(0, height);
    
      endShape();
    }
    
Sign In or Register to comment.