| 109 | } |
| 110 | |
| 111 | function fade(color: RGBA, base: RGBA, fallback: number, scale: number, limit: number): RGBA { |
| 112 | if (color.a === 0) { |
| 113 | return RGBA.fromValues(color.r, color.g, color.b, Math.max(0, Math.min(1, fallback))) |
| 114 | } |
| 115 | |
| 116 | const target = Math.min(limit, color.a * scale) |
| 117 | const mix = Math.min(1, target / color.a) |
| 118 | |
| 119 | return RGBA.fromValues( |
| 120 | base.r + (color.r - base.r) * mix, |
| 121 | base.g + (color.g - base.g) * mix, |
| 122 | base.b + (color.b - base.b) * mix, |
| 123 | color.a, |
| 124 | ) |
| 125 | } |
| 126 | |
| 127 | function ansiToRgba(code: number): RGBA { |
| 128 | if (code < 16) { |