@props(['type' => 'plain', 'size' => 64, 'showLabel' => false]) @php // ── Normalizer: maps any raw DB string → canonical key ──────────────────────── $normalize = function(string $raw): string { $s = mb_strtolower(trim($raw)); $s = strtr($s, ['á'=>'a','é'=>'e','í'=>'i','ó'=>'o','ú'=>'u','ñ'=>'n']); // Ripstop first (tafetan rs / rip stop variants) if (str_contains($s,'ripstop') || str_contains($s,'rip stop') || str_contains($s,'rip-stop') || (str_contains($s,'tafetan') && str_contains($s,'rs'))) return 'ripstop'; // Skip dent / warp rib if (str_contains($s,'skip') || str_contains($s,'skipdent')) return 'skipdent'; // Double cloth if (str_contains($s,'doble') || str_contains($s,'doublecloth') || str_contains($s,'dos caras')) return 'doublecloth'; // Herringbone / quebrado / broken twill if (str_contains($s,'herring') || str_contains($s,'hering') || str_contains($s,'quebrado') || str_contains($s,'broken')) return 'herringbone'; // Twill family — detect ratio first, then direction if (str_contains($s,'twill') || str_contains($s,'twil') || str_contains($s,'sarga') || str_contains($s,'tafetan twill') || str_contains($s,'tafetan tw')) { $left = str_contains($s,'left') || str_contains($s,' l') || str_contains($s,'-l'); if (str_contains($s,'3/1') || str_contains($s,'3-1') || str_contains($s,'tw 7') || str_contains($s,'twill 7')) return $left ? 'twill31l' : 'twill31'; if (str_contains($s,'2/2') || str_contains($s,'2-2')) return $left ? 'twill22l' : 'twill22'; if (str_contains($s,'2/1') || str_contains($s,'2-1') || str_contains($s,'1/2')) return $left ? 'twill21l' : 'twill21'; return $left ? 'twill21l' : 'twill21'; } // Satin if (str_contains($s,'satin') || str_contains($s,'saten')) { if (str_contains($s,'8')) return 'satin8'; if (str_contains($s,'5')) return 'satin5'; return 'satin4'; } // Oxford / basket if (str_contains($s,'oxford')) return 'oxford'; if (str_contains($s,'basket') || str_contains($s,'basquet')) return 'basket'; // Dobby — after twill check to catch "dobby twill" if (str_contains($s,'dobby') || str_contains($s,'doby')) return 'dobby'; // Plain / tafetan (catch-all for plain variants) if (str_contains($s,'plain') || str_contains($s,'tafetan') || str_contains($s,'taffeta') || str_contains($s,'tafetan') || str_contains($s,'interlock')) return 'plain'; // Fallback: return the original if nothing matches return $raw; }; // ── Weave pattern library ────────────────────────────────────────────────────── // matrix: 2-D array 1=warp up (dark) 0=weft up (gold) // cols/rows: how many cells to render in the SVG (matrix tiles to fill) $patterns = [ // ── PLAIN WEAVE FAMILY ─────────────────────────────────────────────────── 'plain' => [ 'label' => 'Plain / Tafetán', 'group' => 'plain', 'matrix' => [[1,0],[0,1]], 'cols' => 8, 'rows' => 8, ], 'basket' => [ 'label' => 'Basket / Basquet', 'group' => 'plain', 'matrix' => [[1,1,1,0,0,0],[1,1,1,0,0,0],[1,1,1,0,0,0],[0,0,0,1,1,1],[0,0,0,1,1,1],[0,0,0,1,1,1]], 'cols' => 6, 'rows' => 6, ], 'oxford' => [ 'label' => 'Oxford (2×2)', 'group' => 'plain', 'matrix' => [[1,1,0,0],[1,1,0,0],[0,0,1,1],[0,0,1,1]], 'cols' => 8, 'rows' => 8, ], 'skipdent' => [ 'label' => 'Skip Dent / Warp Rib', 'group' => 'plain', // Paired warp ends skip alternate dents → vertical rib appearance 'matrix' => [[1,1,0,0],[0,0,1,1],[1,1,0,0],[0,0,1,1]], 'cols' => 8, 'rows' => 8, ], // ── TWILL FAMILY ───────────────────────────────────────────────────────── 'twill21' => [ 'label' => 'Twill 2/1 →', 'group' => 'twill', // 2 warp up, 1 weft up, shift +1 right each row 'matrix' => [[1,1,0],[0,1,1],[1,0,1]], 'cols' => 9, 'rows' => 9, ], 'twill21l' => [ 'label' => 'Twill 2/1 ←', 'group' => 'twill', // shift −1 (left) each row 'matrix' => [[1,1,0],[1,0,1],[0,1,1]], 'cols' => 9, 'rows' => 9, ], 'twill22' => [ 'label' => 'Twill 2/2 →', 'group' => 'twill', 'matrix' => [[1,1,0,0],[0,1,1,0],[0,0,1,1],[1,0,0,1]], 'cols' => 8, 'rows' => 8, ], 'twill22l' => [ 'label' => 'Twill 2/2 ←', 'group' => 'twill', 'matrix' => [[1,1,0,0],[1,0,0,1],[0,0,1,1],[0,1,1,0]], 'cols' => 8, 'rows' => 8, ], 'twill31' => [ 'label' => 'Twill 3/1 →', 'group' => 'twill', // 3 warp up, 1 weft up 'matrix' => [[1,1,1,0],[0,1,1,1],[1,0,1,1],[1,1,0,1]], 'cols' => 8, 'rows' => 8, ], 'twill31l' => [ 'label' => 'Twill 3/1 ←', 'group' => 'twill', 'matrix' => [[1,1,1,0],[1,1,0,1],[1,0,1,1],[0,1,1,1]], 'cols' => 8, 'rows' => 8, ], 'herringbone' => [ 'label' => 'Herringbone / Quebrado', 'group' => 'twill', // 2/2 twill that reverses direction at midpoint → classic chevron 'matrix' => [ [1,1,0,0], // right-twill rows [0,1,1,0], [0,0,1,1], [1,0,0,1], [1,0,0,1], // left-twill rows (mirror) [0,0,1,1], [0,1,1,0], [1,1,0,0], ], 'cols' => 8, 'rows' => 8, ], // ── SATIN FAMILY ───────────────────────────────────────────────────────── 'satin4' => [ 'label' => 'Satin de 4', 'group' => 'satin', // 4-end warp satin, step 3: binding points at col offsets 0,3,2,1 'matrix' => [[1,0,0,0],[0,0,0,1],[0,0,1,0],[0,1,0,0]], 'cols' => 8, 'rows' => 8, ], 'satin5' => [ 'label' => 'Satin de 5', 'group' => 'satin', // 5-end warp satin, step 2: binding points at col offsets 0,2,4,1,3 'matrix' => [[1,0,0,0,0],[0,0,1,0,0],[0,0,0,0,1],[0,1,0,0,0],[0,0,0,1,0]], 'cols' => 10, 'rows' => 10, ], 'satin8' => [ 'label' => 'Satin de 8', 'group' => 'satin', // 8-end warp satin, step 3: binding points 0,3,6,1,4,7,2,5 'matrix' => [ [1,0,0,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,0,0,1,0], [0,1,0,0,0,0,0,0], [0,0,0,0,1,0,0,0], [0,0,0,0,0,0,0,1], [0,0,1,0,0,0,0,0], [0,0,0,0,0,1,0,0], ], 'cols' => 8, 'rows' => 8, ], // ── SPECIALTY ──────────────────────────────────────────────────────────── 'ripstop' => [ 'label' => 'Ripstop', 'group' => 'specialty', // Plain weave base with reinforcing threads at row 6 and col 7 'matrix' => [ [1,0,1,0,1,0,1,1], // ← col 7 = reinforcing warp (always up) [0,1,0,1,0,1,0,1], [1,0,1,0,1,0,1,1], [0,1,0,1,0,1,0,1], [1,0,1,0,1,0,1,1], [0,1,0,1,0,1,0,1], [1,1,1,1,1,1,1,1], // ← reinforcing pick (warp over all) [0,1,0,1,0,1,0,1], ], 'cols' => 8, 'rows' => 8, ], 'dobby' => [ 'label' => 'Dobby', 'group' => 'specialty', // Diamond/lozenge motif typical of dobby weaves 'matrix' => [ [0,0,0,1,1,0,0,0], [0,0,1,0,0,1,0,0], [0,1,0,0,0,0,1,0], [1,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,1], [0,1,0,0,0,0,1,0], [0,0,1,0,0,1,0,0], [0,0,0,1,1,0,0,0], ], 'cols' => 8, 'rows' => 8, ], 'doublecloth' => [ 'label' => 'Double Cloth / Doble Tela', 'group' => 'specialty', // Two independent plain weave layers interleaved 'matrix' => [ [1,0,1,0,0,0,0,0], // face layer: plain on threads 0,1,2,3 [0,1,0,1,0,0,0,0], [0,0,0,0,1,0,1,0], // back layer: plain on threads 4,5,6,7 [0,0,0,0,0,1,0,1], [1,0,1,0,0,0,0,0], [0,1,0,1,0,0,0,0], [0,0,0,0,1,0,1,0], [0,0,0,0,0,1,0,1], ], 'cols' => 8, 'rows' => 8, ], ]; // Resolve to canonical key $key = $normalize($type); $pattern = $patterns[$key] ?? $patterns['plain']; $mRows = count($pattern['matrix']); $mCols = count($pattern['matrix'][0]); $gCols = $pattern['cols']; $gRows = $pattern['rows']; $W = $size / $gCols; $H = $size / $gRows; // Highlight colours per group $warpColor = match($pattern['group']) { 'twill' => '#1a3f72', 'satin' => '#1a3f72', 'specialty' => '#1a3f72', default => '#1a3f72', }; $weftColor = match($pattern['group']) { 'satin' => '#b8820a', default => '#c09030', }; // Ripstop reinforcing gets a slightly brighter warp highlight $warpHighlight = $key === 'ripstop' ? '#0d2a55' : $warpColor; @endphp @if($showLabel)