Skip to content

Commit

Permalink
update hsluv to converter interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectronicBlueberry committed Oct 24, 2023
1 parent 3e7737d commit 9453be3
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions client/src/components/Workflow/Editor/Comments/colours.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hexToHsluv, hsluvToHex } from "hsluv";
import { Hsluv } from "hsluv";

export const colours = {
black: "#000",
Expand All @@ -17,24 +17,28 @@ export type HexColour = `#${string}`;

export const brightColours = (() => {
const brighter: Record<string, string> = {};
const converter = new Hsluv();

Object.entries(colours).forEach(([name, colour]) => {
const hsluv = hexToHsluv(colour);
let l = hsluv[2];
l += (100 - l) * 0.5;
hsluv[2] = l;
brighter[name] = hsluvToHex(hsluv);
converter.hex = colour;
converter.hexToHsluv();
converter.hsluv_l += (100 - converter.hsluv_l) * 0.5;
converter.hsluvToHex();
brighter[name] = converter.hex;
});
return brighter as Record<Colour, HexColour>;
})();

export const brighterColours = (() => {
const brighter: Record<string, string> = {};
const converter = new Hsluv();

Object.entries(colours).forEach(([name, colour]) => {
const hsluv = hexToHsluv(colour);
let l = hsluv[2];
l += (100 - l) * 0.95;
hsluv[2] = l;
brighter[name] = hsluvToHex(hsluv);
converter.hex = colour;
converter.hexToHsluv();
converter.hsluv_l += (100 - converter.hsluv_l) * 0.95;
converter.hsluvToHex();
brighter[name] = converter.hex;
});
return brighter as Record<Colour, HexColour>;
})();
Expand Down

0 comments on commit 9453be3

Please sign in to comment.