Function
blitShade
(
px: Uint8Array,
width: number,
x: number,
y: number,
fg: AnsiColor,
bg: AnsiColor,
alpha: number,
scale: number,
)
Source from the content-addressed store, hash-verified
| 179 | } |
| 180 | |
| 181 | function blitShade( |
| 182 | px: Uint8Array, |
| 183 | width: number, |
| 184 | x: number, |
| 185 | y: number, |
| 186 | fg: AnsiColor, |
| 187 | bg: AnsiColor, |
| 188 | alpha: number, |
| 189 | scale: number, |
| 190 | ): void { |
| 191 | const r = Math.round(fg.r * alpha + bg.r * (1 - alpha)) |
| 192 | const g = Math.round(fg.g * alpha + bg.g * (1 - alpha)) |
| 193 | const b = Math.round(fg.b * alpha + bg.b * (1 - alpha)) |
| 194 | const cellW = GLYPH_W * scale |
| 195 | const cellH = GLYPH_H * scale |
| 196 | for (let dy = 0; dy < cellH; dy++) { |
| 197 | const rowBase = ((y + dy) * width + x) * 4 |
| 198 | for (let dx = 0; dx < cellW; dx++) { |
| 199 | const i = rowBase + dx * 4 |
| 200 | px[i] = r |
| 201 | px[i + 1] = g |
| 202 | px[i + 2] = b |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Blit one glyph into the RGBA buffer at (x,y), scaled by `scale` |
Tested by
no test coverage detected