@4bitlabs/color
A collection color manipulation functions and predefined palettes for working with EGA/CGA images.
Documentation
Full documentation for the library can be found here.
Palettes
Predefined Palettes
Using your own Palette
const customPalette = Uint32Array.of(
0xff_1f_1f_1f,
0xff_e0_e0_e0,
);
Predefined Dither Pairs
Mix | Palette | Mix |
---|
Dithers.CGA | CGA | none |
Dithers.CGA_MIX | CGA | 25% mix |
Dithers.CGA_FLAT | CGA | 50% mix (SCUMMVM de-dithering) |
Dithers.CGA_SOFT | CGA | Dynamic mix |
Dithers.TRUE_CGA | TRUE-CGA | none |
Dithers.TRUE_CGA_MIX | TRUE-CGA | 25% mix |
Dithers.TRUE_CGA_FLAT | TRUE-CGA | 50% mix (SCUMMVM de-dithering) |
Dithers.TRUE_CGA_SOFT | TRUE-CGA | Dynamic mix |
Generating your own Dither Pairs
import { Dithers, Mixers } from '@4bitlabs/color';
const pairs = Dithers.generatePairs(customPalette, Mixers.softMixer());
IBM 5153 Contrast Knob
import { IBM5153Contrast } from '@4bitlabs/color';
const palette = IBM5153Contrast(Palettes.CGA_PALETTE, 0.5);
Simulating Grayscale
const grays = toGrayscale(Palettes.CGA_PALETTE);