Initial commit

This commit is contained in:
2024-02-08 08:28:22 +01:00
commit b5f2518eeb
15 changed files with 275 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
export function grayScale(pixels: Uint8ClampedArray): void {
for (let i = 0; i < pixels.length; i += 4) {
// https://en.wikipedia.org/wiki/Grayscale#Luma_coding_in_video_systems
const lightness = (pixels[i] * .299 + pixels[i + 1] * .587 + pixels[i + 2] * .114) | 0;
pixels[i] = lightness;
pixels[i + 1] = lightness;
pixels[i + 2] = lightness;
}
}