@texel/color
Advanced tools
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(npm ls:*)", | ||
| "Bash(wc:*)", | ||
| "Bash(npm audit:*)", | ||
| "Bash(npm test:*)", | ||
| "Bash(cat:*)", | ||
| "Bash(ls:*)", | ||
| "Bash(node --version:*)", | ||
| "Bash(npm:*)" | ||
| ] | ||
| } | ||
| } |
+1
-1
| The MIT License (MIT) | ||
| Copyright (c) 2024 Matt DesLauriers | ||
| Copyright (c) Matt DesLauriers | ||
@@ -4,0 +4,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
+3
-2
| { | ||
| "name": "@texel/color", | ||
| "version": "1.1.10", | ||
| "version": "1.1.11", | ||
| "description": "a minimal and modern color library", | ||
@@ -26,2 +26,3 @@ "type": "module", | ||
| "jsdoc": "^4.0.4", | ||
| "jsdoc-memberof-namespace": "^2.2.0", | ||
| "pako": "^2.1.0", | ||
@@ -38,3 +39,3 @@ "png-tools": "^1.0.4", | ||
| "types": "jsdoc src -r -t node_modules/tsd-jsdoc/dist -c tools/.jsdoc.types.json -d .", | ||
| "test": "faucet test/test*.js", | ||
| "test": "node test/test.js | faucet", | ||
| "bench": "node test/bench-colorjs.js", | ||
@@ -41,0 +42,0 @@ "bench:node": "NODE_ENV=production node --prof --no-logfile-per-isolate test/bench-node.js && node --prof-process v8.log", |
+3
-3
@@ -345,3 +345,3 @@ # @texel/color | ||
| You can build custom color space objects to extend this library, such as adding support for CIELab and HSL. See [test/spaces/lab.js](./test/spaces/lab.js) and [test/spaces/hsl.js](./test/spaces/hsl.js) for examples of this. Some of these spaces may be added to the library at a later point, although the current focus is on "modern" spaces (such as OKLab that has largely made CIELab and HSL obsolete). Documentaiton on custom color spaces is WIP. | ||
| You can build custom color space objects to extend this library, such as adding support for CIELab and HSL. See [test/spaces/lab.js](./test/spaces/lab.js) and [test/spaces/hsl.js](./test/spaces/hsl.js) for examples of this. Some of these spaces may be added to the library at a later point, although the current focus is on "modern" spaces (such as OKLab that has largely made CIELab and HSL obsolete). Documentation on custom color spaces is WIP. | ||
@@ -354,5 +354,5 @@ ## Notes | ||
| Colorjs, and simialrly, [Culori](https://culorijs.org/), are focused on matching CSS spec, which means it will very likely continue to grow in complexity over time, and performance will often be marred (for example, `@texel/color` cusp intersection gamut mapping is ~125 times faster than Colorjs and ~60 times faster than culori). | ||
| Colorjs, and similarly, [Culori](https://culorijs.org/), are focused on matching CSS spec, which means it will very likely continue to grow in complexity over time, and performance will often be marred (for example, `@texel/color` cusp intersection gamut mapping is ~125 times faster than Colorjs and ~60 times faster than culori). | ||
| There are many other options such as [color-space](https://www.npmjs.com/package/color-space) or [color-convert](https://www.npmjs.com/package/color-convert), however, these do not support modern spacse such as OKLab and OKHSL, and/or have dubious levels of accuracy (many libraries, for example, do not distinguish between D50 and D65 whitepoints in XYZ). | ||
| There are many other options such as [color-space](https://www.npmjs.com/package/color-space) or [color-convert](https://www.npmjs.com/package/color-convert), however, these do not support modern spaces such as OKLab and OKHSL, and/or have dubious levels of accuracy (many libraries, for example, do not distinguish between D50 and D65 whitepoints in XYZ). | ||
@@ -359,0 +359,0 @@ ### Supported Spaces |
+4
-4
@@ -149,3 +149,3 @@ import { clamp, floatToByte, hexToRGB, vec3 } from "./util.js"; | ||
| const id = outputSpace.id; | ||
| if (id == "srgb") { | ||
| if (id === "srgb") { | ||
| // uses the legacy rgb() format | ||
@@ -159,3 +159,3 @@ const r = floatToByte(tmp3[0]); | ||
| const alphaSuffix = alpha === 1 ? "" : ` / ${alpha}`; | ||
| if (id == "oklab" || id == "oklch") { | ||
| if (id === "oklab" || id === "oklch") { | ||
| // older versions of Safari don't support oklch with 0..1 L but do support % | ||
@@ -301,3 +301,3 @@ return `${id}(${tmp3[0] * 100}% ${tmp3[1]} ${tmp3[2]}${alphaSuffix})`; | ||
| // reduce to 3D | ||
| if (alpha == 1 && out.length === 4) out.pop(); | ||
| if (alpha === 1 && out.length === 4) out.pop(); | ||
| return out; | ||
@@ -324,3 +324,3 @@ }; | ||
| // special case: no conversion needed | ||
| if (fromSpace == toSpace) { | ||
| if (fromSpace === toSpace) { | ||
| return out; | ||
@@ -327,0 +327,0 @@ } |
+2
-2
@@ -348,3 +348,3 @@ import { | ||
| throw new Error( | ||
| `color space ${outSpace.id} has no base with LMS to RGB matrix` | ||
| `color space ${gamutSpaceBase.id} has no base with LMS to RGB matrix` | ||
| ); | ||
@@ -410,3 +410,3 @@ } | ||
| const targetSpaceBase = targetSpace.base ?? targetSpace; | ||
| if (targetSpaceBase.id == "oklab") { | ||
| if (targetSpaceBase.id === "oklab") { | ||
| return convert(out, OKLCH, targetSpace, out); | ||
@@ -413,0 +413,0 @@ } |
+1
-1
@@ -374,3 +374,3 @@ import { vec3, constrainAngle as constrain } from "./util.js"; | ||
| // unlike colorjs.io, we are not worknig with none-types | ||
| // unlike colorjs.io, we are not working with none-types | ||
| // if (Math.abs(s) < ε || v === 0.0) { | ||
@@ -377,0 +377,0 @@ // h = null; |
+2
-0
@@ -87,2 +87,4 @@ /** | ||
| * @deprecated Use RGBToHex instead. | ||
| * @param {Vector} rgb The RGB array. | ||
| * @returns {string} The hex color string. | ||
| * @category rgb | ||
@@ -89,0 +91,0 @@ */ |
+6
-2
@@ -389,7 +389,11 @@ declare module "@texel/color" { | ||
| function RGBToHex(rgb: Vector): string; | ||
| function RGBtoHex(): void; | ||
| /** | ||
| * @param rgb - The RGB array. | ||
| * @returns The hex color string. | ||
| */ | ||
| function RGBtoHex(rgb: Vector): string; | ||
| /** | ||
| * Checks if an RGB color is within the gamut. | ||
| * @param lrgb - The linear RGB array. | ||
| * @param [ep = GAMUT_EPSILON] - The epsilon value for comparison. | ||
| * @param [ep = 0] - The epsilon value for comparison. | ||
| * @returns True if the color is within the gamut, false otherwise. | ||
@@ -396,0 +400,0 @@ */ |
111488
0.42%21
5%2505
0.8%15
7.14%