@helpwave/hightide
Version:
helpwave's component and theming library
81 lines (78 loc) • 3.19 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/coloring/shading.ts
var shading_exports = {};
__export(shading_exports, {
generateShadingColors: () => generateShadingColors
});
module.exports = __toCommonJS(shading_exports);
var import_tinycolor2 = __toESM(require("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] = import_tinycolor2.default.mix((0, import_tinycolor2.default)(previousValue), (0, import_tinycolor2.default)(nextValue), (current2 - previous) / interval * 100).toHexString();
}
index = j;
}
return shading;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
generateShadingColors
});
//# sourceMappingURL=shading.js.map