import '../../styles/TShirtSVG.css'; /** * Pure-SVG t-shirt mockup. The path is a stylized tee silhouette (collar + * sleeves + body). Color is the user-selected garment color from the Shirt * Options panel. The print-zone rectangle in the chest area indicates where * the design overlay will land — it's visual-only (the actual design overlay * sits in the Konva stage on top of this). * * Sized via `viewBox` so the SVG scales fluidly with its container. */ export function TShirtSVG({ size = 360, color = '#ffffff', showPrintZone = true }) { // Compute a complementary stroke shade so the silhouette stays visible on // light AND dark fills. We darken the fill ~12% in HSL space — close enough // for our small palette without pulling in a color library. const stroke = darken(color, 0.12); const isDark = perceptualLuminance(color) < 0.45; return ( {/* Soft drop shadow under the shirt — kept subtle so the canvas remains the focus. */} {/* Shirt silhouette ---------------------------------------------------- */} {/* Collar */} {/* Print zone — corner brackets, not a closed rectangle, so the design overlay isn't visually competing with a hard frame. */} {showPrintZone && ( {/* Corners of a 220×220 print zone centered in the chest */} {(() => { const x = 130; const y = 180; const w = 220; const h = 220; const c = 14; return ( <> ); })()} )} ); } /* ────────────────────────────────────────────────────────────────────────── */ /* Tiny color helpers — local to this file to avoid pulling in a dependency. */ /* ────────────────────────────────────────────────────────────────────────── */ function parseHex(hex) { const m = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex); if (!m) return [255, 255, 255]; const v = m[1]; if (v.length === 3) { return [ parseInt(v[0] + v[0], 16), parseInt(v[1] + v[1], 16), parseInt(v[2] + v[2], 16), ]; } return [ parseInt(v.slice(0, 2), 16), parseInt(v.slice(2, 4), 16), parseInt(v.slice(4, 6), 16), ]; } function toHex(r, g, b) { const clamp = (v) => Math.max(0, Math.min(255, Math.round(v))); return `#${[r, g, b].map((v) => clamp(v).toString(16).padStart(2, '0')).join('')}`; } function darken(hex, amount = 0.1) { const [r, g, b] = parseHex(hex); return toHex(r * (1 - amount), g * (1 - amount), b * (1 - amount)); } function perceptualLuminance(hex) { const [r, g, b] = parseHex(hex); // Rec. 601 luma — perceptually weighted, fast. return (0.299 * r + 0.587 * g + 0.114 * b) / 255; }