A collection color manipulation functions and predefined palettes for working with EGA/CGA images.
const customPalette = Uint32Array.of(
//AA-BB-GG-RR
0xff_1f_1f_1f, // color 0
/* ... */
/* snip 14 more entries */
/* ... */
0xff_e0_e0_e0, // color 15
);
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 { generateSciDitherPairs, Mixers } from '@4bitlabs/color';
const pairs = generateSciDitherPairs(customPalette, Mixers.softMixer());
import { IBM5153Contrast } from '@4bitlabs/color';
// Simulate turning the constrast knob on a IBM-5153 to about 50%
const palette = IBM5153Contrast(Palettes.CGA_PALETTE, 0.5);
const grays = toGrayscale(Palettes.CGA_PALETTE);