Skip to content

Instantly share code, notes, and snippets.

@josephtaylor
Created December 8, 2012 22:14
Show Gist options
  • Save josephtaylor/4242212 to your computer and use it in GitHub Desktop.
Save josephtaylor/4242212 to your computer and use it in GitHub Desktop.
A Mess up while trying to do some pentagonal stuff
PVector center;
PVector point;
float x, y, r, theta;
ArrayList<PVector> newPoints;
void setup() {
size(700,700);
background(255);
r = 100;
theta = 0;
x = r * cos(theta);
y = r * sin(theta);
center = new PVector(width/2, height/2);
point = new PVector(x, y);
newPoints = new ArrayList<PVector>();
smooth();
stroke(0,0,0,80);
rectMode(CENTER);
}
void draw() {
translate(center.x, center.y);
drawPent(center);
ArrayList<PVector> copyOfPoints = new ArrayList<PVector>();
for(int i = 0; i < newPoints.size(); i++) {
copyOfPoints.add(newPoints.get(i));
}
for(PVector p : copyOfPoints) {
pushMatrix();
translate(p.x,p.y);
drawPent(center);
popMatrix();
}
noLoop();
saveFrame("WTF" + (int) random(Integer.MAX_VALUE) + ".png");
}
void drawPent(PVector center) {
for(int i = 0; i < 5; i++) {
PVector oldPoint = point.get();
theta += 2*PI/5;
x = r * cos(theta);
y = r * sin(theta);
point.set(x, y, 0);
line(oldPoint.x, oldPoint.y, x, y);
PVector a = PVector.sub(oldPoint, center);
PVector b = PVector.sub(point, center);
PVector ray = PVector.add(a, b);
PVector midPoint = PVector.add(oldPoint, point);
ellipse(midPoint.x, midPoint.y, 10, 10);
print(midPoint.x + "\t" + midPoint.y + "\n");
line(0, 0, midPoint.x, midPoint.y);
newPoints.add(midPoint);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment