| 84 | } |
| 85 | |
| 86 | static darken(hexColorString, amount = -50) { |
| 87 | if (hexColorString[0] !== '#') { |
| 88 | throw new Error(`Unsupported color: ${hexColorString}`); |
| 89 | } |
| 90 | let color = parseInt(hexColorString.substring(1), 16); |
| 91 | let b = Math.min(Math.max((color & 0xFF) + amount, 0), 0xFF); |
| 92 | let g = Math.min(Math.max(((color >> 8) & 0xFF) + amount, 0), 0xFF); |
| 93 | let r = Math.min(Math.max(((color >> 16) & 0xFF) + amount, 0), 0xFF); |
| 94 | color = (r << 16) + (g << 8) + b; |
| 95 | return `#${color.toString(16).padStart(6, '0')}`; |
| 96 | } |
| 97 | |
| 98 | static get list() { |
| 99 | if (!this._colors) { |