@4bitlabs/color
v4.0.4
Published
A collection color manipulation functions and predefined palettes for working with EGA/CGA images
Readme
@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
| Palette | |
| ---------------------------- | ----------------------------------------------------------------------------------------------- |
| Palettes.CGA_PALETTE | IBM's CGA Palette |
| Palettes.TRUE_CGA_PALETTE | VileR's "True" CGA Palettte |
| Palette.DGA_PALETTE | Adigun A. Polack's AAP-DGA16 |
| Palette.COLLY_SOFT_PALETTE | collyflower05's SOFT CGA PALETTE |
Using your own Palette
const customPalette = Uint32Array.of(
//AA-BB-GG-RR
0xff_1f_1f_1f, // color 0
/* ... */
/* snip 14 more entries */
/* ... */
0xff_e0_e0_e0, // color 15
);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';
// Simulate turning the constrast knob on a IBM-5153 to about 50%
const palette = IBM5153Contrast(Palettes.CGA_PALETTE, 0.5);Simulating Grayscale
const grays = toGrayscale(Palettes.CGA_PALETTE);