diff --git a/html/images/space.svg b/html/images/space.svg index 8bfe212..8777ad1 100644 --- a/html/images/space.svg +++ b/html/images/space.svg @@ -149,9 +149,14 @@ triangles.forEach(triangle => { const attr = triangle.getAttribute('points').split(delim) + const [[xa, ya], [xb, yb], [xc, yc]] = attr.map(t => t.split(',').map(n => +n)); + const det = (xb - xa) * (yc - ya) - (xc - xa) * (yb - ya); attr.pop(); attr.push(`${positionX},${positionY}`); triangle.setAttribute('points', attr.join(delim)); + triangle.style.fill = det < 0 ? "white" : "none"; + triangle.style.stroke = det < 0 ? "red" : "none"; + // i think i can also discard obtuse triangles? }); }