Stop when all edges have been mapped

This commit is contained in:
2025-12-19 19:27:59 -08:00
parent fc5a1155dd
commit f9a191048a

View File

@@ -350,6 +350,8 @@
return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2); return Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);
} }
const startingTrianglePts = ["-20,20 20,20", "20,20 20,-20", "20,-20 -10,-30"];
function animate(timestamp) { function animate(timestamp) {
const delta = timestamp - zero; const delta = timestamp - zero;
time.innerText = ((timestamp - zeroForTimer) * 0.001).toFixed(3); time.innerText = ((timestamp - zeroForTimer) * 0.001).toFixed(3);
@@ -413,17 +415,19 @@
return vt.join(' '); return vt.join(' ');
}); });
// console.log(mappedEdges);
[...lineContainer.children].forEach(l => { [...lineContainer.children].forEach(l => {
const x1 = l.getAttribute('x1'); const x1 = l.getAttribute('x1');
const y1 = l.getAttribute('y1'); const y1 = l.getAttribute('y1');
const x2 = l.getAttribute('x2'); const x2 = l.getAttribute('x2');
const y2 = l.getAttribute('y2'); const y2 = l.getAttribute('y2');
const str = `${x1},${y1} ${x2},${y2}`; const str = `${x1},${y1} ${x2},${y2}`;
if (mappedEdges.includes(str)) { if (mappedEdges.includes(str) && (lineContainer.childElementCount < 4 || !startingTrianglePts.includes(str))) {
l.remove(); l.remove();
} }
}); });
if (restart) { if (restart) {
restart = false; restart = false;
[...lineContainer.children].forEach(c => c.remove());; [...lineContainer.children].forEach(c => c.remove());;
@@ -502,7 +506,8 @@
// if (+y < 200) // if (+y < 200)
// if (timestamp < 10000) // if (timestamp < 10000)
requestAnimationFrame(t => animate(t)); if (lineContainer.childElementCount > 0)
requestAnimationFrame(t => animate(t));
} }
let force = 1; let force = 1;

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 21 KiB