@colordx/core
Advanced tools
| import {a as a$1,b}from'./chunk-IOXRZECH.mjs';var h=Array.from({length:256},(t,r)=>r.toString(16).padStart(2,"0")),n=t=>h[a$1(Math.round(t),0,255)],s=t=>(t&15)+9*(t>>6),a=(t,r)=>s(t.charCodeAt(r))<<4|s(t.charCodeAt(r+1)),i=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,p=t=>{if(typeof t!="string")return null;let r=t.trim();if(!i.test(r))return null;let o=r.length;if(o===4||o===5){let e=s(r.charCodeAt(1)),c=s(r.charCodeAt(2)),b$1=s(r.charCodeAt(3)),l=o===5?s(r.charCodeAt(4)):15;return {r:e|e<<4,g:c|c<<4,b:b$1|b$1<<4,alpha:b((l|l<<4)/255,3)}}return {r:a(r,1),g:a(r,3),b:a(r,5),alpha:o===9?b(a(r,7)/255,3):1}},x=({r:t,g:r,b:o,alpha:e})=>{let c="#"+n(t)+n(r)+n(o);return e<1?c+n(e*255):c},f=({r:t,g:r,b:o,alpha:e})=>"#"+n(t)+n(r)+n(o)+n(e*255);export{n as a,p as b,x as c,f as d};//# sourceMappingURL=chunk-RJNXPIQM.mjs.map | ||
| //# sourceMappingURL=chunk-RJNXPIQM.mjs.map |
| {"version":3,"sources":["../src/colorModels/hex.ts"],"names":["HEX_BYTE","_","i","toHexByte","n","clamp","hexNibble","c","hexByte","s","HEX_RE","parseHex","input","len","rv","gv","bv","av","round","rgbToHex","r","g","b","alpha","hex","rgbToHex8"],"mappings":"8CAGA,IAAMA,CAAAA,CAA2B,KAAA,CAAM,IAAA,CAAK,CAAE,MAAA,CAAQ,GAAI,CAAA,CAAG,CAACC,CAAAA,CAAGC,CAAAA,GAAMA,CAAAA,CAAE,QAAA,CAAS,EAAE,EAAE,QAAA,CAAS,CAAA,CAAG,GAAG,CAAC,CAAA,CAGzFC,CAAAA,CAAaC,CAAAA,EAAsBJ,CAAAA,CAASK,GAAAA,CAAM,IAAA,CAAK,KAAA,CAAMD,CAAC,CAAA,C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E__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n\n/** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */\nexport const toHexByte = (n: number): string => HEX_BYTE[clamp(Math.round(n), 0, 255)]!;\nconst hexNibble = (c: number): number => (c & 0xf) + 9 * (c >> 6);\nconst hexByte = (s: string, i: number): number => (hexNibble(s.charCodeAt(i)) << 4) | hexNibble(s.charCodeAt(i + 1));\nconst HEX_RE = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\nexport const parseHex = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const s = input.trim();\n if (!HEX_RE.test(s)) return null;\n const len = s.length;\n\n if (len === 4 || len === 5) {\n const rv = hexNibble(s.charCodeAt(1));\n const gv = hexNibble(s.charCodeAt(2));\n const bv = hexNibble(s.charCodeAt(3));\n const av = len === 5 ? hexNibble(s.charCodeAt(4)) : 15;\n return { r: rv | (rv << 4), g: gv | (gv << 4), b: bv | (bv << 4), alpha: round((av | (av << 4)) / 255, 3) };\n }\n\n return {\n r: hexByte(s, 1),\n g: hexByte(s, 3),\n b: hexByte(s, 5),\n alpha: len === 9 ? round(hexByte(s, 7) / 255, 3) : 1,\n };\n};\n\nexport const rgbToHex = ({ r, g, b, alpha }: RgbColor): string => {\n const hex = '#' + toHexByte(r) + toHexByte(g) + toHexByte(b);\n return alpha < 1 ? hex + toHexByte(alpha * 255) : hex;\n};\n\n/** Always emits 8-digit `#rrggbbaa`, regardless of alpha. Companion to `rgbToHex`. */\nexport const rgbToHex8 = ({ r, g, b, alpha }: RgbColor): string =>\n '#' + toHexByte(r) + toHexByte(g) + toHexByte(b) + toHexByte(alpha * 255);\n"]} |
| 'use strict';var chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var h=Array.from({length:256},(t,r)=>r.toString(16).padStart(2,"0")),n=t=>h[chunkYISEJCI6_cjs.a(Math.round(t),0,255)],s=t=>(t&15)+9*(t>>6),a=(t,r)=>s(t.charCodeAt(r))<<4|s(t.charCodeAt(r+1)),i=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,p=t=>{if(typeof t!="string")return null;let r=t.trim();if(!i.test(r))return null;let o=r.length;if(o===4||o===5){let e=s(r.charCodeAt(1)),c=s(r.charCodeAt(2)),b=s(r.charCodeAt(3)),l=o===5?s(r.charCodeAt(4)):15;return {r:e|e<<4,g:c|c<<4,b:b|b<<4,alpha:chunkYISEJCI6_cjs.b((l|l<<4)/255,3)}}return {r:a(r,1),g:a(r,3),b:a(r,5),alpha:o===9?chunkYISEJCI6_cjs.b(a(r,7)/255,3):1}},x=({r:t,g:r,b:o,alpha:e})=>{let c="#"+n(t)+n(r)+n(o);return e<1?c+n(e*255):c},f=({r:t,g:r,b:o,alpha:e})=>"#"+n(t)+n(r)+n(o)+n(e*255);exports.a=n;exports.b=p;exports.c=x;exports.d=f;//# sourceMappingURL=chunk-UAXI5JGL.cjs.map | ||
| //# sourceMappingURL=chunk-UAXI5JGL.cjs.map |
| {"version":3,"sources":["../src/colorModels/hex.ts"],"names":["HEX_BYTE","_","i","toHexByte","n","clamp","hexNibble","c","hexByte","s","HEX_RE","parseHex","input","len","rv","gv","bv","av","round","rgbToHex","r","g","b","alpha","hex","rgbToHex8"],"mappings":"mEAGA,IAAMA,CAAAA,CAA2B,KAAA,CAAM,IAAA,CAAK,CAAE,MAAA,CAAQ,GAAI,CAAA,CAAG,CAACC,CAAAA,CAAGC,CAAAA,GAAMA,CAAAA,CAAE,QAAA,CAAS,EAAE,EAAE,QAAA,CAAS,CAAA,CAAG,GAAG,CAAC,CAAA,CAGzFC,CAAAA,CAAaC,CAAAA,EAAsBJ,CAAAA,CAASK,mBAAAA,CAAM,IAAA,CAAK,KAAA,CAAMD,CAAC,CAAA,CAAG,CAAA,CAAG,GAAG,CAAC,CAAA,CAC/EE,CAAAA,CAAaC,CAAAA,EAAAA,CAAuBA,CAAAA,CAA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K,CAAC,CAAE,CAC5G,CAEA,OAAO,CACL,EAAGT,CAAAA,CAAQC,CAAAA,CAAG,CAAC,CAAA,CACf,CAAA,CAAGD,CAAAA,CAAQC,CAAAA,CAAG,CAAC,CAAA,CACf,CAAA,CAAGD,CAAAA,CAAQC,CAAAA,CAAG,CAAC,CAAA,CACf,MAAOI,CAAAA,GAAQ,CAAA,CAAIK,mBAAAA,CAAMV,CAAAA,CAAQC,CAAAA,CAAG,CAAC,CAAA,CAAI,GAAA,CAAK,CAAC,CAAA,CAAI,CACrD,CACF,CAAA,CAEaU,CAAAA,CAAW,CAAC,CAAE,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,GAAwB,CAChE,IAAMC,CAAAA,CAAM,GAAA,CAAMrB,EAAUiB,CAAC,CAAA,CAAIjB,CAAAA,CAAUkB,CAAC,CAAA,CAAIlB,CAAAA,CAAUmB,CAAC,CAAA,CAC3D,OAAOC,CAAAA,CAAQ,CAAA,CAAIC,CAAAA,CAAMrB,CAAAA,CAAUoB,CAAAA,CAAQ,GAAG,CAAA,CAAIC,CACpD,CAAA,CAGaC,CAAAA,CAAY,CAAC,CAAE,CAAA,CAAAL,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,IACzC,GAAA,CAAMpB,CAAAA,CAAUiB,CAAC,CAAA,CAAIjB,CAAAA,CAAUkB,CAAC,CAAA,CAAIlB,CAAAA,CAAUmB,CAAC,CAAA,CAAInB,CAAAA,CAAUoB,CAAAA,CAAQ,GAAG","file":"chunk-UAXI5JGL.cjs","sourcesContent":["import { clamp, round } from '../helpers.js';\nimport type { RgbColor } from '../types.js';\n\nconst HEX_BYTE = /* #__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n\n/** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */\nexport const toHexByte = (n: number): string => HEX_BYTE[clamp(Math.round(n), 0, 255)]!;\nconst hexNibble = (c: number): number => (c & 0xf) + 9 * (c >> 6);\nconst hexByte = (s: string, i: number): number => (hexNibble(s.charCodeAt(i)) << 4) | hexNibble(s.charCodeAt(i + 1));\nconst HEX_RE = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\nexport const parseHex = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const s = input.trim();\n if (!HEX_RE.test(s)) return null;\n const len = s.length;\n\n if (len === 4 || len === 5) {\n const rv = hexNibble(s.charCodeAt(1));\n const gv = hexNibble(s.charCodeAt(2));\n const bv = hexNibble(s.charCodeAt(3));\n const av = len === 5 ? hexNibble(s.charCodeAt(4)) : 15;\n return { r: rv | (rv << 4), g: gv | (gv << 4), b: bv | (bv << 4), alpha: round((av | (av << 4)) / 255, 3) };\n }\n\n return {\n r: hexByte(s, 1),\n g: hexByte(s, 3),\n b: hexByte(s, 5),\n alpha: len === 9 ? round(hexByte(s, 7) / 255, 3) : 1,\n };\n};\n\nexport const rgbToHex = ({ r, g, b, alpha }: RgbColor): string => {\n const hex = '#' + toHexByte(r) + toHexByte(g) + toHexByte(b);\n return alpha < 1 ? hex + toHexByte(alpha * 255) : hex;\n};\n\n/** Always emits 8-digit `#rrggbbaa`, regardless of alpha. Companion to `rgbToHex`. */\nexport const rgbToHex8 = ({ r, g, b, alpha }: RgbColor): string =>\n '#' + toHexByte(r) + toHexByte(g) + toHexByte(b) + toHexByte(alpha * 255);\n"]} |
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| type RgbColorInput = Omit<RgbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| type HslColorInput = Omit<HslColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| type HsvColorInput = Omit<HsvColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100] */ | ||
| w: number; | ||
| /** Blackness [0, 100] */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| type HwbColorInput = Omit<HwbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LAB (D50) */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| type LabColorInput = Omit<LabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LCH (D50) */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| type LchColorInput = Omit<LchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D65) */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| type XyzColorInput = Omit<XyzColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| type CmykColorInput = Omit<CmykColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Oklab — perceptually uniform, D65 */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| type OklabColorInput = Omit<OklabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Oklch — perceptually uniform, polar form of Oklab */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| type OklchColorInput = Omit<OklchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Display-P3 */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| type P3ColorInput = Omit<P3Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Rec.2020 */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput; | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'cmyk' | 'p3' | 'rec2020' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally. | ||
| * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding, | ||
| * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output. | ||
| * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| */ | ||
| static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx; | ||
| isValid(): boolean; | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| toRgbString(): string; | ||
| toHex(): string; | ||
| /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */ | ||
| toHex8(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| toHsl(precision?: number): HslColor; | ||
| toHslString(precision?: number): string; | ||
| toOklab(): OklabColor; | ||
| toOklabString(): string; | ||
| toOklch(): OklchColor; | ||
| toOklchString(): string; | ||
| brightness(): number; | ||
| isDark(): boolean; | ||
| isLight(): boolean; | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| grayscale(): Colordx; | ||
| invert(): Colordx; | ||
| rotate(amount?: number): Colordx; | ||
| isEqual(color: AnyColor): boolean; | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| /** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */ | ||
| declare const toHex8: (input: AnyColor | Colordx) => string; | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z }; |
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| type RgbColorInput = Omit<RgbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| type HslColorInput = Omit<HslColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| type HsvColorInput = Omit<HsvColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100] */ | ||
| w: number; | ||
| /** Blackness [0, 100] */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| type HwbColorInput = Omit<HwbColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LAB (D50) */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| type LabColorInput = Omit<LabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE LCH (D50) */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| type LchColorInput = Omit<LchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CIE XYZ (D65) */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| type XyzColorInput = Omit<XyzColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| type CmykColorInput = Omit<CmykColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Oklab — perceptually uniform, D65 */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| type OklabColorInput = Omit<OklabColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** Oklch — perceptually uniform, polar form of Oklab */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| type OklchColorInput = Omit<OklchColor, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Display-P3 */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| type P3ColorInput = Omit<P3Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| /** CSS Color 4 Rec.2020 */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & { | ||
| alpha?: number; | ||
| }; | ||
| type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput; | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'cmyk' | 'p3' | 'rec2020' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally. | ||
| * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding, | ||
| * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output. | ||
| * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| */ | ||
| static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx; | ||
| isValid(): boolean; | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| toRgbString(): string; | ||
| toHex(): string; | ||
| /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */ | ||
| toHex8(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| toHsl(precision?: number): HslColor; | ||
| toHslString(precision?: number): string; | ||
| toOklab(): OklabColor; | ||
| toOklabString(): string; | ||
| toOklch(): OklchColor; | ||
| toOklchString(): string; | ||
| brightness(): number; | ||
| isDark(): boolean; | ||
| isLight(): boolean; | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| grayscale(): Colordx; | ||
| invert(): Colordx; | ||
| rotate(amount?: number): Colordx; | ||
| isEqual(color: AnyColor): boolean; | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| /** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */ | ||
| declare const toHex8: (input: AnyColor | Colordx) => string; | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z }; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunkZ5MM7DU5_cjs=require('./chunk-Z5MM7DU5.cjs'),chunkLTRVT3GL_cjs=require('./chunk-LTRVT3GL.cjs'),chunkGXECYURS_cjs=require('./chunk-GXECYURS.cjs');require('./chunk-EDNIB75Q.cjs');var chunkX5FCFNQN_cjs=require('./chunk-X5FCFNQN.cjs'),chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var V=l=>({h:chunkYISEJCI6_cjs.c(l.h),s:chunkYISEJCI6_cjs.a(l.s,0,100),l:chunkYISEJCI6_cjs.a(l.l,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(l.alpha,3),0,1)}),O={h:0,s:0,l:0,alpha:0},R=({r:l,g:r,b:o,alpha:t})=>{let n=l/255,e=r/255,s=o/255,a=Math.max(n,e,s),b=Math.min(n,e,s),C=(a+b)/2,d=0,x=0;if(a!==b){let _=a-b;switch(x=C>.5?_/(2-a-b):_/(a+b),a){case n:d=((e-s)/_+(e<s?6:0))/6;break;case e:d=((s-n)/_+2)/6;break;case s:d=((n-e)/_+4)/6;break}}let y=d*360;return O.h=y>=0&&y<360?y:(y%360+360)%360,O.s=chunkYISEJCI6_cjs.a(x*100,0,100),O.l=chunkYISEJCI6_cjs.a(C*100,0,100),O.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t,3),0,1),O};var N=(l,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?l+(r-l)*6*o:o<1/2?r:o<2/3?l+(r-l)*(2/3-o)*6:l),k=({h:l,s:r,l:o,alpha:t})=>{let n=r/100,e=o/100,s=e<.5?e*(1+n):e+n-e*n,a=2*e-s,b=(l%360+360)%360/360;return {r:N(a,s,b+1/3)*255,g:N(a,s,b)*255,b:N(a,s,b-1/3)*255,alpha:t}},X=l=>{if(!chunkYISEJCI6_cjs.h(l)||!chunkYISEJCI6_cjs.i(l,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:n=1}=l;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)?null:k(V({h:chunkYISEJCI6_cjs.g(r),s:chunkYISEJCI6_cjs.g(o),l:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.g(n)}))},mr=new RegExp(`^hsla?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<l_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<l_s>${chunkYISEJCI6_cjs.k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=l=>{if(typeof l!="string")return null;let r=mr.exec(l.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",n=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),e=chunkYISEJCI6_cjs.l(r.s_c??r.s_s),s=chunkYISEJCI6_cjs.l(r.l_c??r.l_s),a=r.al_c??r.al_s,b=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let C=a===void 0?1:chunkYISEJCI6_cjs.l(a)/(b?100:1);return k(V({h:n,s:e,l:s,alpha:C}))};var Q=({l,c:r,h:o,alpha:t})=>({l,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=l=>{let{l:r,a:o,b:t,alpha:n}=chunkGXECYURS_cjs.b(l),e=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:e,h:e<4e-6?0:chunkYISEJCI6_cjs.c(s),alpha:n}},A=l=>chunkGXECYURS_cjs.d(Q(l)),Y=l=>chunkGXECYURS_cjs.c(Q(l)),Z=l=>{if(!chunkYISEJCI6_cjs.h(l)||l.colorSpace==="lch"||!chunkYISEJCI6_cjs.i(l,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:n=1}=l;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)||chunkYISEJCI6_cjs.g(r)>1?null:Y({l:chunkYISEJCI6_cjs.g(r),c:Math.max(0,chunkYISEJCI6_cjs.g(o)),h:chunkYISEJCI6_cjs.c(chunkYISEJCI6_cjs.g(t)),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(n),0,1)})},Cr=new RegExp(`^oklch\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<c>${chunkYISEJCI6_cjs.k})(?<cp>%?)\\s+(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),rr=l=>{if(typeof l!="string")return null;let r=Cr.exec(l.trim())?.groups;if(!r)return null;let o=r.lp?chunkYISEJCI6_cjs.l(r.l)/100:chunkYISEJCI6_cjs.l(r.l),t=Math.max(0,r.cp?chunkYISEJCI6_cjs.l(r.c)*.004:chunkYISEJCI6_cjs.l(r.c)),n=r.hu?.toLowerCase()??"deg",e=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[n]??1),s=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:chunkYISEJCI6_cjs.c(e),alpha:chunkYISEJCI6_cjs.a(s,0,1)})};var or=[[chunkZ5MM7DU5_cjs.a,"hex"],[chunk3V4MONNR_cjs.c,"rgb"],[J,"hsl"],[rr,"oklch"],[chunkGXECYURS_cjs.h,"oklab"]],tr=[[chunk3V4MONNR_cjs.b,"rgb"],[X,"hsl"],[chunkGXECYURS_cjs.g,"oklab"],[Z,"oklch"]],lr=or.map(([l])=>l),nr=tr.map(([l])=>l),er=[...lr,...nr],L=[...er],F=[],sr=l=>{if(l==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof l=="string"?lr:nr;for(let o of r){let t=o(l);if(t)return t}for(let o=er.length;o<L.length;o++){let t=L[o](l);if(t)return t}return null},dr=l=>{if(l==="transparent")return "name";let r=typeof l=="string"?or:tr;for(let[o,t]of r)if(o(l))return t;for(let[o,t]of F)if(o(l))return t};var ar=Symbol(),g=class l{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof l){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(this._rgb.alpha,3),0,1);}static _make(r){return new l(ar,r)}static _makeFromOklab({l:r,a:o,b:t,alpha:n}){let[e,s,a]=chunkGXECYURS_cjs.f(r,o,t);return l._make({r:chunkX5FCFNQN_cjs.b(e)*255,g:chunkX5FCFNQN_cjs.b(s)*255,b:chunkX5FCFNQN_cjs.b(a)*255,alpha:n})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return {r:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),g:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),b:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),alpha:n}}_rawRgb(){return this._rgb}toRgbString(){let{r,g:o,b:t,alpha:n}=this._rgb,e=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),s=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),a=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255);return n<1?`rgb(${e} ${s} ${a} / ${n})`:`rgb(${e} ${s} ${a})`}toHex(){return chunkZ5MM7DU5_cjs.b(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255)<<16|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255)<<8|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255)}toHsl(r=2){let{h:o,s:t,l:n,alpha:e}=R(this._rgb),s=chunkYISEJCI6_cjs.b(o,r);return {h:s>=360?0:s,s:chunkYISEJCI6_cjs.b(t,r),l:chunkYISEJCI6_cjs.b(n,r),alpha:e}}toHslString(r=2){let{h:o,s:t,l:n,alpha:e}=this.toHsl(r);return e<1?`hsl(${o} ${t}% ${n}% / ${e})`:`hsl(${o} ${t}% ${n}%)`}toOklab(){let{l:r,a:o,b:t,alpha:n}=chunkGXECYURS_cjs.b(this._rgb);return {l:chunkYISEJCI6_cjs.b(r,4),a:chunkYISEJCI6_cjs.b(o,4),b:chunkYISEJCI6_cjs.b(t,4),alpha:n}}toOklabString(){let{l:r,a:o,b:t,alpha:n}=this.toOklab();return n<1?`oklab(${r} ${o} ${t} / ${n})`:`oklab(${r} ${o} ${t})`}toOklch(){let{l:r,c:o,h:t,alpha:n}=W(this._rgb);return {l:chunkYISEJCI6_cjs.b(r,4),c:chunkYISEJCI6_cjs.b(o,4),h:chunkYISEJCI6_cjs.b(t,2),alpha:n}}toOklchString(){let{l:r,c:o,h:t,alpha:n}=this.toOklch(),e=o===0?"none":t;return n<1?`oklch(${r} ${o} ${e} / ${n})`:`oklch(${r} ${o} ${e})`}brightness(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.b((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:l._make({...this._rgb,alpha:chunkYISEJCI6_cjs.b(chunkYISEJCI6_cjs.a(r,0,1),3)})}hue(r){let{h:o,s:t,l:n,alpha:e}=R(this._rgb);if(r===void 0){let s=chunkYISEJCI6_cjs.b(o,2);return s>=360?0:s}return l._make(k({h:r,s:t,l:n,alpha:e}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:l._make(A({...o,l:chunkYISEJCI6_cjs.a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:l._make(A({...o,c:chunkYISEJCI6_cjs.a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?e*(1+r):e+r*100;return l._make(k({h:t,s:n,l:chunkYISEJCI6_cjs.a(a,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?n*(1+r):n+r*100;return l._make(k({h:t,s:chunkYISEJCI6_cjs.a(a,0,100),l:e,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:n}=this._rgb;return l._make({r:255-r,g:255-o,b:255-t,alpha:n})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new l(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:l._make({r:chunkYISEJCI6_cjs.a(r,0,255),g:chunkYISEJCI6_cjs.a(o,0,255),b:chunkYISEJCI6_cjs.a(t,0,255),alpha:n})}mapSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[e,s,a]=chunkGXECYURS_cjs.a(chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(o/255),chunkX5FCFNQN_cjs.a(t/255)),b=e>1-1e-7?1:e<1e-7?0:e,C=chunkLTRVT3GL_cjs.b({l:b,a:s,b:a,alpha:n});return C!==null?l._makeFromOklab(C):this}static toGamutSrgb},fr=l=>new g(l),kr=l=>{l.forEach(r=>r(g,L,F));},xr=(l,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:n}=new g(l).toOklab(),e=1/0,s=r[0];for(let a of r){let{l:b,a:C,b:d}=new g(a).toOklab(),x=(b-o)**2+(C-t)**2+(d-n)**2;x<e&&(e=x,s=a);}return s},_r=()=>new g({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});g.toGamutSrgb=l=>{let r=chunkLTRVT3GL_cjs.b(l);return r!==null?g._makeFromOklab(r):new g(l)};Object.defineProperty(exports,"inGamutSrgb",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.a}});Object.defineProperty(exports,"oklchToLinear",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.e}});Object.defineProperty(exports,"oklchToLinearAndSrgb",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.i}});Object.defineProperty(exports,"oklchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.j}});Object.defineProperty(exports,"oklchToLinearInto",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.f}});Object.defineProperty(exports,"oklchToRgbChannels",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.g}});Object.defineProperty(exports,"oklchToRgbChannelsInto",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.h}});exports.Colordx=g;exports.colordx=fr;exports.extend=kr;exports.getFormat=dr;exports.nearest=xr;exports.random=_r;//# sourceMappingURL=index.cjs.map | ||
| 'use strict';var chunkUAXI5JGL_cjs=require('./chunk-UAXI5JGL.cjs'),chunkLTRVT3GL_cjs=require('./chunk-LTRVT3GL.cjs'),chunkGXECYURS_cjs=require('./chunk-GXECYURS.cjs');require('./chunk-EDNIB75Q.cjs');var chunkX5FCFNQN_cjs=require('./chunk-X5FCFNQN.cjs'),chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var V=l=>({h:chunkYISEJCI6_cjs.c(l.h),s:chunkYISEJCI6_cjs.a(l.s,0,100),l:chunkYISEJCI6_cjs.a(l.l,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(l.alpha,3),0,1)}),O={h:0,s:0,l:0,alpha:0},R=({r:l,g:r,b:o,alpha:t})=>{let n=l/255,e=r/255,s=o/255,a=Math.max(n,e,s),b=Math.min(n,e,s),C=(a+b)/2,k=0,x=0;if(a!==b){let _=a-b;switch(x=C>.5?_/(2-a-b):_/(a+b),a){case n:k=((e-s)/_+(e<s?6:0))/6;break;case e:k=((s-n)/_+2)/6;break;case s:k=((n-e)/_+4)/6;break}}let y=k*360;return O.h=y>=0&&y<360?y:(y%360+360)%360,O.s=chunkYISEJCI6_cjs.a(x*100,0,100),O.l=chunkYISEJCI6_cjs.a(C*100,0,100),O.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t,3),0,1),O};var A=(l,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?l+(r-l)*6*o:o<1/2?r:o<2/3?l+(r-l)*(2/3-o)*6:l),f=({h:l,s:r,l:o,alpha:t})=>{let n=r/100,e=o/100,s=e<.5?e*(1+n):e+n-e*n,a=2*e-s,b=(l%360+360)%360/360;return {r:A(a,s,b+1/3)*255,g:A(a,s,b)*255,b:A(a,s,b-1/3)*255,alpha:t}},J=l=>{if(!chunkYISEJCI6_cjs.h(l)||!chunkYISEJCI6_cjs.i(l,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:n=1}=l;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)?null:f(V({h:chunkYISEJCI6_cjs.g(r),s:chunkYISEJCI6_cjs.g(o),l:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.g(n)}))},kr=new RegExp(`^hsla?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<l_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<l_s>${chunkYISEJCI6_cjs.k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),Q=l=>{if(typeof l!="string")return null;let r=kr.exec(l.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",n=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),e=chunkYISEJCI6_cjs.l(r.s_c??r.s_s),s=chunkYISEJCI6_cjs.l(r.l_c??r.l_s),a=r.al_c??r.al_s,b=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let C=a===void 0?1:chunkYISEJCI6_cjs.l(a)/(b?100:1);return f(V({h:n,s:e,l:s,alpha:C}))};var W=({l,c:r,h:o,alpha:t})=>({l,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),Y=l=>{let{l:r,a:o,b:t,alpha:n}=chunkGXECYURS_cjs.b(l),e=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:e,h:e<4e-6?0:chunkYISEJCI6_cjs.c(s),alpha:n}},M=l=>chunkGXECYURS_cjs.d(W(l)),Z=l=>chunkGXECYURS_cjs.c(W(l)),rr=l=>{if(!chunkYISEJCI6_cjs.h(l)||l.colorSpace==="lch"||!chunkYISEJCI6_cjs.i(l,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:n=1}=l;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)||chunkYISEJCI6_cjs.g(r)>1?null:Z({l:chunkYISEJCI6_cjs.g(r),c:Math.max(0,chunkYISEJCI6_cjs.g(o)),h:chunkYISEJCI6_cjs.c(chunkYISEJCI6_cjs.g(t)),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(n),0,1)})},dr=new RegExp(`^oklch\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<c>${chunkYISEJCI6_cjs.k})(?<cp>%?)\\s+(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),or=l=>{if(typeof l!="string")return null;let r=dr.exec(l.trim())?.groups;if(!r)return null;let o=r.lp?chunkYISEJCI6_cjs.l(r.l)/100:chunkYISEJCI6_cjs.l(r.l),t=Math.max(0,r.cp?chunkYISEJCI6_cjs.l(r.c)*.004:chunkYISEJCI6_cjs.l(r.c)),n=r.hu?.toLowerCase()??"deg",e=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[n]??1),s=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Z({l:o,c:t,h:chunkYISEJCI6_cjs.c(e),alpha:chunkYISEJCI6_cjs.a(s,0,1)})};var tr=[[chunkUAXI5JGL_cjs.b,"hex"],[chunk3V4MONNR_cjs.c,"rgb"],[Q,"hsl"],[or,"oklch"],[chunkGXECYURS_cjs.h,"oklab"]],lr=[[chunk3V4MONNR_cjs.b,"rgb"],[J,"hsl"],[chunkGXECYURS_cjs.g,"oklab"],[rr,"oklch"]],nr=tr.map(([l])=>l),er=lr.map(([l])=>l),sr=[...nr,...er],L=[...sr],N=[],ar=l=>{if(l==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof l=="string"?nr:er;for(let o of r){let t=o(l);if(t)return t}for(let o=sr.length;o<L.length;o++){let t=L[o](l);if(t)return t}return null},fr=l=>{if(l==="transparent")return "name";let r=typeof l=="string"?tr:lr;for(let[o,t]of r)if(o(l))return t;for(let[o,t]of N)if(o(l))return t};var hr=Symbol(),u=class l{_rgb;_valid;constructor(r,o){if(r===hr)this._valid=true,this._rgb=o;else if(r instanceof l){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=ar(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(this._rgb.alpha,3),0,1);}static _make(r){return new l(hr,r)}static _makeFromOklab({l:r,a:o,b:t,alpha:n}){let[e,s,a]=chunkGXECYURS_cjs.f(r,o,t);return l._make({r:chunkX5FCFNQN_cjs.b(e)*255,g:chunkX5FCFNQN_cjs.b(s)*255,b:chunkX5FCFNQN_cjs.b(a)*255,alpha:n})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return {r:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),g:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),b:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),alpha:n}}_rawRgb(){return this._rgb}toRgbString(){let{r,g:o,b:t,alpha:n}=this._rgb,e=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),s=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),a=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255);return n<1?`rgb(${e} ${s} ${a} / ${n})`:`rgb(${e} ${s} ${a})`}toHex(){return chunkUAXI5JGL_cjs.c(this._rgb)}toHex8(){return chunkUAXI5JGL_cjs.d(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255)<<16|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255)<<8|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255)}toHsl(r=2){let{h:o,s:t,l:n,alpha:e}=R(this._rgb),s=chunkYISEJCI6_cjs.b(o,r);return {h:s>=360?0:s,s:chunkYISEJCI6_cjs.b(t,r),l:chunkYISEJCI6_cjs.b(n,r),alpha:e}}toHslString(r=2){let{h:o,s:t,l:n,alpha:e}=this.toHsl(r);return e<1?`hsl(${o} ${t}% ${n}% / ${e})`:`hsl(${o} ${t}% ${n}%)`}toOklab(){let{l:r,a:o,b:t,alpha:n}=chunkGXECYURS_cjs.b(this._rgb);return {l:chunkYISEJCI6_cjs.b(r,4),a:chunkYISEJCI6_cjs.b(o,4),b:chunkYISEJCI6_cjs.b(t,4),alpha:n}}toOklabString(){let{l:r,a:o,b:t,alpha:n}=this.toOklab();return n<1?`oklab(${r} ${o} ${t} / ${n})`:`oklab(${r} ${o} ${t})`}toOklch(){let{l:r,c:o,h:t,alpha:n}=Y(this._rgb);return {l:chunkYISEJCI6_cjs.b(r,4),c:chunkYISEJCI6_cjs.b(o,4),h:chunkYISEJCI6_cjs.b(t,2),alpha:n}}toOklchString(){let{l:r,c:o,h:t,alpha:n}=this.toOklch(),e=o===0?"none":t;return n<1?`oklch(${r} ${o} ${e} / ${n})`:`oklch(${r} ${o} ${e})`}brightness(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.b((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:l._make({...this._rgb,alpha:chunkYISEJCI6_cjs.b(chunkYISEJCI6_cjs.a(r,0,1),3)})}hue(r){let{h:o,s:t,l:n,alpha:e}=R(this._rgb);if(r===void 0){let s=chunkYISEJCI6_cjs.b(o,2);return s>=360?0:s}return l._make(f({h:r,s:t,l:n,alpha:e}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:l._make(M({...o,l:chunkYISEJCI6_cjs.a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:l._make(M({...o,c:chunkYISEJCI6_cjs.a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?e*(1+r):e+r*100;return l._make(f({h:t,s:n,l:chunkYISEJCI6_cjs.a(a,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?n*(1+r):n+r*100;return l._make(f({h:t,s:chunkYISEJCI6_cjs.a(a,0,100),l:e,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:n}=this._rgb;return l._make({r:255-r,g:255-o,b:255-t,alpha:n})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new l(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:l._make({r:chunkYISEJCI6_cjs.a(r,0,255),g:chunkYISEJCI6_cjs.a(o,0,255),b:chunkYISEJCI6_cjs.a(t,0,255),alpha:n})}mapSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[e,s,a]=chunkGXECYURS_cjs.a(chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(o/255),chunkX5FCFNQN_cjs.a(t/255)),b=e>1-1e-7?1:e<1e-7?0:e,C=chunkLTRVT3GL_cjs.b({l:b,a:s,b:a,alpha:n});return C!==null?l._makeFromOklab(C):this}static toGamutSrgb},xr=l=>new u(l),_r=l=>new u(l).toHex8(),Or=l=>{l.forEach(r=>r(u,L,N));},Rr=(l,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:n}=new u(l).toOklab(),e=1/0,s=r[0];for(let a of r){let{l:b,a:C,b:k}=new u(a).toOklab(),x=(b-o)**2+(C-t)**2+(k-n)**2;x<e&&(e=x,s=a);}return s},yr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=l=>{let r=chunkLTRVT3GL_cjs.b(l);return r!==null?u._makeFromOklab(r):new u(l)};Object.defineProperty(exports,"toHexByte",{enumerable:true,get:function(){return chunkUAXI5JGL_cjs.a}});Object.defineProperty(exports,"inGamutSrgb",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.a}});Object.defineProperty(exports,"oklchToLinear",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.e}});Object.defineProperty(exports,"oklchToLinearAndSrgb",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.i}});Object.defineProperty(exports,"oklchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.j}});Object.defineProperty(exports,"oklchToLinearInto",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.f}});Object.defineProperty(exports,"oklchToRgbChannels",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.g}});Object.defineProperty(exports,"oklchToRgbChannelsInto",{enumerable:true,get:function(){return chunkLTRVT3GL_cjs.h}});exports.Colordx=u;exports.colordx=xr;exports.extend=Or;exports.getFormat=fr;exports.nearest=Rr;exports.random=yr;exports.toHex8=_r;//# sourceMappingURL=index.cjs.map | ||
| //# sourceMappingURL=index.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","a","lr","lg","lb","oklabToLinear","srgbFromLinear","ri","gi","bi","rgbToHex","precision","hr","value","amount","options","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrgbRaw","colordx","extend","plugins","plugin","nearest","candidates","l1","a1","b1","minDist","candidate","l2","a2","b2","dist","random"],"mappings":"iWAeO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,mBAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,KAAA,CAAOE,mBAAAA,CAAMC,mBAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,EAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAE1CC,CAAAA,CAAc,CAAC,CAAE,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,GAA0B,CACrE,IAAMC,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,C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A,CAAevD,CAAAA,EAA6B,CAClD,IAAMmF,CAAAA,CAASC,mBAAAA,CAAepF,CAAK,CAAA,CACnC,OAAOmF,CAAAA,GAAW,IAAA,CAAO5B,CAAAA,CAAQ,cAAA,CAAe4B,CAAM,CAAA,CAAI,IAAI5B,CAAAA,CAAQvD,CAAK,CAC7E,CAAA","file":"index.cjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, oklabToLinear, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.\n * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,\n * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.\n * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n */\n static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return Colordx._make({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n toRgbString(): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, 4), a: round(a, 4), b: round(b, 4), alpha };\n }\n\n toOklabString(): string {\n const { l, a, b, alpha } = this.toOklab();\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, 4), c: round(c, 4), h: round(h, 2), alpha };\n }\n\n toOklchString(): string {\n const { l, c, h, alpha } = this.toOklch();\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n return mapped !== null ? Colordx._makeFromOklab(mapped) : this;\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n return mapped !== null ? Colordx._makeFromOklab(mapped) : new Colordx(input);\n};\n"]} | ||
| {"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","a","lr","lg","lb","oklabToLinear","srgbFromLinear","ri","gi","bi","rgbToHex","rgbToHex8","precision","hr","value","amount","options","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrgbRaw","colordx","toHex8","extend","plugins","plugin","nearest","candidates","l1","a1","b1","minDist","candidate","l2","a2","b2","dist","random"],"mappings":"iWAeO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,mBAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,CAAA,CACtB,KAAA,CAAOE,mBAAAA,CAAMC,mBAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,EAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAE1CC,CAAAA,CAA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MAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,KAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,KAAA,CAAO,CACT,CAAC,EAEHA,EAAQ,WAAA,CAAevD,CAAAA,EAA6B,CAClD,IAAMoF,CAAAA,CAASC,mBAAAA,CAAerF,CAAK,CAAA,CACnC,OAAOoF,CAAAA,GAAW,IAAA,CAAO7B,CAAAA,CAAQ,cAAA,CAAe6B,CAAM,CAAA,CAAI,IAAI7B,CAAAA,CAAQvD,CAAK,CAC7E,CAAA","file":"index.cjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex, rgbToHex8 } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, oklabToLinear, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.\n * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,\n * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.\n * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n */\n static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return Colordx._make({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n toRgbString(): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */\n toHex8(): string {\n return rgbToHex8(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, 4), a: round(a, 4), b: round(b, 4), alpha };\n }\n\n toOklabString(): string {\n const { l, a, b, alpha } = this.toOklab();\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, 4), c: round(c, 4), h: round(h, 2), alpha };\n }\n\n toOklchString(): string {\n const { l, c, h, alpha } = this.toOklch();\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n return mapped !== null ? Colordx._makeFromOklab(mapped) : this;\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\n/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */\nexport const toHex8 = (input: AnyColor | Colordx): string => new Colordx(input).toHex8();\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n return mapped !== null ? Colordx._makeFromOklab(mapped) : new Colordx(input);\n};\n"]} |
+6
-3
@@ -1,4 +0,7 @@ | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-CkpAhqrJ.cjs'; | ||
| export { a as CmykColor, b as ColorParser, c as Colordx, H as HslColor, d as HsvColor, e as HwbColor, L as LabColor, f as LchColor, O as OklabColor, g as OklchColor, P as P3Color, h as Plugin, R as Rec2020Color, i as RgbColor, X as XyzColor, j as colordx, k as extend, n as nearest, r as random } from './colordx-CkpAhqrJ.cjs'; | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-DsvQlWlv.cjs'; | ||
| export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-DsvQlWlv.cjs'; | ||
| /** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */ | ||
| declare const toHexByte: (n: number) => string; | ||
| declare const getFormat: (input: AnyColor) => ColorFormat | undefined; | ||
@@ -50,2 +53,2 @@ | ||
| export { AnyColor, ColorFormat, getFormat, inGamutSrgb, oklchToLinear, oklchToLinearAndSrgb, oklchToLinearAndSrgbInto, oklchToLinearInto, oklchToRgbChannels, oklchToRgbChannelsInto }; | ||
| export { AnyColor, ColorFormat, getFormat, inGamutSrgb, oklchToLinear, oklchToLinearAndSrgb, oklchToLinearAndSrgbInto, oklchToLinearInto, oklchToRgbChannels, oklchToRgbChannelsInto, toHexByte }; |
+6
-3
@@ -1,4 +0,7 @@ | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-CkpAhqrJ.js'; | ||
| export { a as CmykColor, b as ColorParser, c as Colordx, H as HslColor, d as HsvColor, e as HwbColor, L as LabColor, f as LchColor, O as OklabColor, g as OklchColor, P as P3Color, h as Plugin, R as Rec2020Color, i as RgbColor, X as XyzColor, j as colordx, k as extend, n as nearest, r as random } from './colordx-CkpAhqrJ.js'; | ||
| import { A as AnyColor, C as ColorFormat } from './colordx-DsvQlWlv.js'; | ||
| export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-DsvQlWlv.js'; | ||
| /** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */ | ||
| declare const toHexByte: (n: number) => string; | ||
| declare const getFormat: (input: AnyColor) => ColorFormat | undefined; | ||
@@ -50,2 +53,2 @@ | ||
| export { AnyColor, ColorFormat, getFormat, inGamutSrgb, oklchToLinear, oklchToLinearAndSrgb, oklchToLinearAndSrgbInto, oklchToLinearInto, oklchToRgbChannels, oklchToRgbChannelsInto }; | ||
| export { AnyColor, ColorFormat, getFormat, inGamutSrgb, oklchToLinear, oklchToLinearAndSrgb, oklchToLinearAndSrgbInto, oklchToLinearInto, oklchToRgbChannels, oklchToRgbChannelsInto, toHexByte }; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import {a,b as b$3}from'./chunk-4JCO6H3F.mjs';import {b as b$5}from'./chunk-2HOOMNKQ.mjs';export{a as inGamutSrgb,e as oklchToLinear,i as oklchToLinearAndSrgb,j as oklchToLinearAndSrgbInto,f as oklchToLinearInto,g as oklchToRgbChannels,h as oklchToRgbChannelsInto}from'./chunk-2HOOMNKQ.mjs';import {h,g as g$1,c as c$2,f as f$1,b as b$4,a as a$2,d as d$1}from'./chunk-J6CH5YTL.mjs';import'./chunk-OXYX6VNO.mjs';import {b as b$2,a as a$3}from'./chunk-FXCFKFXK.mjs';import {c,b}from'./chunk-Q3O3QQ4H.mjs';import {l,d,a as a$1,c as c$1,h as h$1,i,f,g as g$2,k as k$1,j,b as b$1}from'./chunk-IOXRZECH.mjs';var V=l=>({h:c$1(l.h),s:a$1(l.s,0,100),l:a$1(l.l,0,100),alpha:a$1(b$1(l.alpha,3),0,1)}),O={h:0,s:0,l:0,alpha:0},R=({r:l,g:r,b:o,alpha:t})=>{let n=l/255,e=r/255,s=o/255,a=Math.max(n,e,s),b=Math.min(n,e,s),C=(a+b)/2,d=0,x=0;if(a!==b){let _=a-b;switch(x=C>.5?_/(2-a-b):_/(a+b),a){case n:d=((e-s)/_+(e<s?6:0))/6;break;case e:d=((s-n)/_+2)/6;break;case s:d=((n-e)/_+4)/6;break}}let y=d*360;return O.h=y>=0&&y<360?y:(y%360+360)%360,O.s=a$1(x*100,0,100),O.l=a$1(C*100,0,100),O.alpha=a$1(b$1(t,3),0,1),O};var N=(l,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?l+(r-l)*6*o:o<1/2?r:o<2/3?l+(r-l)*(2/3-o)*6:l),k=({h:l,s:r,l:o,alpha:t})=>{let n=r/100,e=o/100,s=e<.5?e*(1+n):e+n-e*n,a=2*e-s,b=(l%360+360)%360/360;return {r:N(a,s,b+1/3)*255,g:N(a,s,b)*255,b:N(a,s,b-1/3)*255,alpha:t}},X=l=>{if(!h$1(l)||!i(l,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:n=1}=l;return !f(r)||!f(o)||!f(t)||!f(n)?null:k(V({h:g$2(r),s:g$2(o),l:g$2(t),alpha:g$2(n)}))},mr=new RegExp(`^hsla?\\(\\s*(?<h>${k$1})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j})%\\s*,\\s*(?<l_c>${j})%(?:\\s*,\\s*(?<al_c>${j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k$1})(?<sp_s>%?)\\s+(?<l_s>${k$1})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${k$1})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=l$1=>{if(typeof l$1!="string")return null;let r=mr.exec(l$1.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",n=l(r.h)*(d[t]??1),e=l(r.s_c??r.s_s),s=l(r.l_c??r.l_s),a=r.al_c??r.al_s,b=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let C=a===void 0?1:l(a)/(b?100:1);return k(V({h:n,s:e,l:s,alpha:C}))};var Q=({l,c:r,h:o,alpha:t})=>({l,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=l=>{let{l:r,a:o,b:t,alpha:n}=b$4(l),e=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:e,h:e<4e-6?0:c$1(s),alpha:n}},A=l=>d$1(Q(l)),Y=l=>c$2(Q(l)),Z=l=>{if(!h$1(l)||l.colorSpace==="lch"||!i(l,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:n=1}=l;return !f(r)||!f(o)||!f(t)||!f(n)||g$2(r)>1?null:Y({l:g$2(r),c:Math.max(0,g$2(o)),h:c$1(g$2(t)),alpha:a$1(g$2(n),0,1)})},Cr=new RegExp(`^oklch\\(\\s*(?<l>${k$1})(?<lp>%?)\\s+(?<c>${k$1})(?<cp>%?)\\s+(?<h>${k$1})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),rr=l$1=>{if(typeof l$1!="string")return null;let r=Cr.exec(l$1.trim())?.groups;if(!r)return null;let o=r.lp?l(r.l)/100:l(r.l),t=Math.max(0,r.cp?l(r.c)*.004:l(r.c)),n=r.hu?.toLowerCase()??"deg",e=l(r.h)*(d[n]??1),s=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:c$1(e),alpha:a$1(s,0,1)})};var or=[[a,"hex"],[c,"rgb"],[J,"hsl"],[rr,"oklch"],[h,"oklab"]],tr=[[b,"rgb"],[X,"hsl"],[g$1,"oklab"],[Z,"oklch"]],lr=or.map(([l])=>l),nr=tr.map(([l])=>l),er=[...lr,...nr],L=[...er],F=[],sr=l=>{if(l==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof l=="string"?lr:nr;for(let o of r){let t=o(l);if(t)return t}for(let o=er.length;o<L.length;o++){let t=L[o](l);if(t)return t}return null},dr=l=>{if(l==="transparent")return "name";let r=typeof l=="string"?or:tr;for(let[o,t]of r)if(o(l))return t;for(let[o,t]of F)if(o(l))return t};var ar=Symbol(),g=class l{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof l){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=a$1(b$1(this._rgb.alpha,3),0,1);}static _make(r){return new l(ar,r)}static _makeFromOklab({l:r,a:o,b:t,alpha:n}){let[e,s,a]=f$1(r,o,t);return l._make({r:b$2(e)*255,g:b$2(s)*255,b:b$2(a)*255,alpha:n})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return {r:a$1(b$1(r),0,255),g:a$1(b$1(o),0,255),b:a$1(b$1(t),0,255),alpha:n}}_rawRgb(){return this._rgb}toRgbString(){let{r,g:o,b:t,alpha:n}=this._rgb,e=a$1(b$1(r),0,255),s=a$1(b$1(o),0,255),a=a$1(b$1(t),0,255);return n<1?`rgb(${e} ${s} ${a} / ${n})`:`rgb(${e} ${s} ${a})`}toHex(){return b$3(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return a$1(b$1(r),0,255)<<16|a$1(b$1(o),0,255)<<8|a$1(b$1(t),0,255)}toHsl(r=2){let{h:o,s:t,l:n,alpha:e}=R(this._rgb),s=b$1(o,r);return {h:s>=360?0:s,s:b$1(t,r),l:b$1(n,r),alpha:e}}toHslString(r=2){let{h:o,s:t,l:n,alpha:e}=this.toHsl(r);return e<1?`hsl(${o} ${t}% ${n}% / ${e})`:`hsl(${o} ${t}% ${n}%)`}toOklab(){let{l:r,a:o,b:t,alpha:n}=b$4(this._rgb);return {l:b$1(r,4),a:b$1(o,4),b:b$1(t,4),alpha:n}}toOklabString(){let{l:r,a:o,b:t,alpha:n}=this.toOklab();return n<1?`oklab(${r} ${o} ${t} / ${n})`:`oklab(${r} ${o} ${t})`}toOklch(){let{l:r,c:o,h:t,alpha:n}=W(this._rgb);return {l:b$1(r,4),c:b$1(o,4),h:b$1(t,2),alpha:n}}toOklchString(){let{l:r,c:o,h:t,alpha:n}=this.toOklch(),e=o===0?"none":t;return n<1?`oklch(${r} ${o} ${e} / ${n})`:`oklch(${r} ${o} ${e})`}brightness(){let{r,g:o,b:t}=this._rgb;return b$1((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:l._make({...this._rgb,alpha:b$1(a$1(r,0,1),3)})}hue(r){let{h:o,s:t,l:n,alpha:e}=R(this._rgb);if(r===void 0){let s=b$1(o,2);return s>=360?0:s}return l._make(k({h:r,s:t,l:n,alpha:e}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:l._make(A({...o,l:a$1(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:l._make(A({...o,c:a$1(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?e*(1+r):e+r*100;return l._make(k({h:t,s:n,l:a$1(a,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?n*(1+r):n+r*100;return l._make(k({h:t,s:a$1(a,0,100),l:e,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:n}=this._rgb;return l._make({r:255-r,g:255-o,b:255-t,alpha:n})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new l(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:l._make({r:a$1(r,0,255),g:a$1(o,0,255),b:a$1(t,0,255),alpha:n})}mapSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[e,s,a]=a$2(a$3(r/255),a$3(o/255),a$3(t/255)),b=e>1-1e-7?1:e<1e-7?0:e,C=b$5({l:b,a:s,b:a,alpha:n});return C!==null?l._makeFromOklab(C):this}static toGamutSrgb},fr=l=>new g(l),kr=l=>{l.forEach(r=>r(g,L,F));},xr=(l,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:n}=new g(l).toOklab(),e=1/0,s=r[0];for(let a of r){let{l:b,a:C,b:d}=new g(a).toOklab(),x=(b-o)**2+(C-t)**2+(d-n)**2;x<e&&(e=x,s=a);}return s},_r=()=>new g({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});g.toGamutSrgb=l=>{let r=b$5(l);return r!==null?g._makeFromOklab(r):new g(l)};export{g as Colordx,fr as colordx,kr as extend,dr as getFormat,xr as nearest,_r as random};//# sourceMappingURL=index.mjs.map | ||
| import {b,c as c$3,d as d$1}from'./chunk-RJNXPIQM.mjs';export{a as toHexByte}from'./chunk-RJNXPIQM.mjs';import {b as b$5}from'./chunk-2HOOMNKQ.mjs';export{a as inGamutSrgb,e as oklchToLinear,i as oklchToLinearAndSrgb,j as oklchToLinearAndSrgbInto,f as oklchToLinearInto,g as oklchToRgbChannels,h as oklchToRgbChannelsInto}from'./chunk-2HOOMNKQ.mjs';import {h,g,c as c$2,f as f$2,b as b$4,a as a$1,d as d$2}from'./chunk-J6CH5YTL.mjs';import'./chunk-OXYX6VNO.mjs';import {b as b$3,a as a$2}from'./chunk-FXCFKFXK.mjs';import {c,b as b$1}from'./chunk-Q3O3QQ4H.mjs';import {l,d,a,c as c$1,h as h$1,i,f as f$1,g as g$1,k,j,b as b$2}from'./chunk-IOXRZECH.mjs';var V=l=>({h:c$1(l.h),s:a(l.s,0,100),l:a(l.l,0,100),alpha:a(b$2(l.alpha,3),0,1)}),O={h:0,s:0,l:0,alpha:0},R=({r:l,g:r,b:o,alpha:t})=>{let n=l/255,e=r/255,s=o/255,a$1=Math.max(n,e,s),b=Math.min(n,e,s),C=(a$1+b)/2,k=0,x=0;if(a$1!==b){let _=a$1-b;switch(x=C>.5?_/(2-a$1-b):_/(a$1+b),a$1){case n:k=((e-s)/_+(e<s?6:0))/6;break;case e:k=((s-n)/_+2)/6;break;case s:k=((n-e)/_+4)/6;break}}let y=k*360;return O.h=y>=0&&y<360?y:(y%360+360)%360,O.s=a(x*100,0,100),O.l=a(C*100,0,100),O.alpha=a(b$2(t,3),0,1),O};var A=(l,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?l+(r-l)*6*o:o<1/2?r:o<2/3?l+(r-l)*(2/3-o)*6:l),f=({h:l,s:r,l:o,alpha:t})=>{let n=r/100,e=o/100,s=e<.5?e*(1+n):e+n-e*n,a=2*e-s,b=(l%360+360)%360/360;return {r:A(a,s,b+1/3)*255,g:A(a,s,b)*255,b:A(a,s,b-1/3)*255,alpha:t}},J=l=>{if(!h$1(l)||!i(l,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:n=1}=l;return !f$1(r)||!f$1(o)||!f$1(t)||!f$1(n)?null:f(V({h:g$1(r),s:g$1(o),l:g$1(t),alpha:g$1(n)}))},kr=new RegExp(`^hsla?\\(\\s*(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j})%\\s*,\\s*(?<l_c>${j})%(?:\\s*,\\s*(?<al_c>${j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k})(?<sp_s>%?)\\s+(?<l_s>${k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),Q=l$1=>{if(typeof l$1!="string")return null;let r=kr.exec(l$1.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",n=l(r.h)*(d[t]??1),e=l(r.s_c??r.s_s),s=l(r.l_c??r.l_s),a=r.al_c??r.al_s,b=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let C=a===void 0?1:l(a)/(b?100:1);return f(V({h:n,s:e,l:s,alpha:C}))};var W=({l,c:r,h:o,alpha:t})=>({l,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),Y=l=>{let{l:r,a:o,b:t,alpha:n}=b$4(l),e=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:e,h:e<4e-6?0:c$1(s),alpha:n}},M=l=>d$2(W(l)),Z=l=>c$2(W(l)),rr=l=>{if(!h$1(l)||l.colorSpace==="lch"||!i(l,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:n=1}=l;return !f$1(r)||!f$1(o)||!f$1(t)||!f$1(n)||g$1(r)>1?null:Z({l:g$1(r),c:Math.max(0,g$1(o)),h:c$1(g$1(t)),alpha:a(g$1(n),0,1)})},dr=new RegExp(`^oklch\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<c>${k})(?<cp>%?)\\s+(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),or=l$1=>{if(typeof l$1!="string")return null;let r=dr.exec(l$1.trim())?.groups;if(!r)return null;let o=r.lp?l(r.l)/100:l(r.l),t=Math.max(0,r.cp?l(r.c)*.004:l(r.c)),n=r.hu?.toLowerCase()??"deg",e=l(r.h)*(d[n]??1),s=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Z({l:o,c:t,h:c$1(e),alpha:a(s,0,1)})};var tr=[[b,"hex"],[c,"rgb"],[Q,"hsl"],[or,"oklch"],[h,"oklab"]],lr=[[b$1,"rgb"],[J,"hsl"],[g,"oklab"],[rr,"oklch"]],nr=tr.map(([l])=>l),er=lr.map(([l])=>l),sr=[...nr,...er],L=[...sr],N=[],ar=l=>{if(l==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof l=="string"?nr:er;for(let o of r){let t=o(l);if(t)return t}for(let o=sr.length;o<L.length;o++){let t=L[o](l);if(t)return t}return null},fr=l=>{if(l==="transparent")return "name";let r=typeof l=="string"?tr:lr;for(let[o,t]of r)if(o(l))return t;for(let[o,t]of N)if(o(l))return t};var hr=Symbol(),u=class l{_rgb;_valid;constructor(r,o){if(r===hr)this._valid=true,this._rgb=o;else if(r instanceof l){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=ar(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=a(b$2(this._rgb.alpha,3),0,1);}static _make(r){return new l(hr,r)}static _makeFromOklab({l:r,a:o,b:t,alpha:n}){let[e,s,a]=f$2(r,o,t);return l._make({r:b$3(e)*255,g:b$3(s)*255,b:b$3(a)*255,alpha:n})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return {r:a(b$2(r),0,255),g:a(b$2(o),0,255),b:a(b$2(t),0,255),alpha:n}}_rawRgb(){return this._rgb}toRgbString(){let{r,g:o,b:t,alpha:n}=this._rgb,e=a(b$2(r),0,255),s=a(b$2(o),0,255),a$1=a(b$2(t),0,255);return n<1?`rgb(${e} ${s} ${a$1} / ${n})`:`rgb(${e} ${s} ${a$1})`}toHex(){return c$3(this._rgb)}toHex8(){return d$1(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return a(b$2(r),0,255)<<16|a(b$2(o),0,255)<<8|a(b$2(t),0,255)}toHsl(r=2){let{h:o,s:t,l:n,alpha:e}=R(this._rgb),s=b$2(o,r);return {h:s>=360?0:s,s:b$2(t,r),l:b$2(n,r),alpha:e}}toHslString(r=2){let{h:o,s:t,l:n,alpha:e}=this.toHsl(r);return e<1?`hsl(${o} ${t}% ${n}% / ${e})`:`hsl(${o} ${t}% ${n}%)`}toOklab(){let{l:r,a:o,b:t,alpha:n}=b$4(this._rgb);return {l:b$2(r,4),a:b$2(o,4),b:b$2(t,4),alpha:n}}toOklabString(){let{l:r,a:o,b:t,alpha:n}=this.toOklab();return n<1?`oklab(${r} ${o} ${t} / ${n})`:`oklab(${r} ${o} ${t})`}toOklch(){let{l:r,c:o,h:t,alpha:n}=Y(this._rgb);return {l:b$2(r,4),c:b$2(o,4),h:b$2(t,2),alpha:n}}toOklchString(){let{l:r,c:o,h:t,alpha:n}=this.toOklch(),e=o===0?"none":t;return n<1?`oklch(${r} ${o} ${e} / ${n})`:`oklch(${r} ${o} ${e})`}brightness(){let{r,g:o,b:t}=this._rgb;return b$2((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:l._make({...this._rgb,alpha:b$2(a(r,0,1),3)})}hue(r){let{h:o,s:t,l:n,alpha:e}=R(this._rgb);if(r===void 0){let s=b$2(o,2);return s>=360?0:s}return l._make(f({h:r,s:t,l:n,alpha:e}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:l._make(M({...o,l:a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:l._make(M({...o,c:a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a$1=o?.relative?e*(1+r):e+r*100;return l._make(f({h:t,s:n,l:a(a$1,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a$1=o?.relative?n*(1+r):n+r*100;return l._make(f({h:t,s:a(a$1,0,100),l:e,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:n}=this._rgb;return l._make({r:255-r,g:255-o,b:255-t,alpha:n})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new l(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:l._make({r:a(r,0,255),g:a(o,0,255),b:a(t,0,255),alpha:n})}mapSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[e,s,a]=a$1(a$2(r/255),a$2(o/255),a$2(t/255)),b=e>1-1e-7?1:e<1e-7?0:e,C=b$5({l:b,a:s,b:a,alpha:n});return C!==null?l._makeFromOklab(C):this}static toGamutSrgb},xr=l=>new u(l),_r=l=>new u(l).toHex8(),Or=l=>{l.forEach(r=>r(u,L,N));},Rr=(l,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:n}=new u(l).toOklab(),e=1/0,s=r[0];for(let a of r){let{l:b,a:C,b:k}=new u(a).toOklab(),x=(b-o)**2+(C-t)**2+(k-n)**2;x<e&&(e=x,s=a);}return s},yr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=l=>{let r=b$5(l);return r!==null?u._makeFromOklab(r):new u(l)};export{u as Colordx,xr as colordx,Or as extend,fr as getFormat,Rr as nearest,yr as random,_r as toHex8};//# sourceMappingURL=index.mjs.map | ||
| //# sourceMappingURL=index.mjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","a","lr","lg","lb","oklabToLinear","srgbFromLinear","ri","gi","bi","rgbToHex","precision","hr","value","amount","options","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrgbRaw","colordx","extend","plugins","plugin","nearest","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AAE,OAAA,EAAQ,CACzDI,CAAAA,CAAAA,CAAQH,CAAAA,CAAKL,IAAO,CAAA,CAAA,CAAKM,CAAAA,CAAKL,CAAAA,GAAO,CAAA,CAAA,CAAKM,CAAAA,CAAKL,CAAAA,GAAO,CAAA,CACxDM,CAAAA,CAAOL,CAAAA,GACTA,CAAAA,CAAUK,CAAAA,CACVlD,CAAAA,CAAS8C,CAAAA,EAEb,CACA,OAAO9C,CACT,EAEamD,EAAAA,CAAS,IACpB,IAAI7C,CAAAA,CAAQ,CACV,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,KAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,KAAA,CAAO,CACT,CAAC,EAEHA,EAAQ,WAAA,CAAevD,CAAAA,EAA6B,CAClD,IAAMmF,CAAAA,CAASC,GAAAA,CAAepF,CAAK,CAAA,CACnC,OAAOmF,CAAAA,GAAW,IAAA,CAAO5B,CAAAA,CAAQ,cAAA,CAAe4B,CAAM,CAAA,CAAI,IAAI5B,CAAAA,CAAQvD,CAAK,CAC7E,CAAA","file":"index.mjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, oklabToLinear, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.\n * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,\n * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.\n * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n */\n static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return Colordx._make({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n toRgbString(): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, 4), a: round(a, 4), b: round(b, 4), alpha };\n }\n\n toOklabString(): string {\n const { l, a, b, alpha } = this.toOklab();\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, 4), c: round(c, 4), h: round(h, 2), alpha };\n }\n\n toOklchString(): string {\n const { l, c, h, alpha } = this.toOklch();\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n return mapped !== null ? Colordx._makeFromOklab(mapped) : this;\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n return mapped !== null ? Colordx._makeFromOklab(mapped) : new Colordx(input);\n};\n"]} | ||
| {"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","a","lr","lg","lb","oklabToLinear","srgbFromLinear","ri","gi","bi","rgbToHex","rgbToHex8","precision","hr","value","amount","options","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrg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AAGM,CAAAA,CAAI,CAAA,CAAGC,CAAAA,CAAI,CAAA,CAAGC,CAAG,CAAA,CAAI,IAAI7C,CAAAA,CAAQ0C,CAAS,CAAA,CAAE,OAAA,EAAQ,CACzDI,CAAAA,CAAAA,CAAQH,EAAKL,CAAAA,GAAO,CAAA,CAAA,CAAKM,CAAAA,CAAKL,CAAAA,GAAO,CAAA,CAAA,CAAKM,CAAAA,CAAKL,CAAAA,GAAO,CAAA,CACxDM,CAAAA,CAAOL,CAAAA,GACTA,CAAAA,CAAUK,CAAAA,CACVpD,CAAAA,CAASgD,CAAAA,EAEb,CACA,OAAOhD,CACT,CAAA,CAEaqD,EAAAA,CAAS,IACpB,IAAI/C,CAAAA,CAAQ,CACV,CAAA,CAAG,IAAA,CAAK,MAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,KAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,KAAA,CAAO,CACT,CAAC,EAEHA,EAAQ,WAAA,CAAevD,CAAAA,EAA6B,CAClD,IAAMoF,CAAAA,CAASC,GAAAA,CAAerF,CAAK,CAAA,CACnC,OAAOoF,CAAAA,GAAW,IAAA,CAAO7B,CAAAA,CAAQ,cAAA,CAAe6B,CAAM,CAAA,CAAI,IAAI7B,CAAAA,CAAQvD,CAAK,CAC7E,CAAA","file":"index.mjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex, rgbToHex8 } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, oklabToLinear, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.\n * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,\n * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.\n * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n */\n static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return Colordx._make({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n toRgbString(): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */\n toHex8(): string {\n return rgbToHex8(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, 4), a: round(a, 4), b: round(b, 4), alpha };\n }\n\n toOklabString(): string {\n const { l, a, b, alpha } = this.toOklab();\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, 4), c: round(c, 4), h: round(h, 2), alpha };\n }\n\n toOklchString(): string {\n const { l, c, h, alpha } = this.toOklch();\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n return mapped !== null ? Colordx._makeFromOklab(mapped) : this;\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\n/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */\nexport const toHex8 = (input: AnyColor | Colordx): string => new Colordx(input).toHex8();\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n return mapped !== null ? Colordx._makeFromOklab(mapped) : new Colordx(input);\n};\n"]} |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { a as CmykColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { a as CmykColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { a as CmykColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { a as CmykColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ type HarmonyType = 'complementary' | 'analogous' | 'triadic' | 'tetradic' | 'split-complementary' | 'double-split-complementary' | 'rectangle'; |
@@ -1,2 +0,2 @@ | ||
| import { h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ type HarmonyType = 'complementary' | 'analogous' | 'triadic' | 'tetradic' | 'split-complementary' | 'double-split-complementary' | 'rectangle'; |
@@ -1,2 +0,2 @@ | ||
| import { d as HsvColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { f as HsvColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { d as HsvColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { f as HsvColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { e as HwbColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { h as HwbColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { e as HwbColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { h as HwbColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { L as LabColor, X as XyzColor, A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { L as LabColor, X as XyzColor, A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { L as LabColor, X as XyzColor, A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { L as LabColor, X as XyzColor, A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { f as LchColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { k as LchColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { f as LchColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { k as LchColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ interface MinifyOptions { |
@@ -1,2 +0,2 @@ | ||
| import { h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ interface MinifyOptions { |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| 'use strict';var chunkZ5MM7DU5_cjs=require('../chunk-Z5MM7DU5.cjs');require('../chunk-YISEJCI6.cjs');var e={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},u=f=>{if(typeof f!="string")return null;let a=e[f.toLowerCase().trim()];return a?chunkZ5MM7DU5_cjs.a(a):null},k=(f,a,g)=>{a.push(u),g.push([u,"name"]),f.prototype.toName=function(m){let{r:l,g:n,b:t,alpha:h}=this.toRgb();if(h===0&&l===0&&n===0&&t===0)return "transparent";let p=this.toHex().toLowerCase(),i=Object.keys(e).find(r=>e[r]===p);if(i||!m?.closest)return i;let c=1/0,b;for(let r of Object.keys(e)){let d=chunkZ5MM7DU5_cjs.a(e[r]),s=(d.r-l)**2+(d.g-n)**2+(d.b-t)**2;s<c&&(c=s,b=r);}return b};},w=k;module.exports=w;//# sourceMappingURL=names.cjs.map | ||
| 'use strict';var chunkUAXI5JGL_cjs=require('../chunk-UAXI5JGL.cjs');require('../chunk-YISEJCI6.cjs');var e={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},u=f=>{if(typeof f!="string")return null;let a=e[f.toLowerCase().trim()];return a?chunkUAXI5JGL_cjs.b(a):null},k=(f,a,g)=>{a.push(u),g.push([u,"name"]),f.prototype.toName=function(m){let{r:l,g:n,b:t,alpha:h}=this.toRgb();if(h===0&&l===0&&n===0&&t===0)return "transparent";let p=this.toHex().toLowerCase(),i=Object.keys(e).find(r=>e[r]===p);if(i||!m?.closest)return i;let c=1/0,b;for(let r of Object.keys(e)){let d=chunkUAXI5JGL_cjs.b(e[r]),s=(d.r-l)**2+(d.g-n)**2+(d.b-t)**2;s<c&&(c=s,b=r);}return b};},w=k;module.exports=w;//# sourceMappingURL=names.cjs.map | ||
| //# sourceMappingURL=names.cjs.map |
@@ -1,2 +0,2 @@ | ||
| import { h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import {a}from'../chunk-4JCO6H3F.mjs';import'../chunk-IOXRZECH.mjs';var e={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},u=f=>{if(typeof f!="string")return null;let a$1=e[f.toLowerCase().trim()];return a$1?a(a$1):null},k=(f,a$1,g)=>{a$1.push(u),g.push([u,"name"]),f.prototype.toName=function(m){let{r:l,g:n,b:t,alpha:h}=this.toRgb();if(h===0&&l===0&&n===0&&t===0)return "transparent";let p=this.toHex().toLowerCase(),i=Object.keys(e).find(r=>e[r]===p);if(i||!m?.closest)return i;let c=1/0,b;for(let r of Object.keys(e)){let d=a(e[r]),s=(d.r-l)**2+(d.g-n)**2+(d.b-t)**2;s<c&&(c=s,b=r);}return b};},w=k;export{w as default};//# sourceMappingURL=names.mjs.map | ||
| import {b}from'../chunk-RJNXPIQM.mjs';import'../chunk-IOXRZECH.mjs';var e={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},u=f=>{if(typeof f!="string")return null;let a=e[f.toLowerCase().trim()];return a?b(a):null},k=(f,a,g)=>{a.push(u),g.push([u,"name"]),f.prototype.toName=function(m){let{r:l,g:n,b:t,alpha:h}=this.toRgb();if(h===0&&l===0&&n===0&&t===0)return "transparent";let p=this.toHex().toLowerCase(),i=Object.keys(e).find(r=>e[r]===p);if(i||!m?.closest)return i;let c=1/0,b$1;for(let r of Object.keys(e)){let d=b(e[r]),s=(d.r-l)**2+(d.g-n)**2+(d.b-t)**2;s<c&&(c=s,b$1=r);}return b$1};},w=k;export{w as default};//# sourceMappingURL=names.mjs.map | ||
| //# sourceMappingURL=names.mjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../../src/plugins/names.ts"],"names":["NAMES","parseNameString","input","hex","parseHex","names","ColordxClass","parsers","formatParsers","options","r","g","b","alpha","exact","name","minDist","closest","c","d","names_default"],"mappings":"oEAWA,IAAMA,CAAAA,CAAgC,CACpC,SAAA,CAAW,SAAA,CACX,aAAc,SAAA,CACd,IAAA,CAAM,SAAA,CACN,UAAA,CAAY,SAAA,CACZ,KAAA,CAAO,UACP,KAAA,CAAO,SAAA,CACP,OAAQ,SAAA,CACR,KAAA,CAAO,UACP,cAAA,CAAgB,SAAA,CAChB,IAAA,CAAM,SAAA,CACN,UAAA,CAAY,SAAA,CACZ,MAAO,SAAA,CACP,SAAA,CAAW,UACX,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,SAAA,CAAW,SAAA,CACX,KAAA,CAAO,SAAA,CACP,cAAA,CAAgB,UAChB,QAAA,CAAU,SAAA,CACV,OAAA,CAAS,SAAA,CACT,IAAA,CAAM,SAAA,CACN,SAAU,SAAA,CACV,QAAA,CAAU,SAAA,CACV,aAAA,CAAe,SAAA,CACf,QAAA,CAAU,UACV,SAAA,CAAW,SAAA,CACX,UAAW,SAAA,CACX,WAAA,CAAa,UACb,cAAA,CAAgB,SAAA,CAChB,UAAA,CAAY,SAAA,CACZ,UAAA,CAAY,SAAA,CACZ,QAAS,SAAA,CACT,UAAA,CAAY,SAAA,CACZ,YAAA,CAAc,SAAA,CACd,aAAA,CAAe,UACf,aAAA,CAAe,SAAA,CACf,aAAA,CAAe,SAAA,CACf,UAAA,CAAY,SAAA,CACZ,SAAU,SAAA,CACV,WAAA,CAAa,UACb,OAAA,CAAS,SAAA,CACT,WAAY,SAAA,CACZ,SAAA,CAAW,SAAA,CACX,WAAA,CAAa,SAAA,CACb,WAAA,CAAa,UACb,OAAA,CAAS,SAAA,CACT,SAAA,CAAW,SAAA,CACX,UAAA,CAAY,SAAA,CACZ,KAAM,SAAA,CACN,SAAA,CAAW,SAAA,CACX,IAAA,CAAM,SAAA,CACN,KAAA,CAAO,UACP,WAAA,CAAa,SAAA,CACb,SAAU,SAAA,C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CAAAA,GAAU,CAAA,EAAKH,IAAM,CAAA,EAAKC,CAAAA,GAAM,GAAKC,CAAAA,GAAM,CAAA,CAAG,OAAO,aAAA,CAGzD,IAAMT,CAAAA,CAAM,KAAK,KAAA,EAAM,CAAE,WAAA,EAAY,CAE/BW,CAAAA,CAAQ,MAAA,CAAO,KAAKd,CAAK,CAAA,CAAE,IAAA,CAAMe,CAAAA,EAASf,CAAAA,CAAMe,CAAI,IAAMZ,CAAG,CAAA,CACnE,GAAIW,CAAAA,EAAS,CAACL,GAAS,OAAA,CAAS,OAAOK,CAAAA,CACvC,IAAIE,CAAAA,CAAU,CAAA,CAAA,CAAA,CACVC,EACJ,IAAA,IAAWF,CAAAA,IAAQ,MAAA,CAAO,IAAA,CAAKf,CAAK,CAAA,CAAG,CACrC,IAAMkB,CAAAA,CAAId,CAAAA,CAASJ,CAAAA,CAAMe,CAAI,CAAC,EAExBI,CAAAA,CAAAA,CAAKD,CAAAA,CAAE,EAAIR,CAAAA,GAAM,CAAA,CAAA,CAAKQ,EAAE,CAAA,CAAIP,CAAAA,GAAM,CAAA,CAAA,CAAKO,CAAAA,CAAE,CAAA,CAAIN,CAAAA,GAAM,EACrDO,CAAAA,CAAIH,CAAAA,GACNA,CAAAA,CAAUG,CAAAA,CACVF,CAAAA,CAAUF,CAAAA,EAEd,CACA,OAAOE,CACT,EACF,CAAA,CAEOG,CAAAA,CAAQf","file":"names.mjs","sourcesContent":["import { parseHex } from '../colorModels/hex.js';\nimport type { Colordx, Plugin } from '../colordx.js';\nimport type { RgbColor } from '../types.js';\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toName(options?: { closest?: boolean }): string | undefined;\n }\n}\n\n// CSS color names map (name → hex)\nconst NAMES: Record<string, string> = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32',\n};\n\nconst parseNameString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const hex = NAMES[input.toLowerCase().trim()];\n return hex ? parseHex(hex) : null;\n};\n\nconst names: Plugin = (ColordxClass, parsers, formatParsers) => {\n parsers.push(parseNameString);\n formatParsers.push([parseNameString, 'name']);\n\n ColordxClass.prototype.toName = function (this: Colordx, options?: { closest?: boolean }): string | undefined {\n const { r, g, b, alpha } = this.toRgb();\n // Strict: CSS transparent is rgba(0,0,0,0) specifically. Other fully-transparent colors return undefined.\n if (alpha === 0 && r === 0 && g === 0 && b === 0) return 'transparent';\n // toHex() returns 6-char hex for alpha=1, 8-char for alpha<1. Only 6-char can match NAMES entries,\n // so semi-transparent colors always return undefined here (closest still works via RGB distance).\n const hex = this.toHex().toLowerCase();\n // aqua/cyan and fuchsia/magenta share the same hex — insertion order means cyan/magenta are unreachable.\n const exact = Object.keys(NAMES).find((name) => NAMES[name] === hex);\n if (exact || !options?.closest) return exact;\n let minDist = Infinity;\n let closest: string | undefined;\n for (const name of Object.keys(NAMES)) {\n const c = parseHex(NAMES[name])!;\n // Alpha is intentionally excluded — all CSS named colors are opaque, so distance is RGB-only.\n const d = (c.r - r) ** 2 + (c.g - g) ** 2 + (c.b - b) ** 2;\n if (d < minDist) {\n minDist = d;\n closest = name;\n }\n }\n return closest;\n };\n};\n\nexport default names;\n"]} | ||
| {"version":3,"sources":["../../src/plugins/names.ts"],"names":["NAMES","parseNameString","input","hex","parseHex","names","ColordxClass","parsers","formatParsers","options","r","g","b","alpha","exact","name","minDist","closest","c","d","names_default"],"mappings":"oEAWA,IAAMA,CAAAA,CAAgC,CACpC,SAAA,CAAW,SAAA,CACX,aAAc,SAAA,CACd,IAAA,CAAM,SAAA,CACN,UAAA,CAAY,SAAA,CACZ,KAAA,CAAO,UACP,KAAA,CAAO,SAAA,CACP,OAAQ,SAAA,CACR,KAAA,CAAO,UACP,cAAA,CAAgB,SAAA,CAChB,IAAA,CAAM,SAAA,CACN,UAAA,CAAY,SAAA,CACZ,MAAO,SAAA,CACP,SAAA,CAAW,UACX,SAAA,CAAW,SAAA,CACX,WAAY,SAAA,CACZ,SAAA,CAAW,SAAA,CACX,KAAA,C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AA,CAAO,IAAA,CAAKf,CAAK,CAAA,CAAG,CACrC,IAAMkB,CAAAA,CAAId,CAAAA,CAASJ,CAAAA,CAAMe,CAAI,CAAC,EAExBI,CAAAA,CAAAA,CAAKD,CAAAA,CAAE,EAAIR,CAAAA,GAAM,CAAA,CAAA,CAAKQ,EAAE,CAAA,CAAIP,CAAAA,GAAM,CAAA,CAAA,CAAKO,CAAAA,CAAE,CAAA,CAAIN,CAAAA,GAAM,EACrDO,CAAAA,CAAIH,CAAAA,GACNA,CAAAA,CAAUG,CAAAA,CACVF,GAAAA,CAAUF,CAAAA,EAEd,CACA,OAAOE,GACT,EACF,CAAA,CAEOG,CAAAA,CAAQf","file":"names.mjs","sourcesContent":["import { parseHex } from '../colorModels/hex.js';\nimport type { Colordx, Plugin } from '../colordx.js';\nimport type { RgbColor } from '../types.js';\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toName(options?: { closest?: boolean }): string | undefined;\n }\n}\n\n// CSS color names map (name → hex)\nconst NAMES: Record<string, string> = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32',\n};\n\nconst parseNameString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const hex = NAMES[input.toLowerCase().trim()];\n return hex ? parseHex(hex) : null;\n};\n\nconst names: Plugin = (ColordxClass, parsers, formatParsers) => {\n parsers.push(parseNameString);\n formatParsers.push([parseNameString, 'name']);\n\n ColordxClass.prototype.toName = function (this: Colordx, options?: { closest?: boolean }): string | undefined {\n const { r, g, b, alpha } = this.toRgb();\n // Strict: CSS transparent is rgba(0,0,0,0) specifically. Other fully-transparent colors return undefined.\n if (alpha === 0 && r === 0 && g === 0 && b === 0) return 'transparent';\n // toHex() returns 6-char hex for alpha=1, 8-char for alpha<1. Only 6-char can match NAMES entries,\n // so semi-transparent colors always return undefined here (closest still works via RGB distance).\n const hex = this.toHex().toLowerCase();\n // aqua/cyan and fuchsia/magenta share the same hex — insertion order means cyan/magenta are unreachable.\n const exact = Object.keys(NAMES).find((name) => NAMES[name] === hex);\n if (exact || !options?.closest) return exact;\n let minDist = Infinity;\n let closest: string | undefined;\n for (const name of Object.keys(NAMES)) {\n const c = parseHex(NAMES[name])!;\n // Alpha is intentionally excluded — all CSS named colors are opaque, so distance is RGB-only.\n const d = (c.r - r) ** 2 + (c.g - g) ** 2 + (c.b - b) ** 2;\n if (d < minDist) {\n minDist = d;\n closest = name;\n }\n }\n return closest;\n };\n};\n\nexport default names;\n"]} |
@@ -1,2 +0,2 @@ | ||
| import { P as P3Color, A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { P as P3Color, A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { R as Rec2020Color, A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.cjs'; | ||
| import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.cjs'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
@@ -1,2 +0,2 @@ | ||
| import { R as Rec2020Color, A as AnyColor, h as Plugin } from '../colordx-CkpAhqrJ.js'; | ||
| import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-DsvQlWlv.js'; | ||
@@ -3,0 +3,0 @@ declare module '@colordx/core' { |
+4
-2
| { | ||
| "name": "@colordx/core", | ||
| "version": "5.3.2", | ||
| "version": "5.3.3", | ||
| "description": "A high-performance color library with extended support for modern color spaces including OKLCH, OKLAB, Display-P3, and more", | ||
@@ -77,2 +77,3 @@ "author": "Dmitrii Kriaklin", | ||
| "test:coverage": "vitest run --coverage", | ||
| "test:types": "tsc --noEmit -p tsconfig.tests.json", | ||
| "lint": "eslint src", | ||
@@ -86,4 +87,5 @@ "format": "prettier --write \"src/**/*.ts\"", | ||
| "release": "yarn build && publint && changeset publish", | ||
| "check": "tsc --noEmit && echo 'tsc ok' && yarn lint && yarn format", | ||
| "check": "tsc --noEmit && yarn test:types && echo 'tsc ok' && yarn lint && yarn format", | ||
| "bench": "node --expose-gc --import tsx/esm bench/index.ts", | ||
| "size": "tsx scripts/size.ts", | ||
| "prepare": "node --eval \"if (process.env.CI) process.exit(0)\" && husky || true" | ||
@@ -90,0 +92,0 @@ }, |
+40
-134
@@ -16,8 +16,4 @@ <p align="center"> | ||
| A modern color manipulation library built for the CSS Color 4 era. The successor to [colord](https://github.com/omgovich/colord) with first-class support for **OKLCH** and **OKLab**. **5 KB gzipped. More than 2× faster than colord.** | ||
| A modern color manipulation library built for the CSS Color 4 era, with first-class support for **OKLCH** and **OKLab**. **6 KB gzipped. 0 Dependencies.** | ||
| ## Why colordx? | ||
| [colord](https://github.com/omgovich/colord) is a great library, but it was designed around CSS Color 3. Modern CSS uses `oklch()` and `oklab()` — color spaces that produce better gradients, more accurate lightness adjustments, and consistent hue shifts. colord has no support for them, not even via a plugin. With colordx, they're built in. | ||
| ## Performance | ||
@@ -29,8 +25,8 @@ | ||
| |---|---|---|---|---|---|---|---| | ||
| | HEX → toHsl | **13M** | — | 5.2M | 3.4M | 2.4M | 1.7M | 1.7M | | ||
| | HEX → lighten → toHex | **9.9M** | — | 3.8M | 3.1M | 780K | 650K | 650K | | ||
| | Mix two colors | **6.3M** | 4.8M | 1.4M | 920K | 1.0M | 460K | 1.1M | | ||
| | HEX → toOklch | **5.6M** | 4.2M | — | 3.3M | 1.0M | 1.8M | — | | ||
| | inGamutP3 | **4.4M** | 3.0M | — | 960K | — | — | — | | ||
| | inGamutRec2020 | **4.1M** | 3.0M | — | 1.0M | — | — | — | | ||
| | HEX → toHsl | **24M** | — | 10M | 5.5M | 3.5M | 2.8M | 2.5M | | ||
| | HEX → lighten → toHex | **12M** | — | 5.8M | 4.8M | 1.3M | 1.0M | 1.0M | | ||
| | Mix two colors | **6.7M** | 5.2M | 1.2M | 1.0M | 1.1M | 550K | 1.1M | | ||
| | HEX → toOklch | **5.5M** | 4.5M | — | 3.3M | 1.0M | 2.0M | — | | ||
| | inGamutP3 | **4.6M** | 3.0M | — | 1.0M | — | — | — | | ||
| | inGamutRec2020 | **4.5M** | 3.2M | — | 1.1M | — | — | — | | ||
@@ -56,3 +52,3 @@ ## Install | ||
| colordx('oklch(0.5 0.2 240)').toHex(); // '#0069c7' | ||
| colordx({ r: 255, g: 0, b: 0, alpha: 1 }).toHslString(); // 'hsl(0 100% 50%)' | ||
| colordx({ r: 255, g: 0, b: 0 }).toHslString(); // 'hsl(0 100% 50%)' | ||
@@ -82,6 +78,7 @@ // Chain manipulations — each call returns a new immutable Colordx: | ||
| colordx('oklch(0.6279 0.2577 29.23)'); | ||
| colordx({ r: 255, g: 0, b: 0, alpha: 1 }); | ||
| colordx({ h: 0, s: 100, l: 50, alpha: 1 }); | ||
| colordx({ l: 0.6279, a: 0.2249, b: 0.1257, alpha: 1 }); // OKLab | ||
| colordx({ l: 0.6279, c: 0.2577, h: 29.23, alpha: 1 }); // OKLch | ||
| colordx({ r: 255, g: 0, b: 0 }); // alpha defaults to 1 | ||
| colordx({ r: 255, g: 0, b: 0, alpha: 0.5 }); | ||
| colordx({ h: 0, s: 100, l: 50 }); | ||
| colordx({ l: 0.6279, a: 0.2249, b: 0.1257 }); // OKLab | ||
| colordx({ l: 0.6279, c: 0.2577, h: 29.23 }); // OKLch | ||
| // With p3 plugin loaded: | ||
@@ -93,7 +90,17 @@ colordx('color(display-p3 0.9176 0.2003 0.1386)'); // Display-P3 string | ||
| colordx('hwb(0 0% 0%)'); | ||
| colordx({ h: 0, w: 0, b: 0, alpha: 1 }); | ||
| colordx({ h: 0, w: 0, b: 0 }); | ||
| // With hsv plugin loaded: | ||
| colordx({ h: 0, s: 100, v: 100, alpha: 1 }); // HSV | ||
| colordx({ h: 0, s: 100, v: 100 }); // HSV | ||
| ``` | ||
| TypeScript: input color objects use `*ColorInput` types (`alpha` optional, defaults to 1). | ||
| Output methods like `.toRgb()` / `.toOklch()` return `*Color` types (`alpha` always present). | ||
| ```ts | ||
| import type { RgbColor, RgbColorInput } from '@colordx/core'; | ||
| const input: RgbColorInput = { r: 255, g: 0, b: 0 }; // alpha optional | ||
| const output: RgbColor = colordx(input).toRgb(); // alpha guaranteed | ||
| ``` | ||
| ### Conversion | ||
@@ -176,4 +183,4 @@ | ||
| getFormat('oklab(0.6279 0.2249 0.1257)'); // 'oklab' | ||
| getFormat({ r: 255, g: 0, b: 0, alpha: 1 }); // 'rgb' | ||
| getFormat({ h: 0, s: 100, l: 50, alpha: 1 }); // 'hsl' | ||
| getFormat({ r: 255, g: 0, b: 0 }); // 'rgb' | ||
| getFormat({ h: 0, s: 100, l: 50 }); // 'hsl' | ||
| getFormat('notacolor'); // undefined | ||
@@ -355,3 +362,3 @@ // Plugin-added parsers register their own format: | ||
| CIE Lab (D50) and CIE XYZ (D50) color models. Lab and XYZ objects are also accepted as color input (Lab requires a `colorSpace: 'lab'` discriminant). Also adds `.mixLab()` for colord-compatible perceptual mixing, `.delta()` for CIEDE2000 color difference, and string conversion methods. | ||
| CIE Lab (D50) and CIE XYZ (D50) color models. Lab and XYZ objects are also accepted as color input (Lab requires a `colorSpace: 'lab'` discriminant). Also adds `.mixLab()` for perceptual mixing in CIE Lab, `.delta()` for CIEDE2000 color difference, and string conversion methods. | ||
@@ -371,6 +378,6 @@ ```ts | ||
| // Lab objects require colorSpace: 'lab' to distinguish from OKLab (which has the same l/a/b shape) | ||
| colordx({ l: 54.29, a: 80.8, b: 69.89, alpha: 1, colorSpace: 'lab' as const }).toHex(); // '#ff0000' | ||
| colordx({ x: 43.61, y: 22.25, z: 1.39, alpha: 1 }).toHex(); // '#ff0000' | ||
| colordx({ l: 54.29, a: 80.8, b: 69.89, colorSpace: 'lab' as const }).toHex(); // '#ff0000' | ||
| colordx({ x: 43.61, y: 22.25, z: 1.39 }).toHex(); // '#ff0000' | ||
| // Mix in CIE Lab space (colord-compatible) | ||
| // Mix in CIE Lab space | ||
| colordx('#000000').mixLab('#ffffff').toHex(); // '#777777' | ||
@@ -397,3 +404,3 @@ | ||
| // LCH objects require colorSpace: 'lch' to distinguish from OKLCH (which has the same l/c/h shape) | ||
| colordx({ l: 50, c: 50, h: 180, alpha: 1, colorSpace: 'lch' as const }).toHex(); // parses as LCH object | ||
| colordx({ l: 50, c: 50, h: 180, colorSpace: 'lch' as const }).toHex(); // parses as LCH object | ||
| ``` | ||
@@ -413,3 +420,3 @@ | ||
| colordx('device-cmyk(0% 100% 100% 0%)').toHex(); // '#ff0000' | ||
| colordx({ c: 0, m: 100, y: 100, k: 0, alpha: 1 }).toHex(); // '#ff0000' | ||
| colordx({ c: 0, m: 100, y: 100, k: 0 }).toHex(); // '#ff0000' | ||
| ``` | ||
@@ -630,96 +637,7 @@ | ||
| ## Migrating from colord | ||
| ## Notes | ||
| The API is intentionally compatible. Most code works unchanged: | ||
| ```ts | ||
| // Before | ||
| import { colord } from 'colord'; | ||
| const c = colord('#ff0000'); | ||
| // After | ||
| import { colordx } from '@colordx/core'; | ||
| const c = colordx('#ff0000'); | ||
| ``` | ||
| ### What's the same | ||
| All core manipulation and conversion methods have identical signatures: | ||
| `.toHex()`, `.toRgb()`, `.toRgbString()`, `.toHsl()`, `.toHslString()`, `.lighten()`, `.darken()`, `.saturate()`, `.desaturate()`, `.grayscale()`, `.invert()`, `.rotate()`, `.alpha()`, `.hue()`, `.brightness()`, `.isDark()`, `.isLight()`, `.isEqual()`, `getFormat()`, `random()` | ||
| The following remain **plugin-only** (same as colord): `.mix()`, `.mixOklab()`, `.luminance()`, `.contrast()`, `.toHwb()`, `.toHwbString()`. | ||
| `.lighten()`, `.darken()`, `.saturate()`, and `.desaturate()` accept an optional `{ relative: true }` flag not present in colord — see [Relative lighten/darken](#relative-lightendarken) below. | ||
| ### What changed | ||
| **HSV moved to a plugin:** | ||
| ```ts | ||
| // colord | ||
| colord('#ff0000').toHsv(); | ||
| // colordx | ||
| import hsv from '@colordx/core/plugins/hsv'; | ||
| extend([hsv]); | ||
| colordx('#ff0000').toHsv(); | ||
| ``` | ||
| **OKLCH and OKLab are now core** — no plugin needed: | ||
| ```ts | ||
| // colord (requires plugin — not available) | ||
| // colordx | ||
| colordx('#ff0000').toOklch(); | ||
| colordx('#ff0000').toOklchString(); | ||
| colordx('oklch(0.5 0.2 240)').toHex(); | ||
| ``` | ||
| **CIE Lab, LCH, XYZ, CMYK moved to plugins:** | ||
| ```ts | ||
| // colord | ||
| import { colord, extend } from 'colord'; | ||
| import labPlugin from 'colord/plugins/lab'; | ||
| import lchPlugin from 'colord/plugins/lch'; | ||
| import xyzPlugin from 'colord/plugins/xyz'; | ||
| import cmykPlugin from 'colord/plugins/cmyk'; | ||
| extend([labPlugin, lchPlugin, xyzPlugin, cmykPlugin]); | ||
| // colordx | ||
| import { colordx, extend } from '@colordx/core'; | ||
| import lab from '@colordx/core/plugins/lab'; | ||
| import lch from '@colordx/core/plugins/lch'; | ||
| import cmyk from '@colordx/core/plugins/cmyk'; | ||
| // Note: XYZ is part of the lab plugin in colordx | ||
| extend([lab, lch, cmyk]); | ||
| ``` | ||
| **`getFormat()` import path:** | ||
| ```ts | ||
| // colord | ||
| import { getFormat } from 'colord'; | ||
| // colordx | ||
| import { getFormat } from '@colordx/core'; | ||
| ``` | ||
| **Alpha channel property renamed from `a` to `alpha`:** | ||
| colord used `a` as the alpha key in all color objects. colordx uses `alpha` everywhere (except OKLab and CIE Lab where `a` is a color axis). | ||
| ```ts | ||
| // colord | ||
| colord('#ff0000').toRgb(); // { r: 255, g: 0, b: 0, a: 1 } | ||
| colord({ r: 255, g: 0, b: 0, a: 1 }); | ||
| // colordx | ||
| colordx('#ff0000').toRgb(); // { r: 255, g: 0, b: 0, alpha: 1 } | ||
| colordx({ r: 255, g: 0, b: 0, alpha: 1 }); | ||
| ``` | ||
| ### `mix()` uses sRGB; use `mixLab()` or `mixOklab()` for perceptual blending | ||
| colord's `mix` plugin interpolated in **CIE Lab** space. colordx's `mix()` uses **sRGB interpolation**, matching CSS `color-mix(in srgb, ...)` and how browsers composite layers. | ||
| `mix()` interpolates in **sRGB**, matching CSS `color-mix(in srgb, ...)` and how browsers composite layers. Use `mixOklab()` for perceptually uniform blending, or `mixLab()` (lab plugin) for CIE Lab. | ||
@@ -730,25 +648,13 @@ ```ts | ||
| // colord-compatible Lab mixing — requires lab plugin | ||
| import lab from '@colordx/core/plugins/lab'; | ||
| extend([lab]); | ||
| colordx('#000000').mixLab('#ffffff').toHex(); // '#777777' — CIE Lab (colord-compatible) | ||
| colordx('#000000').mixLab('#ffffff').toHex(); // '#777777' — CIE Lab | ||
| ``` | ||
| The same applies to `tints()`, `shades()`, and `tones()` from the mix plugin, which all call `.mix()` internally. If you have hardcoded expected hex values from colord's mix output, switch to `.mixLab()` or update the values. | ||
| The same applies to `tints()`, `shades()`, and `tones()` from the mix plugin, which all call `.mix()` internally. | ||
| ### `contrast()` rounding | ||
| colord uses `Math.floor` when rounding the WCAG contrast ratio to 2 decimal places; colordx uses standard rounding (`Math.round`). This affects values that fall exactly at .xxx5: | ||
| ```ts | ||
| colord('#ff0000').contrast('#ffffff'); // 3.99 (floor) | ||
| colordx('#ff0000').contrast('#ffffff'); // 4 (round) | ||
| ``` | ||
| ### HSL precision | ||
| colordx returns higher precision HSL/HSV values than colord. If your code does exact equality checks on `.toHsl()` output, use `toBeCloseTo` or round the values. | ||
| `toHsl()` accepts an optional `precision` argument to control decimal places: | ||
| `toHsl()` now accepts an optional `precision` argument to control decimal places: | ||
| ```ts | ||
@@ -760,7 +666,7 @@ colordx('#3d7a9f').toHsl(); // { h: 202.65, s: 44.55, l: 43.14, alpha: 1 } — default (2) | ||
| The `minify()` plugin preserves full HSL precision when building candidates, so minification is now lossless — it only picks HSL when the string is genuinely shorter than hex/rgb. | ||
| The `minify()` plugin preserves full HSL precision when building candidates, so minification is lossless — it only picks HSL when the string is genuinely shorter than hex/rgb. | ||
| ## Relative lighten/darken | ||
| By default, `.lighten(0.1)` shifts lightness by an **absolute** 10 percentage points (same as colord). Pass `{ relative: true }` to shift by a fraction of the **current** value instead — useful when migrating from Qix's `color` library or when you want proportional adjustments: | ||
| By default, `.lighten(0.1)` shifts lightness by an **absolute** 10 percentage points. Pass `{ relative: true }` to shift by a fraction of the **current** value instead — useful when migrating from Qix's `color` library or when you want proportional adjustments: | ||
@@ -767,0 +673,0 @@ ```ts |
| import {b,a}from'./chunk-IOXRZECH.mjs';var c=Array.from({length:256},(t,r)=>r.toString(16).padStart(2,"0")),n=t=>(t&15)+9*(t>>6),u=(t,r)=>n(t.charCodeAt(r))<<4|n(t.charCodeAt(r+1)),g=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,f=t=>{if(typeof t!="string")return null;let r=t.trim();if(!g.test(r))return null;let o=r.length;if(o===4||o===5){let e=n(r.charCodeAt(1)),a=n(r.charCodeAt(2)),l=n(r.charCodeAt(3)),b$1=o===5?n(r.charCodeAt(4)):15;return {r:e|e<<4,g:a|a<<4,b:l|l<<4,alpha:b((b$1|b$1<<4)/255,3)}}return {r:u(r,1),g:u(r,3),b:u(r,5),alpha:o===9?b(u(r,7)/255,3):1}},m=({r:t,g:r,b:o,alpha:e})=>{let a$1="#"+c[a(Math.round(t),0,255)]+c[a(Math.round(r),0,255)]+c[a(Math.round(o),0,255)];return e<1?a$1+c[a(Math.round(e*255),0,255)]:a$1};export{f as a,m as b};//# sourceMappingURL=chunk-4JCO6H3F.mjs.map | ||
| //# sourceMappingURL=chunk-4JCO6H3F.mjs.map |
| {"version":3,"sources":["../src/colorModels/hex.ts"],"names":["HEX_BYTE","_","i","hexNibble","c","hexByte","s","HEX_RE","parseHex","input","len","rv","gv","bv","av","round","rgbToHex","r","g","b","alpha","hex","clamp"],"mappings":"uCAGA,IAAMA,CAAAA,CAA2B,KAAA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sourcesContent":["import { clamp, round } from '../helpers.js';\nimport type { RgbColor } from '../types.js';\n\nconst HEX_BYTE = /* #__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\nconst hexNibble = (c: number): number => (c & 0xf) + 9 * (c >> 6);\nconst hexByte = (s: string, i: number): number => (hexNibble(s.charCodeAt(i)) << 4) | hexNibble(s.charCodeAt(i + 1));\nconst HEX_RE = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\nexport const parseHex = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const s = input.trim();\n if (!HEX_RE.test(s)) return null;\n const len = s.length;\n\n if (len === 4 || len === 5) {\n const rv = hexNibble(s.charCodeAt(1));\n const gv = hexNibble(s.charCodeAt(2));\n const bv = hexNibble(s.charCodeAt(3));\n const av = len === 5 ? hexNibble(s.charCodeAt(4)) : 15;\n return { r: rv | (rv << 4), g: gv | (gv << 4), b: bv | (bv << 4), alpha: round((av | (av << 4)) / 255, 3) };\n }\n\n return {\n r: hexByte(s, 1),\n g: hexByte(s, 3),\n b: hexByte(s, 5),\n alpha: len === 9 ? round(hexByte(s, 7) / 255, 3) : 1,\n };\n};\n\nexport const rgbToHex = ({ r, g, b, alpha }: RgbColor): string => {\n const hex =\n '#' +\n HEX_BYTE[clamp(Math.round(r), 0, 255)] +\n HEX_BYTE[clamp(Math.round(g), 0, 255)] +\n HEX_BYTE[clamp(Math.round(b), 0, 255)];\n return alpha < 1 ? hex + HEX_BYTE[clamp(Math.round(alpha * 255), 0, 255)] : hex;\n};\n"]} |
| 'use strict';var chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var c=Array.from({length:256},(t,r)=>r.toString(16).padStart(2,"0")),n=t=>(t&15)+9*(t>>6),u=(t,r)=>n(t.charCodeAt(r))<<4|n(t.charCodeAt(r+1)),g=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,f=t=>{if(typeof t!="string")return null;let r=t.trim();if(!g.test(r))return null;let o=r.length;if(o===4||o===5){let e=n(r.charCodeAt(1)),a=n(r.charCodeAt(2)),l=n(r.charCodeAt(3)),b=o===5?n(r.charCodeAt(4)):15;return {r:e|e<<4,g:a|a<<4,b:l|l<<4,alpha:chunkYISEJCI6_cjs.b((b|b<<4)/255,3)}}return {r:u(r,1),g:u(r,3),b:u(r,5),alpha:o===9?chunkYISEJCI6_cjs.b(u(r,7)/255,3):1}},m=({r:t,g:r,b:o,alpha:e})=>{let a="#"+c[chunkYISEJCI6_cjs.a(Math.round(t),0,255)]+c[chunkYISEJCI6_cjs.a(Math.round(r),0,255)]+c[chunkYISEJCI6_cjs.a(Math.round(o),0,255)];return e<1?a+c[chunkYISEJCI6_cjs.a(Math.round(e*255),0,255)]:a};exports.a=f;exports.b=m;//# sourceMappingURL=chunk-Z5MM7DU5.cjs.map | ||
| //# sourceMappingURL=chunk-Z5MM7DU5.cjs.map |
| {"version":3,"sources":["../src/colorModels/hex.ts"],"names":["HEX_BYTE","_","i","hexNibble","c","hexByte","s","HEX_RE","parseHex","input","len","rv","gv","bv","av","round","rgbToHex","r","g","b","alpha","hex","clamp"],"mappings":"mEAGA,IAAMA,CAAAA,CAA2B,KAAA,CAAM,IAAA,CAAK,CAAE,MAAA,CAAQ,GAAI,CAAA,CAAG,CAACC,CAAAA,CAAGC,CAAAA,GAAMA,CAAAA,CAAE,QAAA,CAAS,EAAE,CAAA,CAAE,QAAA,CAAS,CAAA,CAAG,GAAG,CAAC,CAAA,CAChGC,EAAaC,CAAAA,EAAAA,CAAuBA,CAAAA,CAAI,EAAA,EAAO,CAAA,EAAKA,CAAAA,EAAK,CAAA,CAAA,CACzDC,EAAU,CAACC,CAAAA,CAAWJ,CAAAA,GAAuBC,CAAAA,CAAUG,CAAAA,CAAE,UAAA,CAAWJ,CAAC,CAAC,CAAA,EAAK,CAAA,CAAKC,CAAAA,CAAUG,CAAAA,CAAE,UAAA,CAAWJ,EAAI,CAAC,CAAC,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CAAAA,CAAG,CAAC,CAAA,CAAI,GAAA,CAAK,CAAC,CAAA,CAAI,CACrD,CACF,CAAA,CAEaU,CAAAA,CAAW,CAAC,CAAE,CAAA,CAAAC,CAAAA,CAAG,EAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,GAAwB,CAChE,IAAMC,CAAAA,CACJ,GAAA,CACArB,CAAAA,CAASsB,mBAAAA,CAAM,IAAA,CAAK,MAAML,CAAC,CAAA,CAAG,CAAA,CAAG,GAAG,CAAC,CAAA,CACrCjB,CAAAA,CAASsB,mBAAAA,CAAM,IAAA,CAAK,KAAA,CAAMJ,CAAC,CAAA,CAAG,CAAA,CAAG,GAAG,CAAC,CAAA,CACrClB,CAAAA,CAASsB,mBAAAA,CAAM,IAAA,CAAK,KAAA,CAAMH,CAAC,EAAG,CAAA,CAAG,GAAG,CAAC,CAAA,CACvC,OAAOC,CAAAA,CAAQ,EAAIC,CAAAA,CAAMrB,CAAAA,CAASsB,mBAAAA,CAAM,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAQ,GAAG,CAAA,CAAG,CAAA,CAAG,GAAG,CAAC,CAAA,CAAIC,CAC9E","file":"chunk-Z5MM7DU5.cjs","sourcesContent":["import { clamp, round } from '../helpers.js';\nimport type { RgbColor } from '../types.js';\n\nconst HEX_BYTE = /* #__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\nconst hexNibble = (c: number): number => (c & 0xf) + 9 * (c >> 6);\nconst hexByte = (s: string, i: number): number => (hexNibble(s.charCodeAt(i)) << 4) | hexNibble(s.charCodeAt(i + 1));\nconst HEX_RE = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\nexport const parseHex = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const s = input.trim();\n if (!HEX_RE.test(s)) return null;\n const len = s.length;\n\n if (len === 4 || len === 5) {\n const rv = hexNibble(s.charCodeAt(1));\n const gv = hexNibble(s.charCodeAt(2));\n const bv = hexNibble(s.charCodeAt(3));\n const av = len === 5 ? hexNibble(s.charCodeAt(4)) : 15;\n return { r: rv | (rv << 4), g: gv | (gv << 4), b: bv | (bv << 4), alpha: round((av | (av << 4)) / 255, 3) };\n }\n\n return {\n r: hexByte(s, 1),\n g: hexByte(s, 3),\n b: hexByte(s, 5),\n alpha: len === 9 ? round(hexByte(s, 7) / 255, 3) : 1,\n };\n};\n\nexport const rgbToHex = ({ r, g, b, alpha }: RgbColor): string => {\n const hex =\n '#' +\n HEX_BYTE[clamp(Math.round(r), 0, 255)] +\n HEX_BYTE[clamp(Math.round(g), 0, 255)] +\n HEX_BYTE[clamp(Math.round(b), 0, 255)];\n return alpha < 1 ? hex + HEX_BYTE[clamp(Math.round(alpha * 255), 0, 255)] : hex;\n};\n"]} |
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100] */ | ||
| w: number; | ||
| /** Blackness [0, 100] */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** CIE LAB (D50) */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| /** CIE LCH (D50) */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| /** CIE XYZ (D65) */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| /** Oklab — perceptually uniform, D65 */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Oklch — perceptually uniform, polar form of Oklab */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| /** CSS Color 4 Display-P3 */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| /** CSS Color 4 Rec.2020 */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| type AnyColor = string | RgbColor | HslColor | HsvColor | HwbColor | LabColor | LchColor | XyzColor | CmykColor | OklabColor | OklchColor | P3Color | Rec2020Color; | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'cmyk' | 'p3' | 'rec2020' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally. | ||
| * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding, | ||
| * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output. | ||
| * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| */ | ||
| static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx; | ||
| isValid(): boolean; | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| toRgbString(): string; | ||
| toHex(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| toHsl(precision?: number): HslColor; | ||
| toHslString(precision?: number): string; | ||
| toOklab(): OklabColor; | ||
| toOklabString(): string; | ||
| toOklch(): OklchColor; | ||
| toOklchString(): string; | ||
| brightness(): number; | ||
| isDark(): boolean; | ||
| isLight(): boolean; | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| grayscale(): Colordx; | ||
| invert(): Colordx; | ||
| rotate(amount?: number): Colordx; | ||
| isEqual(color: AnyColor): boolean; | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type ColorParser as b, Colordx as c, type HsvColor as d, type HwbColor as e, type LchColor as f, type OklchColor as g, type Plugin as h, type RgbColor as i, colordx as j, extend as k, nearest as n, random as r }; |
| interface RgbColor { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| interface HslColor { | ||
| h: number; | ||
| s: number; | ||
| l: number; | ||
| alpha: number; | ||
| } | ||
| interface HsvColor { | ||
| h: number; | ||
| s: number; | ||
| v: number; | ||
| alpha: number; | ||
| } | ||
| interface HwbColor { | ||
| h: number; | ||
| /** Whiteness [0, 100] */ | ||
| w: number; | ||
| /** Blackness [0, 100] */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** CIE LAB (D50) */ | ||
| interface LabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lab'; | ||
| } | ||
| /** CIE LCH (D50) */ | ||
| interface LchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'lch'; | ||
| } | ||
| /** CIE XYZ (D65) */ | ||
| interface XyzColor { | ||
| x: number; | ||
| y: number; | ||
| z: number; | ||
| alpha: number; | ||
| } | ||
| interface CmykColor { | ||
| c: number; | ||
| m: number; | ||
| y: number; | ||
| k: number; | ||
| alpha: number; | ||
| } | ||
| /** Oklab — perceptually uniform, D65 */ | ||
| interface OklabColor { | ||
| l: number; | ||
| /** Green–red axis */ | ||
| a: number; | ||
| /** Blue–yellow axis */ | ||
| b: number; | ||
| alpha: number; | ||
| } | ||
| /** Oklch — perceptually uniform, polar form of Oklab */ | ||
| interface OklchColor { | ||
| l: number; | ||
| c: number; | ||
| h: number; | ||
| alpha: number; | ||
| } | ||
| /** CSS Color 4 Display-P3 */ | ||
| interface P3Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'display-p3'; | ||
| } | ||
| /** CSS Color 4 Rec.2020 */ | ||
| interface Rec2020Color { | ||
| r: number; | ||
| g: number; | ||
| b: number; | ||
| alpha: number; | ||
| readonly colorSpace: 'rec2020'; | ||
| } | ||
| type AnyColor = string | RgbColor | HslColor | HsvColor | HwbColor | LabColor | LchColor | XyzColor | CmykColor | OklabColor | OklchColor | P3Color | Rec2020Color; | ||
| type ColorParser<T = AnyColor> = (input: T) => RgbColor | null; | ||
| type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'cmyk' | 'p3' | 'rec2020' | 'name'; | ||
| declare const _SENTINEL: unique symbol; | ||
| declare class Colordx { | ||
| private readonly _rgb; | ||
| private readonly _valid; | ||
| constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor); | ||
| private static _make; | ||
| /** | ||
| * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally. | ||
| * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding, | ||
| * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output. | ||
| * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning. | ||
| */ | ||
| static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx; | ||
| isValid(): boolean; | ||
| toRgb(): RgbColor; | ||
| /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */ | ||
| _rawRgb(): RgbColor; | ||
| toRgbString(): string; | ||
| toHex(): string; | ||
| /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */ | ||
| toNumber(): number; | ||
| toHsl(precision?: number): HslColor; | ||
| toHslString(precision?: number): string; | ||
| toOklab(): OklabColor; | ||
| toOklabString(): string; | ||
| toOklch(): OklchColor; | ||
| toOklchString(): string; | ||
| brightness(): number; | ||
| isDark(): boolean; | ||
| isLight(): boolean; | ||
| alpha(): number; | ||
| alpha(value: number): Colordx; | ||
| hue(): number; | ||
| hue(value: number): Colordx; | ||
| lightness(): number; | ||
| lightness(value: number): Colordx; | ||
| chroma(): number; | ||
| chroma(value: number): Colordx; | ||
| lighten(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| darken(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| saturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| desaturate(amount?: number, options?: { | ||
| relative?: boolean; | ||
| }): Colordx; | ||
| grayscale(): Colordx; | ||
| invert(): Colordx; | ||
| rotate(amount?: number): Colordx; | ||
| isEqual(color: AnyColor): boolean; | ||
| toString(): string; | ||
| /** | ||
| * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255]. | ||
| * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`. | ||
| * Hue and lightness may shift noticeably for colors far outside sRGB. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| clampSrgb(): Colordx; | ||
| /** | ||
| * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm | ||
| * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma. | ||
| * Useful when hue stability matters — design tokens, palettes, color pickers. | ||
| * Returns `this` when already in gamut. | ||
| */ | ||
| mapSrgb(): Colordx; | ||
| /** | ||
| * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm. | ||
| * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through. | ||
| */ | ||
| static toGamutSrgb: (input: AnyColor) => Colordx; | ||
| } | ||
| type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void; | ||
| declare const colordx: (input: AnyColor | Colordx) => Colordx; | ||
| declare const extend: (plugins: Plugin[]) => void; | ||
| declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T; | ||
| declare const random: () => Colordx; | ||
| export { type AnyColor as A, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type ColorParser as b, Colordx as c, type HsvColor as d, type HwbColor as e, type LchColor as f, type OklchColor as g, type Plugin as h, type RgbColor as i, colordx as j, extend as k, nearest as n, random as r }; |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
621165
0.45%828
5.75%687
-12.04%