Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} 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,