const MOUNTAIN = '#f59e0b'; const VALLEY = '#38bdf8'; function toSvg(x, y, dim) { return [x * dim, (1 - y) * dim]; } function GhostEdges({ target, dim }) { if (!target) return null; const { vertices_coords, edges_vertices, edges_assignment } = target; if (!vertices_coords || !edges_vertices || !edges_assignment) return null; return edges_vertices.map((ev, i) => { const asgn = edges_assignment[i]; if (asgn === 'B') return null; const v1 = vertices_coords[ev[0]]; const v2 = vertices_coords[ev[1]]; if (!v1 || !v2) return null; const [x1, y1] = toSvg(v1[0], v1[1], dim); const [x2, y2] = toSvg(v2[0], v2[1], dim); const color = asgn === 'M' ? MOUNTAIN : VALLEY; return ( ); }); } function CurrentEdges({ paperState, dim }) { if (!paperState) return null; const { vertices_coords, edges_vertices, edges_assignment } = paperState; if (!vertices_coords || !edges_vertices || !edges_assignment) return null; return edges_vertices.map((ev, i) => { const asgn = edges_assignment[i]; if (asgn === 'B' || asgn === 'F') return null; const v1 = vertices_coords[ev[0]]; const v2 = vertices_coords[ev[1]]; if (!v1 || !v2) return null; // vertices_coords are 3D [x, y, z] — use only x and y const [x1, y1] = toSvg(v1[0], v1[1], dim); const [x2, y2] = toSvg(v2[0], v2[1], dim); const color = asgn === 'M' ? MOUNTAIN : VALLEY; return ( ); }); } export default function CreaseCanvas({ paperState, target, dim = 280, ghostOnly = false }) { const pad = 1; const size = dim; return ( {/* Paper background */} {/* Ghost target overlay */} {/* Current paper state */} {!ghostOnly && ( )} {/* Paper border */} ); }