float pointNo = 30;
float stage = 0.0;
PVector point1;
PVector point2;
PVector point3;
PVector point4;
PVector point5, point6, point7, point8;
PVector l1mp, l2mp, l3mp, l4mp;
PVector l5mp, l6mp, l7mp, l8mp;
void setup() {
size(1000, 1000);
noLoop();
translate(1000, 1000);
point1 = new PVector(100, 100);
point2 = new PVector(500, 100);
point3 = new PVector(500, 500);
point4 = new PVector(100, 500);
point5 = new PVector(500, 100);
point6 = new PVector(900, 100);
point7 = new PVector(900, 500);
point8 = new PVector(500, 500);
}
void draw() {
for (int i = 0; i < pointNo+1; i++) {
l1mp = PVector.lerp(point1, point2, stage);
l2mp = PVector.lerp(point2, point3, stage);
l3mp = PVector.lerp(point3, point4, stage);
l4mp = PVector.lerp(point4, point1, stage);
line(l1mp.x, l1mp.y, l2mp.x, l2mp.y);
line(l2mp.x, l2mp.y, l3mp.x, l3mp.y);
line(l3mp.x, l3mp.y, l4mp.x, l4mp.y);
line(l4mp.x, l4mp.y, l1mp.x, l1mp.y);
l5mp = PVector.lerp(point5, point6, stage);
l6mp = PVector.lerp(point6, point7, stage);
l7mp = PVector.lerp(point7, point8, stage);
l8mp = PVector.lerp(point8, point5, stage);
line(l5mp.x, l5mp.y, l6mp.x, l6mp.y);
line(l6mp.x, l6mp.y, l7mp.x, l7mp.y);
line(l7mp.x, l7mp.y, l8mp.x, l8mp.y);
line(l8mp.x, l8mp.y, l5mp.x, l5mp.y);
stage += (1/pointNo);
}
translate(0, 400);
stage = 0;
for (int i = 0; i < pointNo+1; i++) {
l1mp = PVector.lerp(point1, point2, stage);
l2mp = PVector.lerp(point2, point3, stage);
l3mp = PVector.lerp(point3, point4, stage);
l4mp = PVector.lerp(point4, point1, stage);
line(l1mp.x, l1mp.y, l2mp.x, l2mp.y);
line(l2mp.x, l2mp.y, l3mp.x, l3mp.y);
line(l3mp.x, l3mp.y, l4mp.x, l4mp.y);
line(l4mp.x, l4mp.y, l1mp.x, l1mp.y);
l5mp = PVector.lerp(point5, point6, stage);
l6mp = PVector.lerp(point6, point7, stage);
l7mp = PVector.lerp(point7, point8, stage);
l8mp = PVector.lerp(point8, point5, stage);
line(l5mp.x, l5mp.y, l6mp.x, l6mp.y);
line(l6mp.x, l6mp.y, l7mp.x, l7mp.y);
line(l7mp.x, l7mp.y, l8mp.x, l8mp.y);
line(l8mp.x, l8mp.y, l5mp.x, l5mp.y);
stage += (1/pointNo);
}
}