/** * WireInProgressRenderer — live preview while drawing a wire. * Shows the fixed waypoints + a dynamic elbow segment to the mouse cursor. * Includes a full-canvas crosshair at the cursor position (CircuitJS-style) * to help with alignment and precision on touch devices. */ import React from 'react'; import type { WireInProgress } from '../../types/wire'; import { generatePreviewPath, generateOrthogonalPath } from '../../utils/wireUtils'; /** Crosshair arm length in world pixels — large enough to span any visible area */ const CROSSHAIR_EXTENT = 8000; interface Props { wireInProgress: WireInProgress; /** When true, show the full-canvas crosshair guides (aiming mode on touch) */ isAiming?: boolean; } export const WireInProgressRenderer: React.FC = ({ wireInProgress, isAiming = false }) => { const { startEndpoint, waypoints, color, currentX, currentY } = wireInProgress; const path = generatePreviewPath( { x: startEndpoint.x, y: startEndpoint.y }, waypoints, currentX, currentY, ); if (!path) return null; return ( {/* ── Crosshair: full-canvas alignment guides (only during aiming) ── */} {isAiming && ( <> )} {/* Dark outline */} {/* Colored wire */} {/* Dashed overlay to indicate "in progress" */} {/* Start pin marker */} {/* Waypoint markers (locked-in corners) */} {waypoints.map((wp, i) => ( ))} {/* Cursor marker */} ); };