(hex)
| 635 | |
| 636 | // Palette File Parsers |
| 637 | function hexToRgb(hex) { |
| 638 | hex = hex.replace(/^#/, ''); |
| 639 | if (hex.length === 3) { |
| 640 | hex = hex.split('').map(c => c + c).join(''); |
| 641 | } |
| 642 | if (hex.length !== 6) return null; |
| 643 | const n = parseInt(hex, 16); |
| 644 | if (isNaN(n)) return null; |
| 645 | return [(n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]; |
| 646 | } |
| 647 | |
| 648 | function parseGplPalette(text, name) { |
| 649 | const lines = text.split(/\r?\n/); |
no test coverage detected