UNPKG

@e280/authlocal

Version:

User-sovereign login system for everybody

14 lines 504 B
import { Hex } from "@e280/stz"; /** derive a hue (integer 0-359) from a hex id */ export function idHue(id, byteIndex = -1) { const bytes = Hex.bytes(id); const x = bytes.at(byteIndex); if (x === undefined) throw new Error(`id didn't have byte at ${byteIndex}`); return Math.floor((x / 255) * 359); } /** derive an hsl color from a hex id */ export function idHsl(id, byteIndex = -1) { return `hsl(${idHue(id, byteIndex)}deg, 100%, 75%)`; } //# sourceMappingURL=id-hue.js.map