nice-ui
Version:
React design system, components, and utilities
42 lines (41 loc) • 1.07 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Color = void 0;
class Color {
constructor(H, S, L, A = 100, light = true) {
this.H = H;
this.S = S;
this.L = L;
this.A = A;
this.light = light;
}
setA(A) {
const { H, S, L, light } = this;
return new Color(H, S, L, A, light);
}
setH(H) {
const { S, L, A, light } = this;
return new Color(H, S, L, A, light);
}
setS(S) {
const { H, L, A, light } = this;
return new Color(H, S, L, A, light);
}
setL(L) {
const { H, S, A, light } = this;
return new Color(H, S, L, A, light);
}
dS(dS) {
const { H, S, L, A, light } = this;
return new Color(H, S + dS, L, A, light);
}
dL(dL) {
const { H, S, L, A } = this;
return new Color(H, S, L + (this.light ? dL : -dL), A);
}
toString() {
const { H, S, L, A } = this;
return `oklch(${L}% ${S} ${H} / ${A}%)`;
}
}
exports.Color = Color;
;