stevesketch
2/26/2016 - 7:52 AM

Triangulation_Lerp.java

boolean lerpTri = true;
float div = 8; //lower = more filled triangles overall

color bgcol = #FC806C; //#061F5C - blue // #FC806C - pink
color fore_col = #061F5C;


 if (lerpTri) {
      if (circ < width/div) {
        //color ccent1 = img_col.pixels[int(centerX) + int(centerY) * width];
        color ccent2 = img.pixels[int(centerX) + int(centerY) * width];


        color cc = ccent2;
        if (j % 2 == 0) {
          beginShape(TRIANGLES);
          stroke(fore_col); 
          noFill();
          vertex(t.p1.x, t.p1.y);
          vertex(t.p2.x, t.p2.y);
          vertex(t.p3.x, t.p3.y);
          endShape(CLOSE);
        }
        float b = norm(brightness(ccent2), 0, 255);
        PVector fillP1 = new PVector (lerp(t.p1.x, centerX, b), lerp (t.p1.y, centerY, b));
        PVector fillP2 = new PVector (lerp(t.p2.x, centerX, b), lerp (t.p2.y, centerY, b));
        PVector fillP3 = new PVector (lerp(t.p3.x, centerX, b), lerp (t.p3.y, centerY, b));
        float fade = map(circ, 0, width/div, 50, 255);
          fade = constrain(fade, 50, 255);
        beginShape();
        fill(fore_col, fade);
        noStroke();
        vertex(fillP1.x, fillP1.y);
        vertex(fillP2.x, fillP2.y);
        vertex(fillP3.x, fillP3.y);
        endShape(CLOSE);
      } else {

        float fade = map(circ, width/div, 700, 255, 0);
        fade = constrain(fade, 0, 255);
        noFill();
        stroke(#061F5C, fade);
        strokeWeight(thickness);

        line(t.p1.x, t.p1.y, t.p2.x, t.p2.y);
      }
      
 }