function setup() {
createCanvas(windowWidth, windowHeight);
fill(255);
}
function draw() {
background(0, 0, 0, 70);
translate(width / 5, height / 5);
t = TWO_PI * sin(frameCount / 1000);
c = min(width,height) / 15;
cTIter2(c);
push()
translate(width/2,height/2);
scale(-1,1)
cTIter2(c);
pop()
}
function conwayTri(d) {
rotate(t * cos(t));
translate(200 * sin(t) * sin(t) * cos(t), 300 * cos(t) * sin(t));
triangle(0, -d, 2 * d, 0, 0, 0);
triangle(
0,
0,
0,
-d,
(d * cos(1.107) * 2) / sqrt(5),
(-d * sin(1.107) * 2) / sqrt(5)
);
triangle(
(d * cos(1.107) * 2) / sqrt(5),
(-d * sin(1.107) * 2) / sqrt(5),
(d * cos(1.107) * 2) / sqrt(5) / 2,
(-d * sin(1.107) * 2) / sqrt(5) / 2,
d,
0
);
triangle(
2 * d - (d * cos(0.464) * 2) / sqrt(5),
(-d * sin(0.464) * 2) / sqrt(5),
d,
0,
2 * d,
0
);
}
function cTIter(c) {
conwayTri(c);
push();
scale(-1, 1);
translate(0, -c);
rotate(1.571);
conwayTri(c);
pop();
push();
scale(1, -1);
conwayTri(c);
pop();
push();
translate(2 * c, -c);
rotate(PI);
conwayTri(c);
pop();
push();
scale(1, -1);
translate(2 * c, c);
conwayTri(c);
pop();
}
function cTIter2(c) {
push();
rotate(0.464);
cTIter(c);
pop();
push();
scale(1, -1);
translate(0, -1.8 * c);
rotate(0.464);
cTIter(c);
pop();
push();
scale(-1, -1);
rotate(0.464);
translate(-3 * c, 2 * c);
cTIter(c);
pop();
push();
scale(1, -1);
translate(4.49 * c, c / 2.27);
rotate(0.464);
cTIter(c);
pop();
push();
scale(-1, 1);
translate(c * 1.35, -c * 0.9);
rotate(0.464 + PI / 2);
cTIter(c);
pop();
}