Skip to content

Instantly share code, notes, and snippets.

@manoloide
Created August 31, 2018 22:23
Show Gist options
  • Save manoloide/302f8fdcea1090552f0550471eece759 to your computer and use it in GitHub Desktop.
Save manoloide/302f8fdcea1090552f0550471eece759 to your computer and use it in GitHub Desktop.
void hoja(float x, float y, float s, float ang, int col) {
float w = s*0.3;
float h = int(s);
pushMatrix();
translate(x, y);
rotate(ang);
float pb = 0.8;
float px = 2.2;
noStroke();
fill(col);
for (int i = 0; i < h; i++) {
float dx1 = sin(pow(map(i, 0, h, 0, 1), pb)*PI)*w;
float dx2 = sin(pow(map(i+1, 0, h, 0, 1), pb)*PI)*w;
float dy1 = pow(map(i, 0, h, 0, 1), px)*h;
float dy2 = pow(map(i+1, 0, h, 0, 1), px)*h;
beginShape();
vertex(dx1, -i);
vertex(dx2, -i-1);
vertex(0, -dy2);
vertex(0, -dy1);
endShape(CLOSE);
}
col = lerpColor(col, color(0), 0.2);
for (int i = 0; i < h; i++) {
float dx1 = sin(pow(map(i, 0, h, 0, 1), pb)*PI)*-w;
float dx2 = sin(pow(map(i+1, 0, h, 0, 1), pb)*PI)*-w;
float dy1 = pow(map(i, 0, h, 0, 1), px)*h;
float dy2 = pow(map(i+1, 0, h, 0, 1), px)*h;
beginShape();
vertex(dx1, -i);
vertex(dx2, -i-1);
vertex(0, -dy2);
vertex(0, -dy1);
endShape(CLOSE);
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment