How to use the pureimage/src/uint32.getBytesBigEndian function in pureimage

To help you get started, we’ve selected a few pureimage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vladimiry / ElectronMail / src / electron-main / api / endpoints-builders / tray-icon / lib.ts View on Github external
} as const;
    if (!hslColors.from || !hslColors.to) {
        throw new Error(`Failed to parse some of the Hex colors: ${JSON.stringify({from: fromColor, toColor})}`);
    }

    const hslColorShift = {
        hue: hslColors.to.hue - hslColors.from.hue,
        sat: hslColors.to.sat - hslColors.from.sat,
        lum: hslColors.to.lum - hslColors.from.lum,
    } as const;

    const bitmap = cloneBitmap(source);

    for (let x = 0; x < bitmap.width; x++) {
        for (let y = 0; y < bitmap.height; y++) {
            const [red, green, blue, alpha] = pureimageUInt32.getBytesBigEndian(
                bitmap.getPixelRGBA(x, y),
            );

            // skip transparent / semi-transparent pixels
            if (alpha < 10) {
                continue;
            }

            const hsl = rgbToHsl({red, green, blue});
            if (!hsl) {
                throw new Error(`Failed to form HSL value from RGB color: ${JSON.stringify({red, green, blue})}`);
            }

            const newHsl = {
                hue: hsl.hue + hslColorShift.hue,
                sat: hsl.sat + hslColorShift.sat,

pureimage

Pure JS image drawing API based on Canvas. Export to PNG, JPG, and streams.

MIT
Latest version published 7 months ago

Package Health Score

69 / 100
Full package analysis

Similar packages