This commit is contained in:
Rhiannon Morris 2024-12-08 03:32:47 +01:00
parent d0099fbf19
commit 815ef5c23f
10 changed files with 256 additions and 131 deletions

View file

@ -108,7 +108,11 @@ export class Oklch {
}
css(alpha: number = 1): string {
return `oklch(${this.l} ${this.c} ${this.h} / ${alpha})`;
const l = (this.l * 100).toFixed(0);
const c = (this.c * 250).toFixed(0);
const h = this.h.toFixed(0);
if (alpha != 1) { return `oklch(${l}% ${c}% ${h} / ${alpha})`; }
else { return `oklch(${l}% ${c}% ${h})`; }
}
with(lch: Partial<Record<Oklch.Channel, number | Oklch.ChannelMap>>): Oklch {