const _256 = 256,
_256_SQUARE = 256 * 256,
_exp = Math.exp,
BLUE = 'blue',
CHROMA_MATCH = 'chroma-match',
COLOR_BURN = 'color-burn',
COLOR_DODGE = 'color-dodge',
CURRENT = 'current',
DARKEN = 'darken',
DESTINATION_ATOP = 'destination-atop',
DESTINATION_IN = 'destination-in',
DESTINATION_ONLY = 'destination-only',
DIFFERENCE = 'difference',
EXCLUSION = 'exclusion',
GRAY_PALETTES = ['black-white', 'monochrome-4', 'monochrome-8', 'monochrome-16'],
HARD_LIGHT = 'hard-light',
HEX = 'hex',
HUE = 'hue',
HUE_MATCH = 'hue-match',
LIGHTEN = 'lighten',
LIGHTER = 'lighter',
LUMINOSITY = 'luminosity',
MONOCHROME_16 = 'monochrome-16',
MONOCHROME_4 = 'monochrome-4',
MONOCHROME_8 = 'monochrome-8',
NAIVE_GRAY_LUT = 'naive-gray-lut',
ORDERED = 'ordered',
OVERLAY = 'overlay',
POINTS = 'points',
RECT = 'rect',
SATURATION = 'saturation',
SCREEN = 'screen',
SOFT_LIGHT = 'soft-light',
SOURCE_ALPHA = 'source-alpha',
SOURCE_ATOP = 'source-atop',
SOURCE_ONLY = 'source-only',
T_FILTER_ENGINE = 'FilterEngine',
XOR = 'xor';
const OK_BLENDS = [HUE, SATURATION, LUMINOSITY, COLOR, HUE_MATCH, CHROMA_MATCH];
const orderedNoise = new Float32Array([0.00,0.50,0.13,0.63,0.03,0.53,0.16,0.66,0.75,0.25,0.88,0.38,0.78,0.28,0.91,0.41,0.19,0.69,0.06,0.56,0.22,0.72,0.09,0.59,0.94,0.44,0.81,0.31,0.97,0.47,0.84,0.34,0.05,0.55,0.17,0.67,0.02,0.52,0.14,0.64,0.80,0.30,0.92,0.42,0.77,0.27,0.89,0.39,0.23,0.73,0.11,0.61,0.20,0.70,0.08,0.58,0.98,0.48,0.86,0.36,0.95,0.45,0.83,0.33]);
const newspaperPatterns = [
new Uint8Array([0,0,0,0]),
new Uint8Array([0,0,0,180]),
new Uint8Array([180,0,0,0]),
new Uint8Array([180,0,0,180]),
new Uint8Array([0,180,180,180]),
new Uint8Array([180,180,180,0]),
new Uint8Array([180,180,180,180]),
new Uint8Array([180,180,180,255]),
new Uint8Array([255,180,180,180]),
new Uint8Array([255,180,180,255]),
new Uint8Array([180,255,255,255]),
new Uint8Array([255,255,255,180]),
new Uint8Array([255,255,255,255])
];
const predefinedPalette = {
[BLACK_WHITE]: [255, 0],
[MONOCHROME_4]: [255, 187, 102, 0],
[MONOCHROME_8]: [255, 221, 187, 153, 119, 85, 51, 0],
[MONOCHROME_16]: [255, 238, 221, 204, 187, 170, 153, 136, 119, 102, 85, 68, 51, 34, 17, 0],
}