Normalize a 1–4 digit hex component to [0, 1].
(hex: string)
| 95 | |
| 96 | /** Normalize a 1–4 digit hex component to [0, 1]. */ |
| 97 | function hexComponent(hex: string): number { |
| 98 | const max = 16 ** hex.length - 1 |
| 99 | return parseInt(hex, 16) / max |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Read $COLORFGBG for a synchronous initial guess before the OSC 11 |