chromonym 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +39 -0
- package/README.md +240 -3
- package/dist/colorspaces/index.d.ts +4 -0
- package/dist/colorspaces/index.d.ts.map +1 -0
- package/dist/colorspaces/index.js +4 -0
- package/dist/colorspaces/index.js.map +1 -0
- package/dist/colorspaces/pantone.d.ts +919 -0
- package/dist/colorspaces/pantone.d.ts.map +1 -0
- package/dist/colorspaces/pantone.js +918 -0
- package/dist/colorspaces/pantone.js.map +1 -0
- package/dist/colorspaces/registry.d.ts +26 -0
- package/dist/colorspaces/registry.d.ts.map +1 -0
- package/dist/colorspaces/registry.js +36 -0
- package/dist/colorspaces/registry.js.map +1 -0
- package/dist/colorspaces/web.d.ts +156 -0
- package/dist/colorspaces/web.d.ts.map +1 -0
- package/dist/colorspaces/web.js +155 -0
- package/dist/colorspaces/web.js.map +1 -0
- package/dist/colorspaces/x11.d.ts +667 -0
- package/dist/colorspaces/x11.d.ts.map +1 -0
- package/dist/colorspaces/x11.js +666 -0
- package/dist/colorspaces/x11.js.map +1 -0
- package/dist/conversions/hex.d.ts +13 -0
- package/dist/conversions/hex.d.ts.map +1 -0
- package/dist/conversions/hex.js +40 -0
- package/dist/conversions/hex.js.map +1 -0
- package/dist/conversions/hsl.d.ts +12 -0
- package/dist/conversions/hsl.d.ts.map +1 -0
- package/dist/conversions/hsl.js +72 -0
- package/dist/conversions/hsl.js.map +1 -0
- package/dist/conversions/hsv.d.ts +12 -0
- package/dist/conversions/hsv.d.ts.map +1 -0
- package/dist/conversions/hsv.js +67 -0
- package/dist/conversions/hsv.js.map +1 -0
- package/dist/conversions/index.d.ts +6 -0
- package/dist/conversions/index.d.ts.map +1 -0
- package/dist/conversions/index.js +6 -0
- package/dist/conversions/index.js.map +1 -0
- package/dist/conversions/pantone.d.ts +17 -0
- package/dist/conversions/pantone.d.ts.map +1 -0
- package/dist/conversions/pantone.js +27 -0
- package/dist/conversions/pantone.js.map +1 -0
- package/dist/conversions/rgb.d.ts +15 -0
- package/dist/conversions/rgb.d.ts.map +1 -0
- package/dist/conversions/rgb.js +57 -0
- package/dist/conversions/rgb.js.map +1 -0
- package/dist/convert.d.ts +21 -0
- package/dist/convert.d.ts.map +1 -0
- package/dist/convert.js +69 -0
- package/dist/convert.js.map +1 -0
- package/dist/detectFormat.d.ts +17 -0
- package/dist/detectFormat.d.ts.map +1 -0
- package/dist/detectFormat.js +59 -0
- package/dist/detectFormat.js.map +1 -0
- package/dist/identify.d.ts +20 -0
- package/dist/identify.d.ts.map +1 -0
- package/dist/identify.js +29 -0
- package/dist/identify.js.map +1 -0
- package/dist/index.d.ts +14 -337
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -267
- package/dist/index.js.map +1 -1
- package/dist/indexing.d.ts +44 -0
- package/dist/indexing.d.ts.map +1 -0
- package/dist/indexing.js +140 -0
- package/dist/indexing.js.map +1 -0
- package/dist/math/clamp.d.ts +11 -0
- package/dist/math/clamp.d.ts.map +1 -0
- package/dist/math/clamp.js +18 -0
- package/dist/math/clamp.js.map +1 -0
- package/dist/math/colorSpace.d.ts +39 -0
- package/dist/math/colorSpace.d.ts.map +1 -0
- package/dist/math/colorSpace.js +85 -0
- package/dist/math/colorSpace.js.map +1 -0
- package/dist/math/deltaE.d.ts +47 -0
- package/dist/math/deltaE.d.ts.map +1 -0
- package/dist/math/deltaE.js +185 -0
- package/dist/math/deltaE.js.map +1 -0
- package/dist/math/euclideanDistance.d.ts +16 -0
- package/dist/math/euclideanDistance.d.ts.map +1 -0
- package/dist/math/euclideanDistance.js +22 -0
- package/dist/math/euclideanDistance.js.map +1 -0
- package/dist/math/hueSector.d.ts +15 -0
- package/dist/math/hueSector.d.ts.map +1 -0
- package/dist/math/hueSector.js +27 -0
- package/dist/math/hueSector.js.map +1 -0
- package/dist/resolve.d.ts +14 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +26 -0
- package/dist/resolve.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -5
package/NOTICE.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Notices and Trademarks
|
|
2
|
+
|
|
3
|
+
## Pantone®
|
|
4
|
+
|
|
5
|
+
**Pantone®** is a registered trademark of **Pantone LLC**. Chromonym is
|
|
6
|
+
**not affiliated with, endorsed by, licensed by, or certified by Pantone
|
|
7
|
+
LLC**.
|
|
8
|
+
|
|
9
|
+
The `pantone` colorspace in this library ships **community-derived sRGB
|
|
10
|
+
approximations** of the Pantone Coated (C) color set, sourced from
|
|
11
|
+
[`color_library`](https://github.com/draganradu/color_library) (MIT © Radu
|
|
12
|
+
Dragan). These values:
|
|
13
|
+
|
|
14
|
+
- Are **not official Pantone measurements** and will not match a licensed
|
|
15
|
+
Pantone reference (physical chips, Pantone Connect, or the Pantone SDK)
|
|
16
|
+
exactly.
|
|
17
|
+
- Are intended for on-screen reference, nearest-name identification, and
|
|
18
|
+
general tooling — **not for print color specification**.
|
|
19
|
+
- Use standard color codes (e.g. `185C`) as **nominative references** to
|
|
20
|
+
publicly identified Pantone colors. No endorsement or claim of accuracy
|
|
21
|
+
is implied.
|
|
22
|
+
|
|
23
|
+
If you need Pantone-certified color values, consult Pantone directly:
|
|
24
|
+
<https://www.pantone.com/>.
|
|
25
|
+
|
|
26
|
+
## X11 / X.Org
|
|
27
|
+
|
|
28
|
+
The `x11` colorspace is derived from the X.Org `rgb.txt` file, which is in
|
|
29
|
+
the public domain.
|
|
30
|
+
|
|
31
|
+
## CSS / SVG named colors
|
|
32
|
+
|
|
33
|
+
The `web` colorspace mirrors the CSS Color Module Level 4 named-color
|
|
34
|
+
set, which is a public specification.
|
|
35
|
+
|
|
36
|
+
## Upstream dependencies
|
|
37
|
+
|
|
38
|
+
See `package.json` for runtime and development dependencies. All are MIT
|
|
39
|
+
or ISC licensed.
|
package/README.md
CHANGED
|
@@ -1,17 +1,233 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src=".github/assets/banner.svg" alt="chromonym" width="800" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://simiancraft.github.io/chromonym/">
|
|
7
|
+
<img src="https://img.shields.io/badge/▶%20Live%20demo-scrub%20a%20color%2C%20see%20the%20name-4f46e5?style=for-the-badge" alt="Live demo" />
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
1
11
|
# chromonym
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
[](https://github.com/simiancraft/chromonym/actions/workflows/ci.yml)
|
|
14
|
+
[](https://codecov.io/gh/simiancraft/chromonym)
|
|
15
|
+
[](https://opensource.org/licenses/MIT)
|
|
16
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
17
|
+
[](https://biomejs.dev)
|
|
18
|
+
|
|
19
|
+
**Tree-shakeable color naming for TypeScript.** Identify, resolve, and convert colors across CSS, X11, and Pantone — with 5 perceptual distance metrics. Add your own colorspaces and metrics as you need them.
|
|
4
20
|
|
|
5
|
-
|
|
21
|
+
Built as a *color-strategy machine*: the identification and resolution mechanism is the same across every colorspace, so plugging in a new set (RAL, HKS, NCS, or a custom brand palette) is one file. For color *manipulation* (mixing, scales, gamut mapping), reach for [`chroma-js`](https://gka.github.io/chroma.js/) or [`color.js`](https://colorjs.io/) — chromonym is the tool for *naming*.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { identify, resolve, convert } from 'chromonym';
|
|
25
|
+
|
|
26
|
+
identify('#ff0000') // 'red'
|
|
27
|
+
resolve('crimson') // '#dc143c'
|
|
28
|
+
resolve('185 C', { colorspace: 'pantone' }) // '#e4002b'
|
|
29
|
+
convert('#ff0000', { format: 'RGB' }) // 'rgb(255, 0, 0)'
|
|
30
|
+
convert({ r: 255, g: 0, b: 0 }, { format: 'HSL' })// 'hsl(0, 100%, 50%)'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> ### Pantone® trademark notice
|
|
34
|
+
>
|
|
35
|
+
> **Pantone®** is a registered trademark of **Pantone LLC**. Chromonym is **not affiliated with, endorsed by, or certified by Pantone LLC**. The `pantone` colorspace ships **community-derived sRGB approximations** of the Pantone Coated (C) set. Values will **not** match a licensed Pantone reference exactly and are unsuitable for print color specification. See [`NOTICE.md`](./NOTICE.md) for full text.
|
|
6
36
|
|
|
7
37
|
## Install
|
|
8
38
|
|
|
9
39
|
```sh
|
|
10
40
|
bun add chromonym
|
|
11
|
-
# or
|
|
12
41
|
npm install chromonym
|
|
13
42
|
```
|
|
14
43
|
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
Three primary functions. All accept an optional `opts` object; defaults fire when omitted.
|
|
47
|
+
|
|
48
|
+
### `identify(input, opts?)`
|
|
49
|
+
|
|
50
|
+
**Color → name.** Finds the nearest-match name in the chosen colorspace using the selected perceptual distance metric.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
function identify(
|
|
54
|
+
input: ColorInput,
|
|
55
|
+
opts?: { colorspace?: ColorspaceName; metric?: DistanceMetric },
|
|
56
|
+
): string | null
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- **Default colorspace**: `'web'`.
|
|
60
|
+
- **Default metric**: picked per colorspace — `'deltaE76'` for web and x11 (well-separated palettes), `'deltaE2000'` for pantone (dense, perceptually-packed). Override freely via `metric`.
|
|
61
|
+
- Returns the matched name, or `null` if input is unrecognized (`detectFormat` returns `'UNKNOWN'`).
|
|
62
|
+
- Ties are broken by the first entry encountered in the colorspace data.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
identify('#ff0000') // 'red'
|
|
66
|
+
identify([255, 0, 0]) // 'red'
|
|
67
|
+
identify({ r: 250, g: 20, b: 60 }) // 'crimson' (nearest)
|
|
68
|
+
identify('#ff0000', { colorspace: 'x11' }) // 'red' (or 'red1', X11 has numbered variants)
|
|
69
|
+
identify('#ff0000', { colorspace: 'pantone' }) // nearest Pantone C code, e.g. '185C'
|
|
70
|
+
identify('#ff0080', { metric: 'deltaE2000' }) // force perceptual-accurate match
|
|
71
|
+
identify('#ff0000', { metric: 'euclidean-srgb' }) // force fastest (non-perceptual) match
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `resolve(name, opts?)`
|
|
75
|
+
|
|
76
|
+
**Name → color.** Normalizes the input (lowercases it, strips all non-alphanumeric characters), looks up the canonical key in the chosen colorspace, and returns the value in the chosen format.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
function resolve(
|
|
80
|
+
name: string,
|
|
81
|
+
opts?: { colorspace?: ColorspaceName; format?: ColorFormat },
|
|
82
|
+
): ColorValue | null
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- **Default colorspace**: `'web'`.
|
|
86
|
+
- **Default format**: `'HEX'`.
|
|
87
|
+
- Returns `null` if the normalized name isn't in the colorspace.
|
|
88
|
+
- Normalization lets users pass `'Alice Blue'`, `'alice-blue'`, `'ALICEBLUE'`, `'Pantone 185 C'` etc. — all resolved identically.
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
resolve('crimson') // '#dc143c'
|
|
92
|
+
resolve('Alice Blue') // '#f0f8ff'
|
|
93
|
+
resolve('alice-blue!') // '#f0f8ff'
|
|
94
|
+
resolve('185 C', { colorspace: 'pantone' }) // '#e4002b'
|
|
95
|
+
resolve('Pantone 185 C', { colorspace: 'pantone' })// '#e4002b' (same, normalized)
|
|
96
|
+
resolve('crimson', { format: 'RGB' }) // 'rgb(220, 20, 60)'
|
|
97
|
+
resolve('crimson', { format: 'RGBA' }) // { r: 220, g: 20, b: 60, a: 1 }
|
|
98
|
+
resolve('not-a-color') // null
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `convert(input, opts?)`
|
|
102
|
+
|
|
103
|
+
**Color → color in a different format.** Detects the input format, normalizes to the canonical internal `Rgba` representation, and returns the value in the target format. Colorspace-independent.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
function convert(
|
|
107
|
+
input: ColorInput,
|
|
108
|
+
opts?: { format?: ColorFormat },
|
|
109
|
+
): ColorValue
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- **Default format**: `'HEX'`.
|
|
113
|
+
- Throws if input format is unrecognized.
|
|
114
|
+
- Alpha information is preserved when converting into RGBA/RGB(A) string forms, and discarded for HEX (6-digit) / HSL / HSV / PANTONE output.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
convert('#ff0000') // '#ff0000' (identity)
|
|
118
|
+
convert('#ff0000', { format: 'RGB' }) // 'rgb(255, 0, 0)'
|
|
119
|
+
convert('#ff0000', { format: 'RGBA' }) // { r: 255, g: 0, b: 0, a: 1 }
|
|
120
|
+
convert([255, 0, 0], { format: 'HEX' }) // '#ff0000'
|
|
121
|
+
convert('rgb(255, 0, 0)', { format: 'HSL' }) // 'hsl(0, 100%, 50%)'
|
|
122
|
+
convert({ h: 0, s: 100, l: 50 }, { format: 'HEX' })// '#ff0000'
|
|
123
|
+
convert('185 C', { format: 'HEX' }) // '#e4002b'
|
|
124
|
+
convert('#e4002b', { format: 'PANTONE' }) // '185C' (nearest Pantone C)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Colorspaces
|
|
128
|
+
|
|
129
|
+
| Name | Entries | Source |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `'web'` (default) | 148 | CSS Color Module Level 4 named colors |
|
|
132
|
+
| `'x11'` | 658 | X.Org `rgb.txt` (public domain) |
|
|
133
|
+
| `'pantone'` | 907 | Pantone Coated (C) — community approximations (not Pantone-licensed) |
|
|
134
|
+
|
|
135
|
+
Each colorspace is a pure data object: `Record<string, HexColor>`. Importable directly:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { web, x11, pantone } from 'chromonym';
|
|
139
|
+
web.crimson // '#dc143c'
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Distance metrics
|
|
143
|
+
|
|
144
|
+
`identify` picks the nearest-named color by comparing your input to every entry in the chosen colorspace. *How* it measures "nearest" is controlled by `metric`. Five options, roughly ordered from fast-and-approximate to slow-and-correct:
|
|
145
|
+
|
|
146
|
+
| Metric | What it does | When to use |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `'euclidean-srgb'` | Raw `sqrt(Δr² + Δg² + Δb²)` in sRGB. Fastest. Not perceptually uniform — a unit of distance doesn't mean a unit of "visual difference." | Tight perf budgets; well-separated palettes where you just need the obvious answer. |
|
|
149
|
+
| `'euclidean-linear'` | Same math, but on linearized (gamma-removed) RGB. Somewhat better in dark regions. Still not perceptual. | Physical-light mixing contexts; incremental upgrade from sRGB Euclidean. |
|
|
150
|
+
| `'deltaE76'` | Euclidean in CIELAB (CIE 1976). Simple perceptual metric. 1 ΔE ≈ "just noticeable difference" for most of the gamut. | **Default for web and x11.** Sweet spot: meaningful perceptual accuracy, low cost. |
|
|
151
|
+
| `'deltaE94'` | ΔE76 + chroma/hue weighting (CIE 1994). Fixes "saturated colors feel too far apart." | When ΔE76 is over-penalizing saturated matches in your use case. |
|
|
152
|
+
| `'deltaE2000'` | Full CIEDE2000 formula with blue/purple rotation correction. Industry standard for print, design tools, Pantone workflows. | **Default for pantone.** Use whenever accuracy matters, especially in the blue region where ΔE76/94 break down. |
|
|
153
|
+
| `'deltaEok'` | Euclidean distance in OKLAB (Björn Ottosson, 2020). OKLAB is perceptually uniform by construction — no weighting formula needed. Strictly more uniform than CIELAB; often a better nearest-match than ΔE2000 in saturated-blue regions, and cheaper to compute. | Modern default if you want perceptual accuracy without the CIEDE2000 rotation-term complexity. |
|
|
154
|
+
|
|
155
|
+
Each metric trades cost for accuracy — the full scan over 907 Pantone entries is well under 1 ms even with ΔE2000, so for interactive UIs there's no practical reason not to use the most accurate metric. Batch-processing millions of colors is where you'd drop down.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
// Defaults: deltaE76 for web/x11, deltaE2000 for pantone.
|
|
159
|
+
identify('#ff8080') // deltaE76 (web default)
|
|
160
|
+
identify('#ff8080', { colorspace: 'pantone' }) // deltaE2000 (pantone default)
|
|
161
|
+
|
|
162
|
+
// Override per-call:
|
|
163
|
+
identify('#ff8080', { metric: 'euclidean-srgb' }) // fastest
|
|
164
|
+
identify('#ff8080', { metric: 'deltaE2000' }) // most accurate
|
|
165
|
+
identify('#ff8080', { colorspace: 'pantone', metric: 'euclidean-srgb' }) // force fast for Pantone
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The low-level `rgbaToPantone` always uses `'deltaE2000'` — appropriate for Pantone matching, where this is what the industry tools use.
|
|
169
|
+
|
|
170
|
+
## Formats
|
|
171
|
+
|
|
172
|
+
Format keys are SCREAMING_CAPS — they are used as dispatch keys internally.
|
|
173
|
+
|
|
174
|
+
| Key | Input accepted | Output shape |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| `'HEX'` | `'#rgb'`, `'#rrggbb'`, `'#rrggbbaa'` | `'#rrggbb'` string |
|
|
177
|
+
| `'RGB'` | `'rgb(r, g, b)'`, `[r, g, b]`, `{ r, g, b }` | `'rgb(r, g, b)'` string |
|
|
178
|
+
| `'RGBA'` | `'rgba(r, g, b, a)'`, `[r, g, b, a]`, `{ r, g, b, a }` | `{ r, g, b, a }` object |
|
|
179
|
+
| `'HSL'` | `'hsl(h, s%, l%)'`, `{ h, s, l }` | `'hsl(h, s%, l%)'` string |
|
|
180
|
+
| `'HSV'` | `'hsv(h, s%, v%)'`, `{ h, s, v }` | `'hsv(h, s%, v%)'` string |
|
|
181
|
+
| `'PANTONE'` | `'185 C'`, `'185C'`, `'Pantone 185 C'`, etc. | `'185C'`-style string |
|
|
182
|
+
|
|
183
|
+
The runtime set `COLOR_FORMATS` is exported for enumeration / membership checks.
|
|
184
|
+
|
|
185
|
+
## Error handling
|
|
186
|
+
|
|
187
|
+
The three dispatchers are asymmetric — chosen deliberately, but worth knowing:
|
|
188
|
+
|
|
189
|
+
| Function | Unrecognized / unknown input | Rationale |
|
|
190
|
+
|---|---|---|
|
|
191
|
+
| `identify(input)` | returns `null` | lookup-flavored; "no match" is a normal outcome |
|
|
192
|
+
| `resolve(name)` | returns `null` | lookup-flavored; name may legitimately not exist |
|
|
193
|
+
| `convert(input)` | **throws** | parser-flavored; malformed color is a caller error |
|
|
194
|
+
|
|
195
|
+
Low-level converters (`hexToRgba`, `rgbToRgba`, `hslToRgba`, `hsvToRgba`, `pantoneToRgba`) all **throw** on malformed input. The `rgbaTo*` direction never throws. The nearest-match returner `rgbaToPantone` always returns *some* Pantone code.
|
|
196
|
+
|
|
197
|
+
If you want a `null`-returning variant of `convert`, wrap it:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const tryConvert = (input: ColorInput, opts = {}) => {
|
|
201
|
+
try { return convert(input, opts); } catch { return null; }
|
|
202
|
+
};
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Utilities
|
|
206
|
+
|
|
207
|
+
- **`detectFormat(input): DetectedFormat`** — runtime format detection. Returns one of the format keys or `'UNKNOWN'`.
|
|
208
|
+
- **`COLOR_FORMATS: ReadonlySet<ColorFormat>`** — the Set of valid format keys.
|
|
209
|
+
- **Per-format converters** (tree-shakeable) — `hexToRgba`, `rgbaToHex`, `rgbToRgba`, `rgbaToRgb`, `hslToRgba`, `rgbaToHsl`, `hsvToRgba`, `rgbaToHsv`, `pantoneToRgba`, `rgbaToPantone`. Use these directly if you only need one conversion and want maximum tree-shaking.
|
|
210
|
+
|
|
211
|
+
## Tree-shaking
|
|
212
|
+
|
|
213
|
+
- `sideEffects: false` in `package.json`.
|
|
214
|
+
- All exports are named; no default export.
|
|
215
|
+
- Barrel uses explicit re-exports.
|
|
216
|
+
- Importing `{ resolve }` or `{ identify }` pulls in all three colorspaces (necessary for the string-keyed `colorspace` option). For strict tree-shaking of colorspace data, use the low-level converters and colorspace objects directly.
|
|
217
|
+
|
|
218
|
+
## Types
|
|
219
|
+
|
|
220
|
+
All types are re-exported from the root:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
import type {
|
|
224
|
+
ColorInput, ColorValue, ColorFormat, ColorspaceName,
|
|
225
|
+
HexColor, Rgba, RgbInput, RgbaInput, HslInput, HsvInput, PantoneCode,
|
|
226
|
+
Colorspace,
|
|
227
|
+
WebColorName, X11ColorName, PantoneColorName,
|
|
228
|
+
} from 'chromonym';
|
|
229
|
+
```
|
|
230
|
+
|
|
15
231
|
## Development
|
|
16
232
|
|
|
17
233
|
```sh
|
|
@@ -22,6 +238,27 @@ bun test
|
|
|
22
238
|
bun run build
|
|
23
239
|
```
|
|
24
240
|
|
|
241
|
+
Regenerating colorspace data:
|
|
242
|
+
|
|
243
|
+
```sh
|
|
244
|
+
bun run scripts/generate-x11.ts # reads /usr/share/X11/rgb.txt
|
|
245
|
+
bun run scripts/generate-pantone.ts # reads color_library (MIT dependency)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Coverage
|
|
249
|
+
|
|
250
|
+
[](https://codecov.io/github/simiancraft/chromonym)
|
|
251
|
+
|
|
252
|
+
Each ring is a directory; each leaf is a file. Green is covered, red is gaps.
|
|
253
|
+
|
|
254
|
+
## See also
|
|
255
|
+
|
|
256
|
+
chromonym deliberately limits its scope to color *naming*. For other color-related work, reach for tools that do those things well:
|
|
257
|
+
|
|
258
|
+
- **[color.js](https://colorjs.io/)** — modern, spec-first color library by the CSS Color WG authors. CSS Color 4/5, OKLAB, P3, gamut mapping, interpolation, ΔE.
|
|
259
|
+
- **[chroma.js](https://gka.github.io/chroma.js/)** — color mixing, scales, interpolation, contrast ratios, luminance.
|
|
260
|
+
- **[tinycolor2](https://github.com/bgrins/TinyColor)** — lightweight manipulation (lighten / darken / mix) with CSS-string I/O.
|
|
261
|
+
|
|
25
262
|
## License
|
|
26
263
|
|
|
27
264
|
MIT © [the-simian](https://github.com/the-simian)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/colorspaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,KAAK,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,KAAK,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/colorspaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAqB,GAAG,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAqB,GAAG,EAAE,MAAM,OAAO,CAAC"}
|