@helpwave/hightide
Version:
helpwave's component and theming library
47 lines (45 loc) • 1.5 kB
JavaScript
// src/coloring/shading.ts
import tinycolor from "tinycolor2";
// src/coloring/types.ts
var shadingColorValues = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1e3];
// src/coloring/shading.ts
var generateShadingColors = (partialShading) => {
const shading = {
0: "#FFFFFF",
1e3: "#000000"
};
let index = 1;
while (index < shadingColorValues.length - 1) {
const previous = shadingColorValues[index - 1];
const current = shadingColorValues[index];
if (partialShading[current] !== void 0) {
shading[current] = partialShading[current];
index++;
continue;
}
let j = index + 1;
while (j < shadingColorValues.length) {
if (partialShading[shadingColorValues[j]] !== void 0) {
break;
}
j++;
}
if (j === shadingColorValues.length) {
j = shadingColorValues.length - 1;
}
const nextFound = shadingColorValues[j];
const interval = nextFound - previous;
for (let k = index; k < j; k++) {
const current2 = shadingColorValues[k];
const previousValue = partialShading[previous] ?? shading[previous];
const nextValue = partialShading[nextFound] ?? shading[nextFound];
shading[current2] = tinycolor.mix(tinycolor(previousValue), tinycolor(nextValue), (current2 - previous) / interval * 100).toHexString();
}
index = j;
}
return shading;
};
export {
generateShadingColors
};
//# sourceMappingURL=shading.mjs.map