Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function mapWebGLBlendModesToPixi(gl, array = [])
{
// TODO - premultiply alpha would be different.
// add a boolean for that!
array[BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.ADD] = [gl.ONE, gl.ONE];
array[BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.SCREEN] = [gl.ONE, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
array[BLEND_MODES.NONE] = [0, 0];
array[BLEND_MODES.COLOR_DODGE] = 'color-dodge';
array[BLEND_MODES.COLOR_BURN] = 'color-burn';
array[BLEND_MODES.HARD_LIGHT] = 'hard-light';
array[BLEND_MODES.SOFT_LIGHT] = 'soft-light';
array[BLEND_MODES.DIFFERENCE] = 'difference';
array[BLEND_MODES.EXCLUSION] = 'exclusion';
array[BLEND_MODES.HUE] = 'hue';
array[BLEND_MODES.SATURATION] = 'saturate';
array[BLEND_MODES.COLOR] = 'color';
array[BLEND_MODES.LUMINOSITY] = 'luminosity';
}
else
{
// this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough'
array[BLEND_MODES.NORMAL] = 'source-over';
array[BLEND_MODES.ADD] = 'lighter'; // IS THIS OK???
array[BLEND_MODES.MULTIPLY] = 'source-over';
array[BLEND_MODES.SCREEN] = 'source-over';
array[BLEND_MODES.OVERLAY] = 'source-over';
array[BLEND_MODES.DARKEN] = 'source-over';
array[BLEND_MODES.LIGHTEN] = 'source-over';
array[BLEND_MODES.COLOR_DODGE] = 'source-over';
array[BLEND_MODES.COLOR_BURN] = 'source-over';
array[BLEND_MODES.HARD_LIGHT] = 'source-over';
array[BLEND_MODES.SOFT_LIGHT] = 'source-over';
array[BLEND_MODES.DIFFERENCE] = 'source-over';
array[BLEND_MODES.EXCLUSION] = 'source-over';
array[BLEND_MODES.HUE] = 'source-over';
array[BLEND_MODES.SATURATION] = 'source-over';
array[BLEND_MODES.COLOR] = 'source-over';
array[BLEND_MODES.LUMINOSITY] = 'source-over';
}
{
const pm = [];
const npm = [];
for (let i = 0; i < 32; i++)
{
pm[i] = i;
npm[i] = i;
}
pm[BLEND_MODES.NORMAL_NPM] = BLEND_MODES.NORMAL;
pm[BLEND_MODES.ADD_NPM] = BLEND_MODES.ADD;
pm[BLEND_MODES.SCREEN_NPM] = BLEND_MODES.SCREEN;
npm[BLEND_MODES.NORMAL] = BLEND_MODES.NORMAL_NPM;
npm[BLEND_MODES.ADD] = BLEND_MODES.ADD_NPM;
npm[BLEND_MODES.SCREEN] = BLEND_MODES.SCREEN_NPM;
const array: number[][] = [];
array.push(npm);
array.push(pm);
return array;
}