Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created February 6, 2012 23:30
Show Gist options
  • Save jordanorelli/1755881 to your computer and use it in GitHub Desktop.
Save jordanorelli/1755881 to your computer and use it in GitHub Desktop.
void setup() {
smooth();
size(542, 475, P3D);
background(255);
stroke(0);
strokeWeight(3);
superQuad(new PVector(364.0, 235.0),
new PVector(314.0, 295.0),
new PVector(114.0, 272.0),
new PVector(169.0, 123.0));
}
void superQuad(PVector a, PVector b, PVector c, PVector d) {
PGraphics pattern = generatePattern(atan(slope(a, b)));
beginShape();
texture(pattern);
vertex(a.x, a.y, a.x, a.y);
vertex(b.x, b.y, b.x, b.y);
vertex(c.x, c.y, c.x, c.y);
vertex(d.x, d.y, d.x, d.y);
endShape(CLOSE);
}
float slope(PVector i, PVector f) {
float dy = f.y - i.y;
float dx = f.x - i.x;
return dy / dx;
}
PGraphics generatePattern(float rotation) {
PGraphics pattern = createGraphics(width, height, P2D);
pattern.beginDraw();
pattern.rotate(rotation);
pattern.stroke(0);
pattern.strokeWeight(3);
for(int y = 0; y < height; y += 10) {
pattern.line(0, y, width, y);
}
pattern.endDraw();
return pattern;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment