From 8bb41a4019c0a291be0d61408ea67ddc069094aa Mon Sep 17 00:00:00 2001 From: Jonny Gerig Meyer Date: Fri, 16 Feb 2024 11:15:46 -0500 Subject: [PATCH] Enforce trailing commas unless `]` or `}` is on the same line. --- .eleventy.cjs | 12 +- .eslintrc.cjs | 3 + apps/convert/convert.js | 2 +- apps/gamut-mapping/index.js | 8 +- apps/gamut-mapping/map-color.js | 12 +- apps/gamut-mapping/methods.js | 6 +- apps/picker/index.js | 6 +- assets/js/docs.js | 8 +- assets/js/index.js | 8 +- elements/css-color/css-color.js | 4 +- notebook/color-notebook.js | 36 +-- notebook/repl.js | 2 +- rollup.config.js | 6 +- rollup.legacy.config.js | 4 +- scripts/cat-mat.js | 8 +- src/CATs.js | 26 +- src/adapt.js | 4 +- src/chromaticity.js | 4 +- src/clone.js | 2 +- src/color.js | 4 +- src/deltaE/index.js | 4 +- src/interpolation.js | 2 +- src/keywords.js | 2 +- src/luminance.js | 2 +- src/parse.js | 2 +- src/rgbspace.js | 8 +- src/space-accessors.js | 2 +- src/spaces/a98rgb-linear.js | 6 +- src/spaces/a98rgb.js | 4 +- src/spaces/acescc.js | 12 +- src/spaces/acescg.js | 14 +- src/spaces/cam16.js | 34 +-- src/spaces/hct.js | 6 +- src/spaces/hpluv.js | 12 +- src/spaces/hsl.js | 10 +- src/spaces/hsluv.js | 14 +- src/spaces/hsv.js | 18 +- src/spaces/hwb.js | 12 +- src/spaces/ictcp.js | 18 +- src/spaces/jzazbz.js | 14 +- src/spaces/jzczhz.js | 8 +- src/spaces/lab-d65.js | 16 +- src/spaces/lab.js | 16 +- src/spaces/lch.js | 16 +- src/spaces/lchuv.js | 16 +- src/spaces/luv.js | 16 +- src/spaces/oklab.js | 20 +- src/spaces/oklch.js | 14 +- src/spaces/p3-linear.js | 6 +- src/spaces/p3.js | 2 +- src/spaces/prophoto-linear.js | 6 +- src/spaces/prophoto.js | 4 +- src/spaces/rec2020-linear.js | 6 +- src/spaces/rec2020.js | 2 +- src/spaces/rec2100-hlg.js | 2 +- src/spaces/rec2100-pq.js | 2 +- src/spaces/srgb-linear.js | 6 +- src/spaces/srgb.js | 12 +- src/spaces/xyz-abs-d65.js | 4 +- src/spaces/xyz-d50.js | 2 +- src/spaces/xyz-d65.js | 2 +- src/toGamut.js | 10 +- src/util.js | 2 +- test/adapt.js | 10 +- test/angles.js | 14 +- test/construct.js | 28 +- test/conversions.js | 446 ++++++++++++++++---------------- test/delta.js | 370 +++++++++++++------------- test/gamut.js | 136 +++++----- test/hpluv.js | 14 +- test/hsluv.js | 14 +- test/in_gamut.js | 56 ++-- test/index-fn.js | 2 +- test/parse.js | 194 +++++++------- types/test/spaces.ts | 8 +- 75 files changed, 923 insertions(+), 920 deletions(-) diff --git a/.eleventy.cjs b/.eleventy.cjs index 394b5f4ed..c84c9a56e 100644 --- a/.eleventy.cjs +++ b/.eleventy.cjs @@ -13,7 +13,7 @@ module.exports = config => { config.setFrontMatterParsingOptions({ excerpt: true, // Optional, default is "---" - excerpt_separator: "" + excerpt_separator: "", }); // config.addFilter("readable_date", date => { @@ -30,12 +30,12 @@ module.exports = config => { let ret = require("path").relative(path, "/"); return ret || "."; - } + }, ); config.addFilter( "unslugify", - slug => slug.replace(/(^|-)([a-z])/g, ($0, $1, $2) => ($1 ? " " : "") + $2.toUpperCase()) + slug => slug.replace(/(^|-)([a-z])/g, ($0, $1, $2) => ($1 ? " " : "") + $2.toUpperCase()), ); config.addFilter( @@ -43,14 +43,14 @@ module.exports = config => { content => { // console.log(content); return content ? content.match(/^#+\s*(.+)/)?.[1] ?? "NO_HEADING_FOUND" : "EMPTY_CONTENT"; - } + }, ); return { markdownTemplateEngine: "njk", templateFormats: ["md", "njk"], dir: { - output: "." - } + output: ".", + }, }; }; diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 62a24f60f..8e5677af5 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -189,6 +189,9 @@ module.exports = { // Enforce consistent brace style for blocks // https://eslint.style/rules/default/brace-style "@stylistic/brace-style": [1, "stroustrup"], + // Enforce trailing commas unless closing `]` or `}` is on the same line + // https://eslint.style/rules/default/comma-dangle + "@stylistic/comma-dangle": [1, "always-multiline"], // Enforce no space before and one or more spaces after a comma // https://eslint.style/rules/default/comma-spacing "@stylistic/comma-spacing": 1, diff --git a/apps/convert/convert.js b/apps/convert/convert.js index bc4ad41b4..ad2fe6f50 100644 --- a/apps/convert/convert.js +++ b/apps/convert/convert.js @@ -13,7 +13,7 @@ function update () { let oldParams = getURLParams(); let newParams = [ ["color", colorInput.value], - ["precision", precisionInput.value || "0"] + ["precision", precisionInput.value || "0"], ]; let changed = ![...new URL(location).searchParams].every((pair, i) => { diff --git a/apps/gamut-mapping/index.js b/apps/gamut-mapping/index.js index 3f6a748fe..5658263fa 100644 --- a/apps/gamut-mapping/index.js +++ b/apps/gamut-mapping/index.js @@ -29,7 +29,7 @@ let app = createApp({ methods: { toPrecision: Color.util.toPrecision, - abs: Math.abs + abs: Math.abs, }, watch: { @@ -54,12 +54,12 @@ let app = createApp({ document.title = value.join(", ") + " • Gamut Mapping Playground"; }, immediate: true, - deep: true - } + deep: true, + }, }, components: { - "map-color": MapColor + "map-color": MapColor, }, }).mount(document.body); diff --git a/apps/gamut-mapping/map-color.js b/apps/gamut-mapping/map-color.js index d8a8c9502..eeae25607 100644 --- a/apps/gamut-mapping/map-color.js +++ b/apps/gamut-mapping/map-color.js @@ -6,7 +6,7 @@ let spacesToShow = [Color.spaces.oklch, Color.spaces.p3, Color.spaces["p3-linear export default { props: { - modelValue: String + modelValue: String, }, emits: ["update:modelValue"], data () { @@ -37,7 +37,7 @@ export default { }, set (value) { this.$emit("update:modelValue", value); - } + }, }, colorLCH () { return this.color.to("oklch"); @@ -49,7 +49,7 @@ export default { let coords = this.color.to(space).coords.map(c => this.toPrecision(c, 3)); return { name: space.name, - coords: Object.fromEntries(coordInfo.map(([c, info], i) => [c, {value: coords[i], name: info.name, id: c}])) + coords: Object.fromEntries(coordInfo.map(([c, info], i) => [c, {value: coords[i], name: info.name, id: c}])), }; }); }, @@ -110,12 +110,12 @@ export default { deltaEs = deltaEs.map(e => this.toPrecision(e, 2)); deltaEs.sort((a, b) => a - b); return deltaEs; - } + }, }, methods: { toPrecision: Color.util.toPrecision, - abs: Math.abs + abs: Math.abs, }, watch: { @@ -194,5 +194,5 @@ export default { - ` + `, }; diff --git a/apps/gamut-mapping/methods.js b/apps/gamut-mapping/methods.js index 6a6159f14..441ec7a29 100644 --- a/apps/gamut-mapping/methods.js +++ b/apps/gamut-mapping/methods.js @@ -17,10 +17,10 @@ const methods = { let lch = color.to("oklch").coords; mappedColor.set({ "oklch.l": lch[0], - "oklch.h": lch[2] + "oklch.h": lch[2], }); return methods.scale.compute(mappedColor); - } + }, }, "scale": { label: "Scale", @@ -38,7 +38,7 @@ const methods = { }); return new Color("p3-linear", scaledCoords).to("p3"); - } + }, }, // "scale125": { // label: "Scale from 0.125", diff --git a/apps/picker/index.js b/apps/picker/index.js index b3ccf4b94..6365099ba 100644 --- a/apps/picker/index.js +++ b/apps/picker/index.js @@ -110,7 +110,7 @@ let app = createApp({ ret.push(steps); return ret; - } + }, }, watch: { spaceId (newSpaceId, oldSpaceId) { @@ -131,8 +131,8 @@ let app = createApp({ let {spaceId, coords, alpha} = this; localStorage.picker_color = JSON.stringify({spaceId, coords, alpha}); }); - } - } + }, + }, }).mount("#app"); window.CSS_color_to_LCH = function CSS_color_to_LCH (str) { diff --git a/assets/js/docs.js b/assets/js/docs.js index e61892b96..d870764a2 100644 --- a/assets/js/docs.js +++ b/assets/js/docs.js @@ -61,7 +61,7 @@ function makePageToc (pageToc) { } let a = $.create("a", { - href: "#" + h2.id + href: "#" + h2.id, }); // Linkify heading @@ -78,7 +78,7 @@ function makePageToc (pageToc) { $.create("li", { contents: toc_a, - inside: pageToc + inside: pageToc, }); }); } @@ -108,7 +108,7 @@ if (location.pathname.indexOf("/spaces") > -1) { id, name: meta.name, min: range?.[0], - max: range?.[1] + max: range?.[1], }; }), whitePoint: Object.entries(Color.WHITES).find(([name, white]) => white === space.white)?.[0], @@ -117,7 +117,7 @@ if (location.pathname.indexOf("/spaces") > -1) { }); Mavo.all.colorSpaces.load({ - data: {space: spaces} + data: {space: spaces}, }); Mavo.hooks.add("getdata-end", function (env) { diff --git a/assets/js/index.js b/assets/js/index.js index ac58f3419..179779402 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -12,7 +12,7 @@ let root_cs = getComputedStyle(root); let colors = { red: new Color(root_cs.getPropertyValue("--color-red")), green: new Color(root_cs.getPropertyValue("--color-green")), - blue: new Color(root_cs.getPropertyValue("--color-blue")) + blue: new Color(root_cs.getPropertyValue("--color-blue")), }; let supportsP3 = window.CSS && CSS.supports("color", "color(display-p3 0 1 0)"); @@ -27,7 +27,7 @@ if (!Color.DEBUGGING) { "gradient-steps": [ ...Color.steps(redGreen, interpolationOptions), ...Color.steps(greenBlue, interpolationOptions), - ...Color.steps(blueRed, interpolationOptions) + ...Color.steps(blueRed, interpolationOptions), ], "color-red-light": colors.red.clone().set({"lch.l": 80}), "color-green-light": colors.green.clone().set({"lch.l": 80}), @@ -51,7 +51,7 @@ if (!Color.DEBUGGING) { textContent: `:root { ${Object.entries(vars).map(pair => `--${pair[0]}: ${pair[1]}`).join(";\n")}; --scrolltop: ${root.scrollTop}; - }` + }`, }); } @@ -77,7 +77,7 @@ for (let code of $$(":not(pre) > code")) { if (match) { $.create("a", { href: `/api/#Color${match[1] === "Color" ? "." : "#"}${match[2]}`, - around: code + around: code, }); } } diff --git a/elements/css-color/css-color.js b/elements/css-color/css-color.js index 342a5962a..56e0014c6 100644 --- a/elements/css-color/css-color.js +++ b/elements/css-color/css-color.js @@ -91,8 +91,8 @@ export default class CSSColor extends HTMLElement { this.dispatchEvent(new CustomEvent("colorchange", { detail: { - color: this.#color - } + color: this.#color, + }, })); } diff --git a/notebook/color-notebook.js b/notebook/color-notebook.js index 16024baff..fd63a48a0 100644 --- a/notebook/color-notebook.js +++ b/notebook/color-notebook.js @@ -57,7 +57,7 @@ export default class Notebook { this.wrapper = $.create("div", { className: "cn-wrapper", around: this.pre, - contents: {className: "cn-results"} + contents: {className: "cn-results"}, }); // Create Prism Live instance if not already present @@ -89,7 +89,7 @@ export default class Notebook { `, // sandbox: "allow-scripts allow-same-origin", inside: document.body, - hidden: true + hidden: true, }); this.initialized = true; @@ -256,7 +256,7 @@ export default class Notebook { if (ret instanceof win.Error) { console.log( "Error during statement evaluation:", ret, - "Statement was:", lineCode + "Statement was:", lineCode, ); } else { @@ -291,7 +291,7 @@ export default class Notebook { className: "variable", "data-varname": name, "data-line": i, - around: text + around: text, }); try { @@ -428,15 +428,15 @@ export function serialize (ret, color, win = window) { className: "cn-error", textContent: ret.name, title: ret + ". Click to see error in the console.", - onclick: _ => console.error(ret) + onclick: _ => console.error(ret), }); } let template = { title: "Click to see value in the console", events: { - click: _ => console.log(ret) - } + click: _ => console.log(ret), + }, }; if (ret instanceof Color) { @@ -444,7 +444,7 @@ export function serialize (ret, color, win = window) { element = $.create({ ...template, - textContent: ret.toString({precision: 3, inGamut: false}) + textContent: ret.toString({precision: 3, inGamut: false}), }); flag = true; @@ -461,8 +461,8 @@ export function serialize (ret, color, win = window) { } return color; - }) - } + }), + }, }); } else if (Array.isArray(ret)) { @@ -484,28 +484,28 @@ export function serialize (ret, color, win = window) { return $.create({ ...template, className: "cn-value cn-array", - contents + contents, }); } else if (typeof ret === "number") { element = $.create({ ...template, className: "cn-number", - textContent: util.toPrecision(ret, 3) + "" + textContent: util.toPrecision(ret, 3) + "", }); } else if (typeof ret === "boolean") { element = $.create({ ...template, className: "cn-boolean", - textContent: ret + textContent: ret, }); } else if (util.isString(ret)) { element = $.create({ ...template, className: "cn-string", - textContent: `"${ret}"` + textContent: `"${ret}"`, }); } else if (ret && typeof ret === "object") { @@ -513,7 +513,7 @@ export function serialize (ret, color, win = window) { element = $.create({ ...template, className: "cn-object", - textContent: `Object {${keys.slice(0, 3).join(", ") + (keys.length > 3 ? ", ..." : "")}}` + textContent: `Object {${keys.slice(0, 3).join(", ") + (keys.length > 3 ? ", ..." : "")}}`, }); } @@ -545,11 +545,11 @@ export function serialize (ret, color, win = window) { $.set(element, { style: { - "--color": color.to(outputSpace) + "--color": color.to(outputSpace), }, properties: { - color - } + color, + }, }); } diff --git a/notebook/repl.js b/notebook/repl.js index 0f247f48d..2344e08b5 100644 --- a/notebook/repl.js +++ b/notebook/repl.js @@ -53,7 +53,7 @@ await Mavo.ready; for (let id in extensions) { showdown.extension(id, () => [ - extensions[id] + extensions[id], ]); } diff --git a/rollup.config.js b/rollup.config.js index 29cb0e58b..2b28e7152 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,7 +5,7 @@ const bundles = [ "file": "dist/color.global.js", "format": "iife", "sourcemap": true, - "name": "Color" + "name": "Color", }, { "file": "dist/color.js", @@ -49,7 +49,7 @@ export default [ if (warning.code !== "CIRCULAR_DEPENDENCY") { rollupWarn(warning); } - } + }, }, { input: "src/index-fn.js", @@ -58,6 +58,6 @@ export default [ if (warning.code !== "CIRCULAR_DEPENDENCY") { rollupWarn(warning); } - } + }, }, ]; diff --git a/rollup.legacy.config.js b/rollup.legacy.config.js index 69e2694b3..a05cc0797 100644 --- a/rollup.legacy.config.js +++ b/rollup.legacy.config.js @@ -16,6 +16,6 @@ export default defaultConfig.map(config => ...bundle, file: bundle.file.replace(/\.(?:min\.)?\w+$/, ".legacy$&"), })), - plugins: [...(config.plugins || []), ...legacyPlugins] - }) + plugins: [...(config.plugins || []), ...legacyPlugins], + }), ); diff --git a/scripts/cat-mat.js b/scripts/cat-mat.js index 6fb451dce..b43942459 100644 --- a/scripts/cat-mat.js +++ b/scripts/cat-mat.js @@ -8,25 +8,25 @@ const d65 = [0.3127 / 0.3290, 1.00000, (1.0 - 0.3127 - 0.3290) / 0.3290]; const bradford = [ [ 0.8951000, 0.2664000, -0.1614000 ], [ -0.7502000, 1.7135000, 0.0367000 ], - [ 0.0389000, -0.0685000, 1.0296000 ] + [ 0.0389000, -0.0685000, 1.0296000 ], ]; const von_kries = [ [ 0.4002400, 0.7076000, -0.0808100 ], [ -0.2263000, 1.1653200, 0.0457000 ], - [ 0.0000000, 0.0000000, 0.9182200 ] + [ 0.0000000, 0.0000000, 0.9182200 ], ]; const cat02 = [ [ 0.7328000, 0.4296000, -0.1624000 ], [ -0.7036000, 1.6975000, 0.0061000 ], - [ 0.0030000, 0.0136000, 0.9834000 ] + [ 0.0030000, 0.0136000, 0.9834000 ], ]; const cat16 = [ [ 0.401288, 0.650173, -0.051461 ], [ -0.250268, 1.204414, 0.045854 ], - [ -0.002079, 0.048952, 0.953127 ] + [ -0.002079, 0.048952, 0.953127 ], ]; console.log("===== bradford ====="); diff --git a/src/CATs.js b/src/CATs.js index e49656798..949b265ee 100644 --- a/src/CATs.js +++ b/src/CATs.js @@ -35,7 +35,7 @@ export function adapt (W1, W2, id = "Bradford") { let scale = [ [ρd / ρs, 0, 0 ], [0, γd / γs, 0 ], - [0, 0, βd / βs] + [0, 0, βd / βs], ]; // console.log({scale}); @@ -50,13 +50,13 @@ defineCAT({ toCone_M: [ [ 0.4002400, 0.7076000, -0.0808100 ], [ -0.2263000, 1.1653200, 0.0457000 ], - [ 0.0000000, 0.0000000, 0.9182200 ] + [ 0.0000000, 0.0000000, 0.9182200 ], ], fromCone_M: [ [ 1.8599363874558397, -1.1293816185800916, 0.21989740959619328 ], [ 0.3611914362417676, 0.6388124632850422, -0.000006370596838649899 ], - [ 0, 0, 1.0890636230968613 ] - ] + [ 0, 0, 1.0890636230968613 ], + ], }); defineCAT({ @@ -66,14 +66,14 @@ defineCAT({ toCone_M: [ [ 0.8951000, 0.2664000, -0.1614000 ], [ -0.7502000, 1.7135000, 0.0367000 ], - [ 0.0389000, -0.0685000, 1.0296000 ] + [ 0.0389000, -0.0685000, 1.0296000 ], ], // and back fromCone_M: [ [ 0.9869929054667121, -0.14705425642099013, 0.15996265166373122 ], [ 0.4323052697233945, 0.5183602715367774, 0.049291228212855594 ], - [ -0.00852866457517732, 0.04004282165408486, 0.96848669578755 ] - ] + [ -0.00852866457517732, 0.04004282165408486, 0.96848669578755 ], + ], }); defineCAT({ @@ -82,13 +82,13 @@ defineCAT({ toCone_M: [ [ 0.7328000, 0.4296000, -0.1624000 ], [ -0.7036000, 1.6975000, 0.0061000 ], - [ 0.0030000, 0.0136000, 0.9834000 ] + [ 0.0030000, 0.0136000, 0.9834000 ], ], fromCone_M: [ [ 1.0961238208355142, -0.27886900021828726, 0.18274517938277307 ], [ 0.4543690419753592, 0.4735331543074117, 0.07209780371722911 ], - [ -0.009627608738429355, -0.00569803121611342, 1.0153256399545427 ] - ] + [ -0.009627608738429355, -0.00569803121611342, 1.0153256399545427 ], + ], }); defineCAT({ @@ -96,14 +96,14 @@ defineCAT({ toCone_M: [ [ 0.401288, 0.650173, -0.051461 ], [ -0.250268, 1.204414, 0.045854 ], - [ -0.002079, 0.048952, 0.953127 ] + [ -0.002079, 0.048952, 0.953127 ], ], // the extra precision is needed to avoid roundtripping errors fromCone_M: [ [ 1.862067855087233, -1.0112546305316845, 0.14918677544445172 ], [ 0.3875265432361372, 0.6214474419314753, -0.008973985167612521 ], - [ -0.01584149884933386, -0.03412293802851557, 1.0499644368778496 ] - ] + [ -0.01584149884933386, -0.03412293802851557, 1.0499644368778496 ], + ], }); Object.assign(WHITES, { diff --git a/src/adapt.js b/src/adapt.js index 7a5cc8010..02555c31e 100644 --- a/src/adapt.js +++ b/src/adapt.js @@ -38,7 +38,7 @@ export default function adapt (W1, W2, XYZ, options = {}) { env.M = [ [ 1.0479297925449969, 0.022946870601609652, -0.05019226628920524 ], [ 0.02962780877005599, 0.9904344267538799, -0.017073799063418826 ], - [ -0.009243040646204504, 0.015055191490298152, 0.7518742814281371 ] + [ -0.009243040646204504, 0.015055191490298152, 0.7518742814281371 ], ]; } else if (env.W1 === WHITES.D50 && env.W2 === WHITES.D65) { @@ -46,7 +46,7 @@ export default function adapt (W1, W2, XYZ, options = {}) { env.M = [ [ 0.955473421488075, -0.02309845494876471, 0.06325924320057072 ], [ -0.0283697093338637, 1.0099953980813041, 0.021041441191917323 ], - [ 0.012314014864481998, -0.020507649298898964, 1.330365926242124 ] + [ 0.012314014864481998, -0.020507649298898964, 1.330365926242124 ], ]; } } diff --git a/src/chromaticity.js b/src/chromaticity.js index 64dd50b12..752fe5fdd 100644 --- a/src/chromaticity.js +++ b/src/chromaticity.js @@ -20,12 +20,12 @@ export function register (Color) { Object.defineProperty(Color.prototype, "uv", { get () { return uv(this); - } + }, }); Object.defineProperty(Color.prototype, "xy", { get () { return xy(this); - } + }, }); } diff --git a/src/clone.js b/src/clone.js index 6a0efce23..e866e3fec 100644 --- a/src/clone.js +++ b/src/clone.js @@ -2,6 +2,6 @@ export default function clone (color) { return { space: color.space, coords: color.coords.slice(), - alpha: color.alpha + alpha: color.alpha, }; } diff --git a/src/color.js b/src/color.js index 394b21c52..d78f6cf62 100644 --- a/src/color.js +++ b/src/color.js @@ -95,7 +95,7 @@ export default class Color { return { spaceId: this.spaceId, coords: this.coords, - alpha: this.alpha + alpha: this.alpha, }; } @@ -197,5 +197,5 @@ Object.assign(Color, { parse, // Global defaults one may want to configure - defaults + defaults, }); diff --git a/src/deltaE/index.js b/src/deltaE/index.js index b050917bf..9ee592765 100644 --- a/src/deltaE/index.js +++ b/src/deltaE/index.js @@ -13,7 +13,7 @@ export { deltaEJz, deltaEITP, deltaEOK, - deltaEHCT + deltaEHCT, }; export default { @@ -23,5 +23,5 @@ export default { deltaEJz, deltaEITP, deltaEOK, - deltaEHCT + deltaEHCT, }; diff --git a/src/interpolation.js b/src/interpolation.js index d7ce847de..e1f5c97a2 100644 --- a/src/interpolation.js +++ b/src/interpolation.js @@ -205,7 +205,7 @@ export function range (color1, color2, options = {}) { return ret; }, { - rangeArgs + rangeArgs, }); } diff --git a/src/keywords.js b/src/keywords.js index 1f38db9ce..27b895b81 100644 --- a/src/keywords.js +++ b/src/keywords.js @@ -154,5 +154,5 @@ export default { "white": [1, 1, 1], "whitesmoke": [245 / 255, 245 / 255, 245 / 255], "yellow": [1, 1, 0], - "yellowgreen": [154 / 255, 205 / 255, 50 / 255] + "yellowgreen": [154 / 255, 205 / 255, 50 / 255], }; diff --git a/src/luminance.js b/src/luminance.js index 96eeaf94f..57133d988 100644 --- a/src/luminance.js +++ b/src/luminance.js @@ -20,6 +20,6 @@ export function register (Color) { }, set (value) { setLuminance(this, value); - } + }, }); } diff --git a/src/parse.js b/src/parse.js index 88a37d9cf..b6e3e9368 100644 --- a/src/parse.js +++ b/src/parse.js @@ -146,7 +146,7 @@ export default function parse (str, {meta} = {}) { return { spaceId: space.id, - coords, alpha + coords, alpha, }; } } diff --git a/src/rgbspace.js b/src/rgbspace.js index 200ad5150..f94e6b91d 100644 --- a/src/rgbspace.js +++ b/src/rgbspace.js @@ -22,16 +22,16 @@ export default class RGBColorSpace extends ColorSpace { options.coords = { r: { range: [0, 1], - name: "Red" + name: "Red", }, g: { range: [0, 1], - name: "Green" + name: "Green", }, b: { range: [0, 1], - name: "Blue" - } + name: "Blue", + }, }; } diff --git a/src/space-accessors.js b/src/space-accessors.js index 4302458e4..e7b5b66ca 100644 --- a/src/space-accessors.js +++ b/src/space-accessors.js @@ -81,6 +81,6 @@ function addSpaceAccessors (id, space) { this.setAll(id, coords); }, configurable: true, - enumerable: true + enumerable: true, }); } diff --git a/src/spaces/a98rgb-linear.js b/src/spaces/a98rgb-linear.js index 8eacd51dc..4d2279188 100644 --- a/src/spaces/a98rgb-linear.js +++ b/src/spaces/a98rgb-linear.js @@ -9,13 +9,13 @@ import RGBColorSpace from "../rgbspace.js"; const toXYZ_M = [ [ 0.5766690429101305, 0.1855582379065463, 0.1882286462349947 ], [ 0.29734497525053605, 0.6273635662554661, 0.07529145849399788 ], - [ 0.02703136138641234, 0.07068885253582723, 0.9913375368376388 ] + [ 0.02703136138641234, 0.07068885253582723, 0.9913375368376388 ], ]; const fromXYZ_M = [ [ 2.0415879038107465, -0.5650069742788596, -0.34473135077832956 ], [ -0.9692436362808795, 1.8759675015077202, 0.04155505740717557 ], - [ 0.013444280632031142, -0.11836239223101838, 1.0151749943912054 ] + [ 0.013444280632031142, -0.11836239223101838, 1.0151749943912054 ], ]; export default new RGBColorSpace({ @@ -23,5 +23,5 @@ export default new RGBColorSpace({ name: "Linear Adobe® 98 RGB compatible", white: "D65", toXYZ_M, - fromXYZ_M + fromXYZ_M, }); diff --git a/src/spaces/a98rgb.js b/src/spaces/a98rgb.js index b742619ce..55675e121 100644 --- a/src/spaces/a98rgb.js +++ b/src/spaces/a98rgb.js @@ -9,7 +9,7 @@ export default new RGBColorSpace({ fromBase: RGB => RGB.map(val => Math.pow(Math.abs(val), 256 / 563) * Math.sign(val)), formats: { color: { - id: "a98-rgb" - } + id: "a98-rgb", + }, }, }); diff --git a/src/spaces/acescc.js b/src/spaces/acescc.js index 07dd0b8dc..fd541040b 100644 --- a/src/spaces/acescc.js +++ b/src/spaces/acescc.js @@ -25,16 +25,16 @@ export default new RGBColorSpace({ coords: { r: { range: [ACES_min_nonzero, ACES_cc_max], - name: "Red" + name: "Red", }, g: { range: [ACES_min_nonzero, ACES_cc_max], - name: "Green" + name: "Green", }, b: { range: [ACES_min_nonzero, ACES_cc_max], - name: "Blue" - } + name: "Blue", + }, }, referred: "scene", @@ -73,6 +73,6 @@ export default new RGBColorSpace({ // encoded media white (rgb 1,1,1) => linear [ 222.861, 222.861, 222.861 ] // encoded media black (rgb 0,0,0) => linear [ 0.0011857, 0.0011857, 0.0011857] formats: { - color: {} - } + color: {}, + }, }); diff --git a/src/spaces/acescg.js b/src/spaces/acescg.js index 6d2d39702..d1fd88810 100644 --- a/src/spaces/acescg.js +++ b/src/spaces/acescg.js @@ -12,12 +12,12 @@ WHITES.ACES = [0.32168 / 0.33767, 1.00000, (1.00000 - 0.32168 - 0.33767) / 0.337 const toXYZ_M = [ [ 0.6624541811085053, 0.13400420645643313, 0.1561876870049078 ], [ 0.27222871678091454, 0.6740817658111484, 0.05368951740793705 ], - [ -0.005574649490394108, 0.004060733528982826, 1.0103391003129971 ] + [ -0.005574649490394108, 0.004060733528982826, 1.0103391003129971 ], ]; const fromXYZ_M = [ [ 1.6410233796943257, -0.32480329418479, -0.23642469523761225 ], [ -0.6636628587229829, 1.6153315916573379, 0.016756347685530137 ], - [ 0.011721894328375376, -0.008284441996237409, 0.9883948585390215 ] + [ 0.011721894328375376, -0.008284441996237409, 0.9883948585390215 ], ]; export default new RGBColorSpace({ @@ -30,16 +30,16 @@ export default new RGBColorSpace({ coords: { r: { range: [0, 65504], - name: "Red" + name: "Red", }, g: { range: [0, 65504], - name: "Green" + name: "Green", }, b: { range: [0, 65504], - name: "Blue" - } + name: "Blue", + }, }, referred: "scene", @@ -50,7 +50,7 @@ export default new RGBColorSpace({ fromXYZ_M, formats: { - color: {} + color: {}, }, }); diff --git a/src/spaces/cam16.js b/src/spaces/cam16.js index 2eb461db0..108122c81 100644 --- a/src/spaces/cam16.js +++ b/src/spaces/cam16.js @@ -12,32 +12,32 @@ const tau = 2 * Math.PI; const cat16 = [ [ 0.401288, 0.650173, -0.051461 ], [ -0.250268, 1.204414, 0.045854 ], - [ -0.002079, 0.048952, 0.953127 ] + [ -0.002079, 0.048952, 0.953127 ], ]; const cat16Inv = [ [1.8620678550872327, -1.0112546305316843, 0.14918677544445175], [0.38752654323613717, 0.6214474419314753, -0.008973985167612518], - [-0.015841498849333856, -0.03412293802851557, 1.0499644368778496] + [-0.015841498849333856, -0.03412293802851557, 1.0499644368778496], ]; const m1 = [ [460.0, 451.0, 288.0], [460.0, -891.0, -261.0], - [460.0, -220.0, -6300.0] + [460.0, -220.0, -6300.0], ]; const surroundMap = { dark: [0.8, 0.525, 0.8], dim: [0.9, 0.59, 0.9], - average: [1, 0.69, 1] + average: [1, 0.69, 1], }; const hueQuadMap = { // Red, Yellow, Green, Blue, Red h: [20.14, 90.00, 164.25, 237.53, 380.14], e: [0.8, 0.7, 1.0, 1.2, 0.8], - H: [0.0, 100.0, 200.0, 300.0, 400.0] + H: [0.0, 100.0, 200.0, 300.0, 400.0], }; const rad2deg = 180 / Math.PI; @@ -83,7 +83,7 @@ export function invHueQuadrature (H) { return constrain( (Hp * (eii * hi - ei * hii) - 100 * hi * eii) / - (Hp * (eii - ei) - 100 * eii) + (Hp * (eii - ei) - 100 * eii), ); } @@ -92,7 +92,7 @@ export function environment ( adaptingLuminance, backgroundLuminance, surround, - discounting + discounting, ) { const env = {}; @@ -138,7 +138,7 @@ export function environment ( 1 : Math.max( Math.min(f * (1 - 1 / 3.6 * Math.exp((-env.la - 42) / 92)), 1), - 0 + 0, ); env.dRgb = rgbW.map(c => { return interpolate(1, yw / c, d); @@ -164,7 +164,7 @@ const viewingConditions = environment( white, 64 / Math.PI * 0.2, 20, "average", - false + false, ); export function fromCam16 (cam16, env) { @@ -223,7 +223,7 @@ export function fromCam16 (cam16, env) { } const t = spow( alpha * Math.pow(1.64 - Math.pow(0.29, env.n), -0.73), - 10 / 9 + 10 / 9, ); // Eccentricity @@ -247,13 +247,13 @@ export function fromCam16 (cam16, env) { multiplyMatrices(m1, [p2, a, b]).map(c => { return c * 1 / 1403; }), - env.fl + env.fl, ); return multiplyMatrices( cat16Inv, rgb_c.map((c, i) => { return c * env.dRgbInv[i]; - }) + }), ).map(c => { return c / 100; }); @@ -269,7 +269,7 @@ export function toCam16 (xyzd65, env) { multiplyMatrices(cat16, xyz100).map((c, i) => { return c * env.dRgb[i]; }), - env.fl + env.fl, ); // Calculate hue from red-green and yellow-blue components @@ -284,7 +284,7 @@ export function toCam16 (xyzd65, env) { 5e4 / 13 * env.nc * env.ncb * zdiv( et * Math.sqrt(a ** 2 + b ** 2), - rgbA[0] + rgbA[1] + 1.05 * rgbA[2] + 0.305 + rgbA[0] + rgbA[1] + 1.05 * rgbA[2] + 0.305, ) ); const alpha = spow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, env.n), 0.73); @@ -343,7 +343,7 @@ export default new ColorSpace({ refRange: [0, 360], type: "angle", name: "Hue", - } + }, }, base: xyz_d65, @@ -355,12 +355,12 @@ export default new ColorSpace({ toBase (cam16) { return fromCam16( {J: cam16[0], M: cam16[1], h: cam16[2]}, - viewingConditions + viewingConditions, ); }, formats: { color: { - id: "--cam16-jmh" + id: "--cam16-jmh", }, }, }); diff --git a/src/spaces/hct.js b/src/spaces/hct.js index b4c4fe45f..fecd20890 100644 --- a/src/spaces/hct.js +++ b/src/spaces/hct.js @@ -109,7 +109,7 @@ export const viewingConditions = environment( white, 200 / Math.PI * fromLstar(50.0), fromLstar(50.0) * 100, "average", - false + false, ); // https://material.io/blog/science-of-color-design @@ -137,7 +137,7 @@ export default new ColorSpace({ t: { refRange: [0, 100], name: "Tone", - } + }, }, base: xyz_d65, @@ -151,7 +151,7 @@ export default new ColorSpace({ formats: { color: { id: "--hct", - coords: [" | ", " | ", " | "] + coords: [" | ", " | ", " | "], }, }, }); diff --git a/src/spaces/hpluv.js b/src/spaces/hpluv.js index c3416a945..3b00a8559 100644 --- a/src/spaces/hpluv.js +++ b/src/spaces/hpluv.js @@ -63,16 +63,16 @@ export default new ColorSpace({ h: { refRange: [0, 360], type: "angle", - name: "Hue" + name: "Hue", }, s: { range: [0, 100], - name: "Saturation" + name: "Saturation", }, l: { range: [0, 100], - name: "Lightness" - } + name: "Lightness", + }, }, base: LCHuv, @@ -124,7 +124,7 @@ export default new ColorSpace({ formats: { color: { id: "--hpluv", - coords: [" | ", " | ", " | "] - } + coords: [" | ", " | ", " | "], + }, }, }); diff --git a/src/spaces/hsl.js b/src/spaces/hsl.js index f61237322..5989009eb 100644 --- a/src/spaces/hsl.js +++ b/src/spaces/hsl.js @@ -8,16 +8,16 @@ export default new ColorSpace({ h: { refRange: [0, 360], type: "angle", - name: "Hue" + name: "Hue", }, s: { range: [0, 100], - name: "Saturation" + name: "Saturation", }, l: { range: [0, 100], - name: "Lightness" - } + name: "Lightness", + }, }, base: sRGB, @@ -86,6 +86,6 @@ export default new ColorSpace({ coords: [" | ", "", ""], commas: true, lastAlpha: true, - } + }, }, }); diff --git a/src/spaces/hsluv.js b/src/spaces/hsluv.js index 14e171f9c..0baedb8cb 100644 --- a/src/spaces/hsluv.js +++ b/src/spaces/hsluv.js @@ -71,7 +71,7 @@ export function calculateBoundingLines (l) { b0s: s1b / s3b, b0i: s2b * l / s3b, b1s: s1b / (s3b + 126452), - b1i: (s2b - 769860) * l / (s3b + 126452) + b1i: (s2b - 769860) * l / (s3b + 126452), }; } @@ -94,16 +94,16 @@ export default new ColorSpace({ h: { refRange: [0, 360], type: "angle", - name: "Hue" + name: "Hue", }, s: { range: [0, 100], - name: "Saturation" + name: "Saturation", }, l: { range: [0, 100], - name: "Lightness" - } + name: "Lightness", + }, }, base: LCHuv, @@ -156,7 +156,7 @@ export default new ColorSpace({ formats: { color: { id: "--hsluv", - coords: [" | ", " | ", " | "] - } + coords: [" | ", " | ", " | "], + }, }, }); diff --git a/src/spaces/hsv.js b/src/spaces/hsv.js index af348b139..8fc3f1c3a 100644 --- a/src/spaces/hsv.js +++ b/src/spaces/hsv.js @@ -13,16 +13,16 @@ export default new ColorSpace({ h: { refRange: [0, 360], type: "angle", - name: "Hue" + name: "Hue", }, s: { range: [0, 100], - name: "Saturation" + name: "Saturation", }, v: { range: [0, 100], - name: "Value" - } + name: "Value", + }, }, base: HSL, @@ -37,7 +37,7 @@ export default new ColorSpace({ return [ h, // h is the same v === 0 ? 0 : 200 * (1 - l / v), // s - 100 * v + 100 * v, ]; }, // https://en.wikipedia.org/wiki/HSL_and_HSV#Interconversion @@ -52,14 +52,14 @@ export default new ColorSpace({ return [ h, // h is the same (l === 0 || l === 1) ? 0 : ((v - l) / Math.min(l, 1 - l)) * 100, - l * 100 + l * 100, ]; }, formats: { color: { id: "--hsv", - coords: [" | ", " | ", " | "] - } - } + coords: [" | ", " | ", " | "], + }, + }, }); diff --git a/src/spaces/hwb.js b/src/spaces/hwb.js index b97c52290..4d94072cd 100644 --- a/src/spaces/hwb.js +++ b/src/spaces/hwb.js @@ -13,16 +13,16 @@ export default new ColorSpace({ h: { refRange: [0, 360], type: "angle", - name: "Hue" + name: "Hue", }, w: { range: [0, 100], - name: "Whiteness" + name: "Whiteness", }, b: { range: [0, 100], - name: "Blackness" - } + name: "Blackness", + }, }, base: HSV, @@ -53,6 +53,6 @@ export default new ColorSpace({ formats: { "hwb": { coords: [" | ", "", ""], - } - } + }, + }, }); diff --git a/src/spaces/ictcp.js b/src/spaces/ictcp.js index 0a98528c3..9d8408545 100644 --- a/src/spaces/ictcp.js +++ b/src/spaces/ictcp.js @@ -15,7 +15,7 @@ const im2 = 32 / 2523; const XYZtoLMS_M = [ [ 0.3592832590121217, 0.6976051147779502, -0.0358915932320290 ], [ -0.1920808463704993, 1.1004767970374321, 0.0753748658519118 ], - [ 0.0070797844607479, 0.0748396662186362, 0.8433265453898765 ] + [ 0.0070797844607479, 0.0748396662186362, 0.8433265453898765 ], ]; // linear-light Rec.2020 to LMS, again with crosstalk // rational terms from Jan Fröhlich, @@ -35,14 +35,14 @@ const Rec2020toLMS_M = [ const LMStoIPT_M = [ [ 2048 / 4096, 2048 / 4096, 0 ], [ 6610 / 4096, -13613 / 4096, 7003 / 4096 ], - [ 17933 / 4096, -17390 / 4096, -543 / 4096 ] + [ 17933 / 4096, -17390 / 4096, -543 / 4096 ], ]; // inverted matrices, calculated from the above const IPTtoLMS_M = [ [ 0.9999999999999998, 0.0086090370379328, 0.1110296250030260 ], [ 0.9999999999999998, -0.0086090370379328, -0.1110296250030259 ], - [ 0.9999999999999998, 0.5600313357106791, -0.3206271749873188 ] + [ 0.9999999999999998, 0.5600313357106791, -0.3206271749873188 ], ]; /* const LMStoRec2020_M = [ @@ -54,7 +54,7 @@ const LMStoRec2020_M = [ const LMStoXYZ_M = [ [ 2.0701522183894223, -1.3263473389671563, 0.2066510476294053 ], [ 0.3647385209748072, 0.6805660249472273, -0.0453045459220347 ], - [ -0.0497472075358123, -0.0492609666966131, 1.1880659249923042 ] + [ -0.0497472075358123, -0.0492609666966131, 1.1880659249923042 ], ]; // Only the PQ form of ICtCp is implemented here. There is also an HLG form. @@ -79,16 +79,16 @@ export default new ColorSpace({ coords: { i: { refRange: [0, 1], // Constant luminance, - name: "I" + name: "I", }, ct: { refRange: [-0.5, 0.5], // Full BT.2020 gamut in range [-0.5, 0.5] - name: "CT" + name: "CT", }, cp: { refRange: [-0.5, 0.5], - name: "CP" - } + name: "CP", + }, }, base: XYZ_Abs_D65, @@ -104,7 +104,7 @@ export default new ColorSpace({ return multiplyMatrices(LMStoXYZ_M, LMS); }, formats: { - color: {} + color: {}, }, }); diff --git a/src/spaces/jzazbz.js b/src/spaces/jzazbz.js index dcb908fa9..8ff418802 100644 --- a/src/spaces/jzazbz.js +++ b/src/spaces/jzazbz.js @@ -17,24 +17,24 @@ const d0 = 1.6295499532821566E-11; const XYZtoCone_M = [ [ 0.41478972, 0.579999, 0.0146480 ], [ -0.2015100, 1.120649, 0.0531008 ], - [ -0.0166008, 0.264800, 0.6684799 ] + [ -0.0166008, 0.264800, 0.6684799 ], ]; // XYZtoCone_M inverted const ConetoXYZ_M = [ [ 1.9242264357876067, -1.0047923125953657, 0.037651404030618 ], [ 0.35031676209499907, 0.7264811939316552, -0.06538442294808501 ], - [ -0.09098281098284752, -0.3127282905230739, 1.5227665613052603 ] + [ -0.09098281098284752, -0.3127282905230739, 1.5227665613052603 ], ]; const ConetoIab_M = [ [ 0.5, 0.5, 0 ], [ 3.524000, -4.066708, 0.542708 ], - [ 0.199076, 1.096799, -1.295875 ] + [ 0.199076, 1.096799, -1.295875 ], ]; // ConetoIab_M inverted const IabtoCone_M = [ [ 1, 0.1386050432715393, 0.05804731615611886 ], [ 0.9999999999999999, -0.1386050432715393, -0.05804731615611886 ], - [ 0.9999999999999998, -0.09601924202631895, -0.8118918960560388 ] + [ 0.9999999999999998, -0.09601924202631895, -0.8118918960560388 ], ]; export default new ColorSpace({ @@ -50,7 +50,7 @@ export default new ColorSpace({ }, bz: { refRange: [-0.5, 0.5], - } + }, }, base: XYZ_Abs_D65, @@ -113,6 +113,6 @@ export default new ColorSpace({ // https://drafts.csswg.org/css-color-hdr/#Jzazbz "color": { coords: [" | ", " | [-1,1]", " | [-1,1]"], - } - } + }, + }, }); diff --git a/src/spaces/jzczhz.js b/src/spaces/jzczhz.js index 942971bc7..92edb21f9 100644 --- a/src/spaces/jzczhz.js +++ b/src/spaces/jzczhz.js @@ -18,7 +18,7 @@ export default new ColorSpace({ refRange: [0, 360], type: "angle", name: "Hue", - } + }, }, base: Jzazbz, @@ -38,7 +38,7 @@ export default new ColorSpace({ return [ Jz, // Jz is still Jz Math.sqrt(az ** 2 + bz ** 2), // Chroma - constrainAngle(hue) // Hue, in degrees [0 to 360) + constrainAngle(hue), // Hue, in degrees [0 to 360) ]; }, toBase (jzczhz) { @@ -47,10 +47,10 @@ export default new ColorSpace({ return [ jzczhz[0], // Jz is still Jz jzczhz[1] * Math.cos(jzczhz[2] * Math.PI / 180), // az - jzczhz[1] * Math.sin(jzczhz[2] * Math.PI / 180) // bz + jzczhz[1] * Math.sin(jzczhz[2] * Math.PI / 180), // bz ]; }, formats: { - color: {} + color: {}, }, }); diff --git a/src/spaces/lab-d65.js b/src/spaces/lab-d65.js index c8bf58ca2..7ff9e47e9 100644 --- a/src/spaces/lab-d65.js +++ b/src/spaces/lab-d65.js @@ -15,14 +15,14 @@ export default new ColorSpace({ coords: { l: { refRange: [0, 100], - name: "Lightness" + name: "Lightness", }, a: { - refRange: [-125, 125] + refRange: [-125, 125], }, b: { - refRange: [-125, 125] - } + refRange: [-125, 125], + }, }, // Assuming XYZ is relative to D65, convert to CIE Lab @@ -42,7 +42,7 @@ export default new ColorSpace({ return [ (116 * f[1]) - 16, // L 500 * (f[0] - f[1]), // a - 200 * (f[1] - f[2]) // b + 200 * (f[1] - f[2]), // b ]; }, // Convert Lab to D65-adapted XYZ @@ -59,7 +59,7 @@ export default new ColorSpace({ let xyz = [ f[0] > ε3 ? Math.pow(f[0], 3) : (116 * f[0] - 16) / κ, Lab[0] > 8 ? Math.pow((Lab[0] + 16) / 116, 3) : Lab[0] / κ, - f[2] > ε3 ? Math.pow(f[2], 3) : (116 * f[2] - 16) / κ + f[2] > ε3 ? Math.pow(f[2], 3) : (116 * f[2] - 16) / κ, ]; // Compute XYZ by scaling xyz by reference white @@ -69,6 +69,6 @@ export default new ColorSpace({ formats: { "lab-d65": { coords: [" | ", " | [-1,1]", " | [-1,1]"], - } - } + }, + }, }); diff --git a/src/spaces/lab.js b/src/spaces/lab.js index d9e24f140..55d944e81 100644 --- a/src/spaces/lab.js +++ b/src/spaces/lab.js @@ -15,14 +15,14 @@ export default new ColorSpace({ coords: { l: { refRange: [0, 100], - name: "Lightness" + name: "Lightness", }, a: { - refRange: [-125, 125] + refRange: [-125, 125], }, b: { - refRange: [-125, 125] - } + refRange: [-125, 125], + }, }, // Assuming XYZ is relative to D50, convert to CIE Lab @@ -42,7 +42,7 @@ export default new ColorSpace({ return [ (116 * f[1]) - 16, // L 500 * (f[0] - f[1]), // a - 200 * (f[1] - f[2]) // b + 200 * (f[1] - f[2]), // b ]; }, // Convert Lab to D50-adapted XYZ @@ -59,7 +59,7 @@ export default new ColorSpace({ let xyz = [ f[0] > ε3 ? Math.pow(f[0], 3) : (116 * f[0] - 16) / κ, Lab[0] > 8 ? Math.pow((Lab[0] + 16) / 116, 3) : Lab[0] / κ, - f[2] > ε3 ? Math.pow(f[2], 3) : (116 * f[2] - 16) / κ + f[2] > ε3 ? Math.pow(f[2], 3) : (116 * f[2] - 16) / κ, ]; // Compute XYZ by scaling xyz by reference white @@ -69,6 +69,6 @@ export default new ColorSpace({ formats: { "lab": { coords: [" | ", " | [-1,1]", " | [-1,1]"], - } - } + }, + }, }); diff --git a/src/spaces/lch.js b/src/spaces/lch.js index 66aa5a6ba..0fe24e134 100644 --- a/src/spaces/lch.js +++ b/src/spaces/lch.js @@ -8,17 +8,17 @@ export default new ColorSpace({ coords: { l: { refRange: [0, 100], - name: "Lightness" + name: "Lightness", }, c: { refRange: [0, 150], - name: "Chroma" + name: "Chroma", }, h: { refRange: [0, 360], type: "angle", - name: "Hue" - } + name: "Hue", + }, }, base: Lab, @@ -38,7 +38,7 @@ export default new ColorSpace({ return [ L, // L is still L Math.sqrt(a ** 2 + b ** 2), // Chroma - constrainAngle(hue) // Hue, in degrees [0 to 360) + constrainAngle(hue), // Hue, in degrees [0 to 360) ]; }, toBase (LCH) { @@ -55,13 +55,13 @@ export default new ColorSpace({ return [ Lightness, // L is still L Chroma * Math.cos(Hue * Math.PI / 180), // a - Chroma * Math.sin(Hue * Math.PI / 180) // b + Chroma * Math.sin(Hue * Math.PI / 180), // b ]; }, formats: { "lch": { coords: [" | ", " | ", " | "], - } - } + }, + }, }); diff --git a/src/spaces/lchuv.js b/src/spaces/lchuv.js index aa22d6d78..d26432e7b 100644 --- a/src/spaces/lchuv.js +++ b/src/spaces/lchuv.js @@ -8,17 +8,17 @@ export default new ColorSpace({ coords: { l: { refRange: [0, 100], - name: "Lightness" + name: "Lightness", }, c: { refRange: [0, 220], - name: "Chroma" + name: "Chroma", }, h: { refRange: [0, 360], type: "angle", - name: "Hue" - } + name: "Hue", + }, }, base: Luv, @@ -38,7 +38,7 @@ export default new ColorSpace({ return [ L, // L is still L Math.sqrt(u ** 2 + v ** 2), // Chroma - constrainAngle(hue) // Hue, in degrees [0 to 360) + constrainAngle(hue), // Hue, in degrees [0 to 360) ]; }, toBase (LCH) { @@ -55,7 +55,7 @@ export default new ColorSpace({ return [ Lightness, // L is still L Chroma * Math.cos(Hue * Math.PI / 180), // u - Chroma * Math.sin(Hue * Math.PI / 180) // v + Chroma * Math.sin(Hue * Math.PI / 180), // v ]; }, @@ -63,6 +63,6 @@ export default new ColorSpace({ color: { id: "--lchuv", coords: [" | ", " | ", " | "], - } - } + }, + }, }); diff --git a/src/spaces/luv.js b/src/spaces/luv.js index ae7f102d6..e847a55c3 100644 --- a/src/spaces/luv.js +++ b/src/spaces/luv.js @@ -16,15 +16,15 @@ export default new ColorSpace({ coords: { l: { refRange: [0, 100], - name: "Lightness" + name: "Lightness", }, // Reference ranges from https://facelessuser.github.io/coloraide/colors/luv/ u: { - refRange: [-215, 215] + refRange: [-215, 215], }, v: { - refRange: [-215, 215] - } + refRange: [-215, 215], + }, }, white: white, @@ -47,7 +47,7 @@ export default new ColorSpace({ return [ L, 13 * L * (up - U_PRIME_WHITE), - 13 * L * (vp - V_PRIME_WHITE) + 13 * L * (vp - V_PRIME_WHITE), ]; }, @@ -72,14 +72,14 @@ export default new ColorSpace({ return [ y * ((9 * up) / (4 * vp)), y, - y * ((12 - 3 * up - 20 * vp) / (4 * vp)) + y * ((12 - 3 * up - 20 * vp) / (4 * vp)), ]; }, formats: { color: { id: "--luv", - coords: [" | ", " | [-1,1]", " | [-1,1]"] - } + coords: [" | ", " | [-1,1]", " | [-1,1]"], + }, }, }); diff --git a/src/spaces/oklab.js b/src/spaces/oklab.js index 25be38ff1..15882150b 100644 --- a/src/spaces/oklab.js +++ b/src/spaces/oklab.js @@ -7,24 +7,24 @@ import XYZ_D65 from "./xyz-d65.js"; const XYZtoLMS_M = [ [ 0.8190224379967030, 0.3619062600528904, -0.1288737815209879 ], [ 0.0329836539323885, 0.9292868615863434, 0.0361446663506424 ], - [ 0.0481771893596242, 0.2642395317527308, 0.6335478284694309 ] + [ 0.0481771893596242, 0.2642395317527308, 0.6335478284694309 ], ]; // inverse of XYZtoLMS_M const LMStoXYZ_M = [ [ 1.2268798758459243, -0.5578149944602171, 0.2813910456659647 ], [ -0.0405757452148008, 1.1122868032803170, -0.0717110580655164 ], - [ -0.0763729366746601, -0.4214933324022432, 1.5869240198367816 ] + [ -0.0763729366746601, -0.4214933324022432, 1.5869240198367816 ], ]; const LMStoLab_M = [ [ 0.2104542683093140, 0.7936177747023054, -0.0040720430116193 ], [ 1.9779985324311684, -2.4285922420485799, 0.4505937096174110 ], - [ 0.0259040424655478, 0.7827717124575296, -0.8086757549230774 ] + [ 0.0259040424655478, 0.7827717124575296, -0.8086757549230774 ], ]; // LMStoIab_M inverted const LabtoLMS_M = [ [ 1.0000000000000000, 0.3963377773761749, 0.2158037573099136 ], [ 1.0000000000000000, -0.1055613458156586, -0.0638541728258133 ], - [ 1.0000000000000000, -0.0894841775298119, -1.2914855480194092 ] + [ 1.0000000000000000, -0.0894841775298119, -1.2914855480194092 ], ]; export default new ColorSpace({ @@ -33,14 +33,14 @@ export default new ColorSpace({ coords: { l: { refRange: [0, 1], - name: "Lightness" + name: "Lightness", }, a: { - refRange: [-0.4, 0.4] + refRange: [-0.4, 0.4], }, b: { - refRange: [-0.4, 0.4] - } + refRange: [-0.4, 0.4], + }, }, // Note that XYZ is relative to D65 @@ -69,6 +69,6 @@ export default new ColorSpace({ formats: { "oklab": { coords: [" | ", " | [-1,1]", " | [-1,1]"], - } - } + }, + }, }); diff --git a/src/spaces/oklch.js b/src/spaces/oklch.js index 00b7b97a7..884aef357 100644 --- a/src/spaces/oklch.js +++ b/src/spaces/oklch.js @@ -8,17 +8,17 @@ export default new ColorSpace({ coords: { l: { refRange: [0, 1], - name: "Lightness" + name: "Lightness", }, c: { refRange: [0, 0.4], - name: "Chroma" + name: "Chroma", }, h: { refRange: [0, 360], type: "angle", - name: "Hue" - } + name: "Hue", + }, }, white: "D65", @@ -39,7 +39,7 @@ export default new ColorSpace({ return [ L, // OKLab L is still L Math.sqrt(a ** 2 + b ** 2), // Chroma - constrainAngle(h) // Hue, in degrees [0 to 360) + constrainAngle(h), // Hue, in degrees [0 to 360) ]; }, // Convert from polar form @@ -63,6 +63,6 @@ export default new ColorSpace({ formats: { "oklch": { coords: [" | ", " | [0,1]", " | "], - } - } + }, + }, }); diff --git a/src/spaces/p3-linear.js b/src/spaces/p3-linear.js index da3667e60..0f1d5c709 100644 --- a/src/spaces/p3-linear.js +++ b/src/spaces/p3-linear.js @@ -3,13 +3,13 @@ import RGBColorSpace from "../rgbspace.js"; const toXYZ_M = [ [0.4865709486482162, 0.26566769316909306, 0.1982172852343625], [0.2289745640697488, 0.6917385218365064, 0.079286914093745], - [0.0000000000000000, 0.04511338185890264, 1.043944368900976] + [0.0000000000000000, 0.04511338185890264, 1.043944368900976], ]; const fromXYZ_M = [ [ 2.493496911941425, -0.9313836179191239, -0.40271078445071684], [-0.8294889695615747, 1.7626640603183463, 0.023624685841943577], - [ 0.03584583024378447, -0.07617238926804182, 0.9568845240076872] + [ 0.03584583024378447, -0.07617238926804182, 0.9568845240076872], ]; export default new RGBColorSpace({ @@ -17,5 +17,5 @@ export default new RGBColorSpace({ name: "Linear P3", white: "D65", toXYZ_M, - fromXYZ_M + fromXYZ_M, }); diff --git a/src/spaces/p3.js b/src/spaces/p3.js index c6adea5f3..68a875207 100644 --- a/src/spaces/p3.js +++ b/src/spaces/p3.js @@ -12,6 +12,6 @@ export default new RGBColorSpace({ formats: { color: { id: "display-p3", - } + }, }, }); diff --git a/src/spaces/prophoto-linear.js b/src/spaces/prophoto-linear.js index 35db73ba2..6f8b861ca 100644 --- a/src/spaces/prophoto-linear.js +++ b/src/spaces/prophoto-linear.js @@ -8,13 +8,13 @@ import XYZ_D50 from "./xyz-d50.js"; const toXYZ_M = [ [ 0.79776664490064230, 0.13518129740053308, 0.03134773412839220 ], [ 0.28807482881940130, 0.71183523424187300, 0.00008993693872564 ], - [ 0.00000000000000000, 0.00000000000000000, 0.82510460251046020 ] + [ 0.00000000000000000, 0.00000000000000000, 0.82510460251046020 ], ]; const fromXYZ_M = [ [ 1.34578688164715830, -0.25557208737979464, -0.05110186497554526 ], [ -0.54463070512490190, 1.50824774284514680, 0.02052744743642139 ], - [ 0.00000000000000000, 0.00000000000000000, 1.21196754563894520 ] + [ 0.00000000000000000, 0.00000000000000000, 1.21196754563894520 ], ]; export default new RGBColorSpace({ @@ -23,5 +23,5 @@ export default new RGBColorSpace({ white: "D50", base: XYZ_D50, toXYZ_M, - fromXYZ_M + fromXYZ_M, }); diff --git a/src/spaces/prophoto.js b/src/spaces/prophoto.js index 41e0669da..ed0c1f389 100644 --- a/src/spaces/prophoto.js +++ b/src/spaces/prophoto.js @@ -17,7 +17,7 @@ export default new RGBColorSpace({ }, formats: { color: { - id: "prophoto-rgb" - } + id: "prophoto-rgb", + }, }, }); diff --git a/src/spaces/rec2020-linear.js b/src/spaces/rec2020-linear.js index fc2b20de9..7a62fad37 100644 --- a/src/spaces/rec2020-linear.js +++ b/src/spaces/rec2020-linear.js @@ -7,14 +7,14 @@ import RGBColorSpace from "../rgbspace.js"; const toXYZ_M = [ [ 0.6369580483012914, 0.14461690358620832, 0.1688809751641721 ], [ 0.2627002120112671, 0.6779980715188708, 0.05930171646986196 ], - [ 0.000000000000000, 0.028072693049087428, 1.060985057710791 ] + [ 0.000000000000000, 0.028072693049087428, 1.060985057710791 ], ]; // from ITU-R BT.2124-0 Annex 2 p.3 const fromXYZ_M = [ [ 1.716651187971268, -0.355670783776392, -0.253366281373660 ], [ -0.666684351832489, 1.616481236634939, 0.0157685458139111 ], - [ 0.017639857445311, -0.042770613257809, 0.942103121235474 ] + [ 0.017639857445311, -0.042770613257809, 0.942103121235474 ], ]; export default new RGBColorSpace({ @@ -25,5 +25,5 @@ export default new RGBColorSpace({ fromXYZ_M, formats: { color: {}, - } + }, }); diff --git a/src/spaces/rec2020.js b/src/spaces/rec2020.js index 77e03aaae..cba63daba 100644 --- a/src/spaces/rec2020.js +++ b/src/spaces/rec2020.js @@ -30,5 +30,5 @@ export default new RGBColorSpace({ }, formats: { color: {}, - } + }, }); diff --git a/src/spaces/rec2100-hlg.js b/src/spaces/rec2100-hlg.js index a094f38cb..0747a730c 100644 --- a/src/spaces/rec2100-hlg.js +++ b/src/spaces/rec2100-hlg.js @@ -48,7 +48,7 @@ export default new RGBColorSpace({ }, formats: { color: { - id: "rec2100-hlg" + id: "rec2100-hlg", }, }, }); diff --git a/src/spaces/rec2100-pq.js b/src/spaces/rec2100-pq.js index f960e3bc4..beebd0357 100644 --- a/src/spaces/rec2100-pq.js +++ b/src/spaces/rec2100-pq.js @@ -35,7 +35,7 @@ export default new RGBColorSpace({ }, formats: { color: { - id: "rec2100-pq" + id: "rec2100-pq", }, }, }); diff --git a/src/spaces/srgb-linear.js b/src/spaces/srgb-linear.js index d2d2b8a71..12329fbb8 100644 --- a/src/spaces/srgb-linear.js +++ b/src/spaces/srgb-linear.js @@ -10,7 +10,7 @@ import RGBColorSpace from "../rgbspace.js"; const toXYZ_M = [ [ 0.41239079926595934, 0.357584339383878, 0.1804807884018343 ], [ 0.21263900587151027, 0.715168678767756, 0.07219231536073371 ], - [ 0.01933081871559182, 0.11919477979462598, 0.9505321522496607 ] + [ 0.01933081871559182, 0.11919477979462598, 0.9505321522496607 ], ]; // This matrix is the inverse of the above; @@ -18,7 +18,7 @@ const toXYZ_M = [ export const fromXYZ_M = [ [ 3.2409699419045226, -1.537383177570094, -0.4986107602930034 ], [ -0.9692436362808796, 1.8759675015077202, 0.04155505740717559 ], - [ 0.05563007969699366, -0.20397695888897652, 1.0569715142428786 ] + [ 0.05563007969699366, -0.20397695888897652, 1.0569715142428786 ], ]; export default new RGBColorSpace({ @@ -28,6 +28,6 @@ export default new RGBColorSpace({ toXYZ_M, fromXYZ_M, formats: { - color: {} + color: {}, }, }); diff --git a/src/spaces/srgb.js b/src/spaces/srgb.js index 7ff6d1cca..692abf0b4 100644 --- a/src/spaces/srgb.js +++ b/src/spaces/srgb.js @@ -58,7 +58,7 @@ export default new RGBColorSpace({ "rgba_number": { name: "rgba", commas: true, - coords: coordGrammarNumber + coords: coordGrammarNumber, }, "hex": { type: "custom", @@ -78,11 +78,11 @@ export default new RGBColorSpace({ return { spaceId: "srgb", coords: rgba.slice(0, 3), - alpha: rgba.slice(3)[0] + alpha: rgba.slice(3)[0], }; }, serialize: (coords, alpha, { - collapse = true // collapse to 3-4 digit hex when possible? + collapse = true, // collapse to 3-4 digit hex when possible? } = {}) => { if (alpha < 1) { coords.push(alpha); @@ -101,7 +101,7 @@ export default new RGBColorSpace({ }).join(""); return "#" + hex; - } + }, }, "keyword": { type: "custom", @@ -121,7 +121,7 @@ export default new RGBColorSpace({ if (ret.coords) { return ret; } - } + }, }, - } + }, }); diff --git a/src/spaces/xyz-abs-d65.js b/src/spaces/xyz-abs-d65.js index 73c93c867..ab5c7a332 100644 --- a/src/spaces/xyz-abs-d65.js +++ b/src/spaces/xyz-abs-d65.js @@ -22,7 +22,7 @@ export default new ColorSpace({ z: { refRange: [0, 10888.3], name: "Za", - } + }, }, base: XYZ_D65, @@ -35,5 +35,5 @@ export default new ColorSpace({ toBase (AbsXYZ) { // Convert to media-white relative XYZ return AbsXYZ.map(v => Math.max(v / Yw, 0)); - } + }, }); diff --git a/src/spaces/xyz-d50.js b/src/spaces/xyz-d50.js index 2051c38ea..44c8ba76b 100644 --- a/src/spaces/xyz-d50.js +++ b/src/spaces/xyz-d50.js @@ -10,6 +10,6 @@ export default new ColorSpace({ fromBase: coords => adapt(XYZ_D65.white, "D50", coords), toBase: coords => adapt("D50", XYZ_D65.white, coords), formats: { - color: {} + color: {}, }, }); diff --git a/src/spaces/xyz-d65.js b/src/spaces/xyz-d65.js index 909eed142..95b6ae025 100644 --- a/src/spaces/xyz-d65.js +++ b/src/spaces/xyz-d65.js @@ -12,7 +12,7 @@ export default new ColorSpace({ formats: { color: { ids: ["xyz-d65", "xyz"], - } + }, }, aliases: ["xyz"], }); diff --git a/src/toGamut.js b/src/toGamut.js index e2637715a..c78117fcf 100644 --- a/src/toGamut.js +++ b/src/toGamut.js @@ -32,13 +32,13 @@ const GMAPPRESET = { method: "hct.c", jnd: 2, deltaEMethod: "hct", - blackWhiteClamp: {} + blackWhiteClamp: {}, }, "hct-tonal": { method: "hct.c", jnd: 0, deltaEMethod: "hct", - blackWhiteClamp: { channel: "hct.t", min: 0, max: 100 } + blackWhiteClamp: { channel: "hct.t", min: 0, max: 100 }, }, }; @@ -69,8 +69,8 @@ export default function toGamut ( space = color.space, deltaEMethod = "", jnd = 2, - blackWhiteClamp = {} - } = {} + blackWhiteClamp = {}, + } = {}, ) { if (util.isString(arguments[1])) { space = arguments[1]; @@ -207,7 +207,7 @@ toGamut.returns = "color"; // DeltaEOK calculation, so it is guaranteed to be imported. const COLORS = { WHITE: { space: oklab, coords: [1, 0, 0] }, - BLACK: { space: oklab, coords: [0, 0, 0] } + BLACK: { space: oklab, coords: [0, 0, 0] }, }; /** diff --git a/src/util.js b/src/util.js index 434449638..f6cf47943 100644 --- a/src/util.js +++ b/src/util.js @@ -144,7 +144,7 @@ export function parseFunction (str) { rawArgs: parts[2], // An argument could be (as of css-color-4): // a number, percentage, degrees (hue), ident (in color()) - args + args, }; } } diff --git a/test/adapt.js b/test/adapt.js index a943bcdd9..2b1ac00c2 100644 --- a/test/adapt.js +++ b/test/adapt.js @@ -20,7 +20,7 @@ export default { expect: [ [ 0.955473421488075, -0.02309845494876471, 0.06325924320057072 ], [ -0.0283697093338637, 1.0099953980813041, 0.021041441191917323 ], - [ 0.012314014864481998, -0.020507649298898964, 1.330365926242124 ] + [ 0.012314014864481998, -0.020507649298898964, 1.330365926242124 ], ], }, { @@ -29,11 +29,11 @@ export default { expect: [ [ 1.0479297925449969, 0.022946870601609652, -0.05019226628920524 ], [ 0.02962780877005599, 0.9904344267538799, -0.017073799063418826 ], - [ -0.009243040646204504, 0.015055191490298152, 0.7518742814281371 ] + [ -0.009243040646204504, 0.015055191490298152, 0.7518742814281371 ], ], }, - ] - } + ], + }, // , // { // name: "Bradford Other whitepoints", @@ -158,5 +158,5 @@ export default { // } // ] // } - ] + ], }; diff --git a/test/angles.js b/test/angles.js index 956960c7c..36e2eb0c5 100644 --- a/test/angles.js +++ b/test/angles.js @@ -9,27 +9,27 @@ export default { tests: [ { args: [undefined, [-20, 380]], - expect: [340, 20] + expect: [340, 20], }, { args: ["increasing", [-20, 380]], - expect: [340, 380] + expect: [340, 380], }, { args: ["decreasing", [-20, 380]], - expect: [340, 20] + expect: [340, 20], }, { args: ["longer", [-20, 380]], - expect: [340, 20] + expect: [340, 20], }, { args: ["shorter", [-20, 380]], - expect: [340, 380] + expect: [340, 380], }, { args: ["raw", [-20, 380]], - expect: [-20, 380] + expect: [-20, 380], }, - ] + ], }; diff --git a/test/construct.js b/test/construct.js index f62128fce..08779d35c 100644 --- a/test/construct.js +++ b/test/construct.js @@ -26,50 +26,50 @@ export default { tests: [ { args: ["P3", [0, 1, 0]], - expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 1 } + expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 1 }, }, { args: ["rec2100pq", [0.34, 0.34, 0.34]], - expect: { "spaceId": "rec2100pq", "coords": [ 0.34, 0.34, 0.34 ], "alpha": 1 } - } - ] + expect: { "spaceId": "rec2100pq", "coords": [ 0.34, 0.34, 0.34 ], "alpha": 1 }, + }, + ], }, { name: "new Color(keyword)", args: ["red"], - expect: { "spaceId": "srgb", "coords": [ 1, 0, 0 ], "alpha": 1 } + expect: { "spaceId": "srgb", "coords": [ 1, 0, 0 ], "alpha": 1 }, }, { name: "new Color(hsl string)", args: ["hsl(10, 50%, 50%)"], - expect: { "spaceId": "hsl", "coords": [ 10, 50, 50 ], "alpha": 1 } + expect: { "spaceId": "hsl", "coords": [ 10, 50, 50 ], "alpha": 1 }, }, { name: "new Color(hsl string), none alpha", args: ["hsl(10, 50%, 50% / none)"], - expect: { "spaceId": "hsl", "coords": [ 10, 50, 50 ], "alpha": NaN } + expect: { "spaceId": "hsl", "coords": [ 10, 50, 50 ], "alpha": NaN }, }, { name: "new Color({spaceId, coords})", args: [{spaceId: "p3", coords: [0, 1, 0]}], - expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 1 } + expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 1 }, }, { name: "new Color({spaceId, coords, alpha})", args: [{spaceId: "p3", coords: [0, 1, 0], alpha: 0.5}], - expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 0.5 } + expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 0.5 }, }, { name: "new Color({spaceId, coords, alpha}), clamp alpha", args: [{spaceId: "p3", coords: [0, 1, 0], alpha: 1000}], - expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 1 } + expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": 1 }, }, { name: "new Color({spaceId, coords, alpha}), NaN alpha", args: [{spaceId: "p3", coords: [0, 1, 0], alpha: NaN}], - expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": NaN } + expect: { "spaceId": "p3", "coords": [ 0, 1, 0 ], "alpha": NaN }, }, - ] - } - ] + ], + }, + ], }; diff --git a/test/conversions.js b/test/conversions.js index 03d735474..f5cf610cc 100644 --- a/test/conversions.js +++ b/test/conversions.js @@ -18,32 +18,32 @@ const tests = { return checkProximity(actual, expect); }), data: { - epsilon: .0001 + epsilon: .0001, }, tests: [ { name: "sRGB to LCH", data: { - toSpace: "lch" + toSpace: "lch", }, tests: [ { args: "slategray", - expect: [52.69734985816035, 11.234156441150068, 253.00263766910288] + expect: [52.69734985816035, 11.234156441150068, 253.00263766910288], }, { args: "papayawhip", - expect: [95.22890204788412, 14.894161408435306, 80.18569512775224] + expect: [95.22890204788412, 14.894161408435306, 80.18569512775224], }, { args: "white", - expect: [100, 0, NaN] + expect: [100, 0, NaN], }, { args: "black", - expect: [0, 0, NaN] - } - ] + expect: [0, 0, NaN], + }, + ], }, { name: "sRGB to (D65) XYZ", @@ -53,9 +53,9 @@ const tests = { tests: [ { args: "white", - expect: [0.9504559270516717, 1, 1.0890577507598784] + expect: [0.9504559270516717, 1, 1.0890577507598784], }, - ] + ], }, { name: "HWB to sRGB", @@ -65,33 +65,33 @@ const tests = { tests: [ { args: "hwb(0 20% 40%)", - expect: [0.6, 0.2, 0.2] + expect: [0.6, 0.2, 0.2], }, { args: "hwb(90 30% 5%)", - expect: [0.625, 0.950, 0.300] + expect: [0.625, 0.950, 0.300], }, { args: "hwb(30 0% 80%)", - expect: [0.2, 0.1, 0] + expect: [0.2, 0.1, 0], }, { args: "hwb(720 20% 40%)", - expect: [0.6, 0.2, 0.2] + expect: [0.6, 0.2, 0.2], }, { args: "hwb(-270 30% 5%)", - expect: [0.625, 0.950, 0.300] + expect: [0.625, 0.950, 0.300], }, { args: "hwb(0 40% 80%)", - expect: [0.3333333, 0.3333333, 0.3333333] + expect: [0.3333333, 0.3333333, 0.3333333], }, { args: "hwb(0 50% 50%)", - expect: [0.5, 0.5, 0.5] + expect: [0.5, 0.5, 0.5], }, - ] + ], }, { name: "sRGB to HWB", @@ -101,34 +101,34 @@ const tests = { tests: [ { args: "rgb(60% 20% 20%)", - expect: [0, 20, 40] + expect: [0, 20, 40], }, { args: "black", - expect: [NaN, 0, 100] + expect: [NaN, 0, 100], }, { args: "white", - expect: [NaN, 100, 0] - } - ] + expect: [NaN, 100, 0], + }, + ], }, { name: "Out of sRGB gamut conversions", tests: [ { args: ["color(rec2020 0 0 1)", "hwb"], - expect: [230.63914728691736, -29.9212950204808, -5.0489461007690295] + expect: [230.63914728691736, -29.9212950204808, -5.0489461007690295], }, { args: ["color(rec2020 0 0 1)", "hsl"], - expect: [230.63914728691736, 179.65454686851365, 37.563825540144116] + expect: [230.63914728691736, 179.65454686851365, 37.563825540144116], }, { args: ["color(rec2020 0 0 1)", "hsv"], - expect: [230.63914728691736, 128.48319391208224, 105.04894610076903] - } - ] + expect: [230.63914728691736, 128.48319391208224, 105.04894610076903], + }, + ], }, { name: "sRGB to HSL", @@ -138,13 +138,13 @@ const tests = { tests: [ { args: "black", - expect: [NaN, 0, 0] + expect: [NaN, 0, 0], }, { args: "white", - expect: [NaN, 0, 100] - } - ] + expect: [NaN, 0, 100], + }, + ], }, { name: "P3 to sRGB", @@ -154,33 +154,33 @@ const tests = { tests: [ { args: "color(display-p3 0.47 0.47 0.47)", - expect: [0.47, 0.47, 0.47] + expect: [0.47, 0.47, 0.47], }, { args: "color(display-p3 1 1 1)", - expect: [1, 1, 1] + expect: [1, 1, 1], }, { args: "color(display-p3 -0.1 -0.1 -0.1)", - expect: [-0.1, -0.1, -0.1] + expect: [-0.1, -0.1, -0.1], }, { args: "color(display-p3 0.238 0.532 0.611)", - expect: [0.019595, 0.54027, 0.621351] + expect: [0.019595, 0.54027, 0.621351], }, { args: "color(display-p3 1 0 0)", - expect: [1.09299, -0.226745, -0.150155] + expect: [1.09299, -0.226745, -0.150155], }, { args: "color(display-p3 0 1 0)", - expect: [-0.511567, 1.018276, -0.310711] + expect: [-0.511567, 1.018276, -0.310711], }, { args: "color(display-p3 0 0 1)", - expect: [0, 0, 1.0420216193529395] - } - ] + expect: [0, 0, 1.0420216193529395], + }, + ], }, { name: "rec2100pq to XYZ and back", @@ -190,41 +190,41 @@ const tests = { tests: [ { args: ["color(rec2100-pq 0.3720 0.3720 0.3720)", "xyz-d65"], - expect: [0.11118, 0.11698, 0.12740] + expect: [0.11118, 0.11698, 0.12740], }, { args: "color(xyz 0.11118, 0.11698, 0.12740)", - expect: [0.3720, 0.3720, 0.3720] + expect: [0.3720, 0.3720, 0.3720], }, { args: "white", - expect: [0.5807, 0.5807, 0.5807] + expect: [0.5807, 0.5807, 0.5807], }, { args: "color(display-p3 1 0 0)", - expect: [0.5514, 0.2939, 0] + expect: [0.5514, 0.2939, 0], }, { args: "color(display-p3 0 1 0)", - expect: [0.4200, 0.5744, 0.2248] + expect: [0.4200, 0.5744, 0.2248], }, { args: "color(display-p3 0 0 1)", - expect: [0.2970, 0.2026, 0.5790] + expect: [0.2970, 0.2026, 0.5790], }, { args: "color(rec2020 1 0 0)", - expect: [0.5807, 0, 0] + expect: [0.5807, 0, 0], }, { args: "color(rec2020 0 1 0)", - expect: [0, 0.5807, 0] + expect: [0, 0.5807, 0], }, { args: "color(rec2020 0 0 1)", - expect: [0, 0, 0.5807] - } - ] + expect: [0, 0, 0.5807], + }, + ], }, { name: "Jzazbz", @@ -235,49 +235,49 @@ const tests = { tests: [ { args: ["color(jzazbz 0.5 0 0)", "xyz-d65"], - expect: [7.986957, 8.397692, 9.136922] + expect: [7.986957, 8.397692, 9.136922], }, { args: ["color(jzazbz 1 0 0)", "xyz-d65"], - expect: [48.187785, 50.665878, 55.125885] + expect: [48.187785, 50.665878, 55.125885], }, { args: ["color(jzazbz 0.1 -0.05 0.05)", "xyz-d65"], - expect: [0.108518, 0.172874, 0.074937] + expect: [0.108518, 0.172874, 0.074937], }, { args: "color(xyz 0 0 0)", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { args: "white", - expect: [0.222065, -0.0002, -0.0001] + expect: [0.222065, -0.0002, -0.0001], }, { args: "color(rec2020 1 1 1)", - expect: [0.22206525, -0.000161, -0.000117] + expect: [0.22206525, -0.000161, -0.000117], }, { args: "color(jzazbz 0.22206525 -0.000161 -0.000117)", - expect: [1, 1, 1] + expect: [1, 1, 1], }, { args: "#FFFF80", - expect: [0.212398, -0.0171, 0.0914] + expect: [0.212398, -0.0171, 0.0914], }, { args: "color(rec2020 1 0 0)", - expect: [0.154543, 0.1643, 0.1351] + expect: [0.154543, 0.1643, 0.1351], }, { args: "color(rec2020 0 1 0)", - expect: [0.160578, -0.2066, 0.1462] + expect: [0.160578, -0.2066, 0.1462], }, { args: "color(rec2020 0 0 1)", - expect: [0.091785, -0.0775, -0.2047] - } - ] + expect: [0.091785, -0.0775, -0.2047], + }, + ], }, { name: "JzCzHz", @@ -287,33 +287,33 @@ const tests = { tests: [ { args: "color(jzazbz 0.5 0 0)", - expect: [0.5, 0, NaN] + expect: [0.5, 0, NaN], }, { args: "color(jzazbz 0.2 0.000004 -0.000003)", - expect: [0.2, 0.000005, NaN] + expect: [0.2, 0.000005, NaN], }, { args: "color(jzazbz 0.2 0.000005 -0.000005)", - expect: [0.2, 0.00000707, NaN] + expect: [0.2, 0.00000707, NaN], }, { args: "color(jzazbz 0.1 -0.05 0.05)", - expect: [0.1, 0.070710678, 135] + expect: [0.1, 0.070710678, 135], }, { args: "color(jzczhz 0.1 0.070710678 135)", - expect: [0.1, -0.05, 0.05] + expect: [0.1, -0.05, 0.05], }, { args: "color(jzazbz 0.1 0.1 -0.08)", - expect: [0.1, 0.12806248, 321.34019] + expect: [0.1, 0.12806248, 321.34019], }, { args: "color(jzczhz 0.1, 0.12806248, 321.34019)", - expect: [0.1, 0.1, -0.08] - } - ] + expect: [0.1, 0.1, -0.08], + }, + ], }, { name: "ICtCp", @@ -324,54 +324,54 @@ const tests = { { name: "XYZ to ICtCp", args: "color(xyz 0 0 0)", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { name: "XYZ of D50 to ICtCp", args: "color(xyz 0.96422, 1.00000, 0.82521)", - expect: [0.5820, 0.0344, 0.0001] + expect: [0.5820, 0.0344, 0.0001], }, { name: "sRGB white (D65) to ICtCp", args: "white", - expect: [0.5820, 0.0344, 0.0001] + expect: [0.5820, 0.0344, 0.0001], }, { name: "rec2020 white to ICtCp", args: "color(rec2020 1 1 1)", - expect: [0.5820, 0.0344, 0.0001] + expect: [0.5820, 0.0344, 0.0001], }, { name: "rec2020 red to ICtCp", args: "color(rec2020 1 0 0)", - expect: [0.4413, -0.1164, 0.3985] + expect: [0.4413, -0.1164, 0.3985], }, { name: "rec2020 green to ICtCp", args: "color(rec2020 0 1 0)", - expect: [0.5305, -0.4247, -0.1219] + expect: [0.5305, -0.4247, -0.1219], }, { name: "rec2020 blue to ICtCp", args: "color(rec2020 0 0 1)", - expect: [0.3687, 0.2746, -0.2406] + expect: [0.3687, 0.2746, -0.2406], }, { name: "ICtCp rec2020 red back to rec2020", args: ["color(ictcp 0.4413 -0.1164 0.3985)", "rec2020"], - expect: [1, 0, 0] + expect: [1, 0, 0], }, { name: "ICtCp rec2020 green back to rec2020", args: ["color(ictcp 0.5305 -0.4247 -0.1219)", "rec2020"], - expect: [0, 1, 0] + expect: [0, 1, 0], }, { name: "ICtCp rec2020 blue back to rec2020", args: ["color(ictcp 0.3687 0.2746 -0.2406)", "rec2020"], - expect: [0, 0, 1] - } - ] + expect: [0, 0, 1], + }, + ], }, { name: "OKLab", @@ -383,44 +383,44 @@ const tests = { { name: "sRGB white (D65) to OKlab", args: "white", - expect: [1.000000, 0.000000, 0.000000] + expect: [1.000000, 0.000000, 0.000000], }, { name: "sRGB red (D65) to OKlab", args: "red", - expect: [0.627955, 0.224863, 0.125846] + expect: [0.627955, 0.224863, 0.125846], }, { name: "sRGB lime (D65) to OKlab", args: "lime", - expect: [0.86644, -0.233888, 0.179498] + expect: [0.86644, -0.233888, 0.179498], }, { name: "sRGB blue (D65) to OKlab", args: "blue", - expect: [0.452014, -0.032457, -0.311528] + expect: [0.452014, -0.032457, -0.311528], }, { name: "sRGB cyan (D65) to OKlab", args: "cyan", - expect: [0.905399, -0.149444, -0.039398] + expect: [0.905399, -0.149444, -0.039398], }, { name: "sRGB magenta (D65) to OKlab", args: "magenta", - expect: [0.701674, 0.274566, -0.169156] + expect: [0.701674, 0.274566, -0.169156], }, { name: "sRGB yellow (D65) to OKlab", args: "yellow", - expect: [0.967983, -0.071369, 0.198570] + expect: [0.967983, -0.071369, 0.198570], }, { name: "sRGB black (D65) to OKlab", args: "black", - expect: [0.000000, 0.000000, 0.000000] - } - ] + expect: [0.000000, 0.000000, 0.000000], + }, + ], }, { name: "OKLCh", @@ -431,24 +431,24 @@ const tests = { { name: "sRGB white (D65) to OKlch", args: "white", - expect: [1.0, 0.0, NaN] + expect: [1.0, 0.0, NaN], }, { name: "sRGB red (D65) to OKlab", args: "red", - expect: [0.6279553639214311, 0.2576833038053608, 29.23388027962784] + expect: [0.6279553639214311, 0.2576833038053608, 29.23388027962784], }, { name: "sRGB lime (D65) to OKlab", args: "lime", - expect: [0.8664396175234368, 0.2948272245426958, 142.4953450414439] + expect: [0.8664396175234368, 0.2948272245426958, 142.4953450414439], }, { name: "sRGB blue (D65) to OKlab", args: "blue", - expect: [0.45201371817442365, 0.3132143886344849, 264.0520226163699] - } - ] + expect: [0.45201371817442365, 0.3132143886344849, 264.0520226163699], + }, + ], }, { name: "Linear-light sRGB", @@ -459,14 +459,14 @@ const tests = { { name: "sRGB white to linear (identity", args: "white", - expect: [1.0, 1.0, 1.0] + expect: [1.0, 1.0, 1.0], }, { name: "mid grey to linear", args: "rgb(50% 50% 50%)", - expect: [0.21404114, 0.21404114, 0.21404114] - } - ] + expect: [0.21404114, 0.21404114, 0.21404114], + }, + ], }, { name: "ACEScc to XYZ", @@ -477,39 +477,39 @@ const tests = { { name: "ACEScc media white to XYZ", args: "color(acescc 1.0 1.0 1.0)", - expect: [211.8195, 222.8610, 242.7084] + expect: [211.8195, 222.8610, 242.7084], }, { name: "mid grey (linear 0.5) to XYZ", args: "color(acescc 0.4977169 0.4977169 0.4977169)", - expect: [0.475228, 0.500000, 0.544529] + expect: [0.475228, 0.500000, 0.544529], }, { name: "media black to XYZ", args: "color(acescc 0 0 0)", - expect: [0.001127, 0.001186, 0.001291] + expect: [0.001127, 0.001186, 0.001291], }, { name: "deepest black to XYZ", args: "color(acescc -0.358447, -0.358447, -0.358447)", - expect: [0, 0, 0] + expect: [0, 0, 0], }, { name: "ACEScc red to XYZ", args: "color(acescc 1.0 0.0 0.0)", - expect: [145.3586, 59.6545, -1.1981] + expect: [145.3586, 59.6545, -1.1981], }, { name: "ACEScc green to XYZ", args: "color(acescc 0.0 1.0 0.0)", - expect: [28.5798, 150.2844, 0.306392] + expect: [28.5798, 150.2844, 0.306392], }, { name: "ACEScc blue to XYZ", args: "color(acescc 0.0 0.0 1.0)", - expect: [37.8833, 12.9243, 243.6027] - } - ] + expect: [37.8833, 12.9243, 243.6027], + }, + ], }, { name: "ACEScc to Display P3", @@ -520,19 +520,19 @@ const tests = { { name: "ACEScc red to P3", args: "color(acescc 1.0 0.0 0.0)", - expect: [11.42071, -3.24602, -0.722011] + expect: [11.42071, -3.24602, -0.722011], }, { name: "ACEScc green to P3", args: "color(acescc 0.0 1.0 0.0)", - expect: [-6.096756, 10.318155, -2.713562] + expect: [-6.096756, 10.318155, -2.713562], }, { name: "ACEScc blue to P3", args: "color(acescc 0.0 0.0 1.0)", - expect: [-3.266071, -1.586111, 10.178351] - } - ] + expect: [-3.266071, -1.586111, 10.178351], + }, + ], }, { name: "CAM16 JMh", @@ -543,44 +543,44 @@ const tests = { { name: "sRGB white to CAM16 JMh", args: "white", - expect: [100.0, 2.236898, 209.5333] + expect: [100.0, 2.236898, 209.5333], }, { name: "sRGB red to CAM16 JMh", args: "red", - expect: [46.0257, 81.25425, 27.39326] + expect: [46.0257, 81.25425, 27.39326], }, { name: "sRGB lime to CAM16 JMh", args: "lime", - expect: [79.10135, 78.21552, 142.2234] + expect: [79.10135, 78.21552, 142.2234], }, { name: "sRGB blue to CAM16 JMh", args: "blue", - expect: [25.06626, 62.44153, 282.7545] + expect: [25.06626, 62.44153, 282.7545], }, { name: "sRGB cyan to CAM16 JMh", args: "cyan", - expect: [85.06114, 42.65358, 196.5924] + expect: [85.06114, 42.65358, 196.5924], }, { name: "sRGB magenta to CAM16 JMh", args: "magenta", - expect: [54.86332, 77.19869, 334.5684] + expect: [54.86332, 77.19869, 334.5684], }, { name: "sRGB yellow to CAM16 JMh", args: "yellow", - expect: [94.68236, 54.50008, 111.1473] + expect: [94.68236, 54.50008, 111.1473], }, { name: "sRGB black to CAM16 JMh", args: "black", - expect: [0.0, 0.0, 0.0] - } - ] + expect: [0.0, 0.0, 0.0], + }, + ], }, { name: "HCT", @@ -591,44 +591,44 @@ const tests = { { name: "sRGB white to HCT", args: "white", - expect: [209.5429, 2.871589, 100.0] + expect: [209.5429, 2.871589, 100.0], }, { name: "sRGB red to HCT", args: "red", - expect: [27.4098, 113.3564, 53.23712] + expect: [27.4098, 113.3564, 53.23712], }, { name: "sRGB lime to HCT", args: "lime", - expect: [142.1404, 108.4065, 87.73552] + expect: [142.1404, 108.4065, 87.73552], }, { name: "sRGB blue to HCT", args: "blue", - expect: [282.7622, 87.22804, 32.30087] + expect: [282.7622, 87.22804, 32.30087], }, { name: "sRGB cyan to HCT", args: "cyan", - expect: [196.5475, 58.96368, 91.11475] + expect: [196.5475, 58.96368, 91.11475], }, { name: "sRGB magenta to HCT", args: "magenta", - expect: [334.6332, 107.3899, 60.32273] + expect: [334.6332, 107.3899, 60.32273], }, { name: "sRGB yellow to HCT", args: "yellow", - expect: [111.0456, 75.50438, 97.13856] + expect: [111.0456, 75.50438, 97.13856], }, { name: "sRGB black to HCT", args: "black", - expect: [0.0, 0.0, 0.0] - } - ] + expect: [0.0, 0.0, 0.0], + }, + ], }, { name: "Luv", @@ -639,69 +639,69 @@ const tests = { { name: "sRGB white to Luv", args: "white", - expect: [100.0, 0, 0] + expect: [100.0, 0, 0], }, { name: "sRGB red to Luv", args: "red", - expect: [53.23711559542937, 175.0098221628849, 37.76509362555986] + expect: [53.23711559542937, 175.0098221628849, 37.76509362555986], }, { name: "sRGB lime to Luv", args: "lime", - expect: [87.73551910966002, -83.06711971440055, 107.41811123934258] + expect: [87.73551910966002, -83.06711971440055, 107.41811123934258], }, { name: "sRGB blue to Luv", args: "blue", - expect: [32.30087290398018, -9.402407214824064, -130.35108850356178] + expect: [32.30087290398018, -9.402407214824064, -130.35108850356178], }, { name: "sRGB cyan to Luv", args: "cyan", - expect: [91.11475231670536, -70.4643799638778, -15.205397466926968] + expect: [91.11475231670536, -70.4643799638778, -15.205397466926968], }, { name: "sRGB magenta to Luv", args: "magenta", - expect: [60.322731354551394, 84.05560198975205, -108.69636549176991] + expect: [60.322731354551394, 84.05560198975205, -108.69636549176991], }, { name: "sRGB yellow to Luv", args: "yellow", - expect: [97.13855934179699, 7.7042191772699375, 106.80811125089548] + expect: [97.13855934179699, 7.7042191772699375, 106.80811125089548], }, { name: "sRGB black to Luv", args: "black", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { name: "XYZ (none x) to Luv", args: "color(xyz-d65 none 0.4 0.5)", - expect: [69.46953076845696, -178.66105053418175, 10.54825812268007] + expect: [69.46953076845696, -178.66105053418175, 10.54825812268007], }, { name: "XYZ (none y) to Luv", args: "color(xyz-d65 0.3 none 0.5)", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { name: "XYZ (none z) to Luv", args: "color(xyz-d65 0.3 0.4 none)", - expect: [69.46953076845696, -6.641260059907392, 93.1177575503318] + expect: [69.46953076845696, -6.641260059907392, 93.1177575503318], }, { name: "LChuv (sRGB white) to Luv", args: "color(--lchuv 100.0 0 0)", - expect: [100.0, 0.0, 0.0] + expect: [100.0, 0.0, 0.0], }, { name: "LChuv (sRGB red) to Luv", args: "color(--lchuv 53.23711559542937 179.038096923620287 12.1770506300617765)", - expect: [53.23711559542937, 175.0098221628849, 37.76509362555986] + expect: [53.23711559542937, 175.0098221628849, 37.76509362555986], }, - ] + ], }, { name: "Luv to sRGB", @@ -712,84 +712,84 @@ const tests = { { name: "Luv (sRGB white) to sRGB", args: "color(--luv 100 0 0)", - expect: [1.0, 1.0, 1.0] + expect: [1.0, 1.0, 1.0], }, { name: "Luv (sRGB red) to sRGB", args: "color(--luv 53.23711559542937 175.0098221628849 37.76509362555986)", - expect: [1.0, 0.0, 0.0] + expect: [1.0, 0.0, 0.0], }, { name: "Luv (sRGB lime) to sRGB", args: "color(--luv 87.73551910966002 -83.06711971440055 107.41811123934258)", - expect: [0.0, 1.0, 0.0] + expect: [0.0, 1.0, 0.0], }, { name: "Luv (sRGB blue) to sRGB", args: "color(--luv 32.30087290398018 -9.402407214824064 -130.35108850356178)", - expect: [0.0, 0.0, 1.0] + expect: [0.0, 0.0, 1.0], }, { name: "Luv (sRGB cyan) to sRGB", args: "color(--luv 91.11475231670536 -70.4643799638778 -15.205397466926968)", - expect: [0.0, 1.0, 1.0] + expect: [0.0, 1.0, 1.0], }, { name: "Luv (sRGB magenta) to sRGB", args: "color(--luv 60.322731354551394 84.05560198975205 -108.69636549176991)", - expect: [1.0, 0.0, 1.0] + expect: [1.0, 0.0, 1.0], }, { name: "Luv (sRGB yellow) to sRGB", args: "color(--luv 97.13855934179699 7.7042191772699375 106.80811125089548)", - expect: [1.0, 1.0, 0.0] + expect: [1.0, 1.0, 0.0], }, { name: "Luv (sRGB black) to sRGB", args: "color(--luv 0 0 0)", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { name:"Luv (none lightness) to sRGB", args: "color(--luv none 50 50)", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { name:"Luv (none u) to sRGB", args: "color(--luv 100% none 0)", - expect: [1.0, 1.0, 1.0] + expect: [1.0, 1.0, 1.0], }, { name:"Luv (none v) to sRGB", args: "color(--luv 100% 0 none)", - expect: [1.0, 1.0, 1.0] - } + expect: [1.0, 1.0, 1.0], + }, - ] + ], }, { name: "sRGB to LCHuv", data: { - toSpace: "lchuv" + toSpace: "lchuv", }, tests: [ { args: "#771199", - expect: [30.933250438121703, 76.27303932913182, 290.5839513811392] + expect: [30.933250438121703, 76.27303932913182, 290.5839513811392], }, { args: "#ffee77", - expect: [93.33835580058862, 77.48166024357033, 77.51954539527138] + expect: [93.33835580058862, 77.48166024357033, 77.51954539527138], }, { args: "white", - expect: [100, 0, NaN] + expect: [100, 0, NaN], }, { args: "black", - expect: [0, 0, NaN] - } - ] + expect: [0, 0, NaN], + }, + ], }, { name: "HSLuv to sRGB", @@ -800,78 +800,78 @@ const tests = { { name: "HSLuv (sRGB white) to sRGB", args: "color(--hsluv 0 0 100)", - expect: [1.0, 1.0, 1.0] + expect: [1.0, 1.0, 1.0], }, { name: "HSLuv (sRGB red) to sRGB", args: "color(--hsluv 12.1770506300617765 100 53.23711559542933)", - expect: [1.0, 0.0, 0.0] + expect: [1.0, 0.0, 0.0], }, { name: "HSLuv (sRGB lime) to sRGB", args: "color(--hsluv 127.715012949240474 100 87.7355191096597338)", - expect: [0.0, 1.0, 0.0] + expect: [0.0, 1.0, 0.0], }, { name: "HSLuv (sRGB blue) to sRGB", args: "color(--hsluv 265.8743202181779 100 32.3008729039800215)", - expect: [0.0, 0.0, 1.0] + expect: [0.0, 0.0, 1.0], }, { name: "HSLuv (sRGB cyan) to sRGB", args: "color(--hsluv 192.17705063006116 100 91.114752316705065)", - expect: [0.0, 1.0, 1.0] + expect: [0.0, 1.0, 1.0], }, { name: "HSLuv (#777777) to sRGB", args: "color(--hsluv 0 0 50.0344387925380687)", - expect: [0.466666666666666674, 0.466666666666666674, 0.466666666666666674] + expect: [0.466666666666666674, 0.466666666666666674, 0.466666666666666674], }, { name: "HSLuv (sRGB black) to sRGB", args: "color(--hsluv 0 0 0)", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { name:"HSLuv (#dddddd with none hue) to sRGB", args: "color(--hsluv none 0 88.1154369871094)", - expect: [0.866666666666666696, 0.866666666666666696, 0.866666666666666696] + expect: [0.866666666666666696, 0.866666666666666696, 0.866666666666666696], }, { name:"HSLuv (none saturation) to sRGB", args: "color(--hsluv 80 none 100)", - expect: [1.0, 1.0, 1.0] + expect: [1.0, 1.0, 1.0], }, { name:"HSLuv (none lightness) to sRGB", args: "color(--hsluv 0 50 none)", - expect: [0.0, 0.0, 0.0] - } - ] + expect: [0.0, 0.0, 0.0], + }, + ], }, { name: "sRGB to HSLuv", data: { - toSpace: "hsluv" + toSpace: "hsluv", }, tests: [ { args: "#771199", - expect: [290.583951381139741, 94.745562802664864, 30.9332504381216253] + expect: [290.583951381139741, 94.745562802664864, 30.9332504381216253], }, { args: "#ffee77", - expect: [77.5195453952684659, 100.00000000002693, 93.3383558005883742] + expect: [77.5195453952684659, 100.00000000002693, 93.3383558005883742], }, { args: "white", - expect: [0, 0, 100] + expect: [0, 0, 100], }, { args: "black", - expect: [0, 0, 0] - } - ] + expect: [0, 0, 0], + }, + ], }, { name: "HPLuv to sRGB", @@ -882,83 +882,83 @@ const tests = { { name: "HPLuv (sRGB white) to sRGB", args: "color(--hpluv 0 0 100)", - expect: [1.0, 1.0, 1.0] + expect: [1.0, 1.0, 1.0], }, { name: "HPLuv (sRGB red) to sRGB", args: "color(--hpluv 12.1770506300617765 426.746789183125202 53.23711559542933)", - expect: [1.0, 0.0, 0.0] + expect: [1.0, 0.0, 0.0], }, { name: "HPLuv (sRGB lime) to sRGB", args: "color(--hpluv 127.715012949240474 490.145375063702204 87.7355191096597338)", - expect: [0.0, 1.0, 0.0] + expect: [0.0, 1.0, 0.0], }, { name: "HPLuv (sRGB blue) to sRGB", args: "color(--hpluv 265.8743202181779, 513.41269684428039, 32.3008729039800215)", - expect: [0.0, 0.0, 1.0] + expect: [0.0, 0.0, 1.0], }, { name: "HPLuv (sRGB cyan) to sRGB", args: "color(--hpluv 192.17705063006116 369.190533917051368 91.114752316705065)", - expect: [0.0, 1.0, 1.0] + expect: [0.0, 1.0, 1.0], }, { name: "HPLuv (#777777) to sRGB", args: "color(--hpluv 0 0 50.0344387925380687)", - expect: [0.466666666666666674, 0.466666666666666674, 0.466666666666666674] + expect: [0.466666666666666674, 0.466666666666666674, 0.466666666666666674], }, { name: "HPLuv (#cc99aa) to sRGB", args: "color(--hpluv 349.049331623372325 57.3580941092039609 68.4044417972397838)", - expect: [0.8, 0.6, 0.66666666666666663] + expect: [0.8, 0.6, 0.66666666666666663], }, { name: "HPLuv (sRGB black) to sRGB", args: "color(--hpluv 0 0 0)", - expect: [0.0, 0.0, 0.0] + expect: [0.0, 0.0, 0.0], }, { name:"HPLuv (#dddddd with none hue) to sRGB", args: "color(--hpluv none 0 88.1154369871094)", - expect: [0.866666666666666696, 0.866666666666666696, 0.866666666666666696] + expect: [0.866666666666666696, 0.866666666666666696, 0.866666666666666696], }, { name:"HPLuv (none saturation) to sRGB", args: "color(--hpluv 80 none 100)", - expect: [1.0, 1.0, 1.0] + expect: [1.0, 1.0, 1.0], }, { name:"HPLuv (none lightness) to sRGB", args: "color(--hpluv 0 50 none)", - expect: [0.0, 0.0, 0.0] - } - ] + expect: [0.0, 0.0, 0.0], + }, + ], }, { name: "sRGB to HPLuv", data: { - toSpace: "hpluv" + toSpace: "hpluv", }, tests: [ { args: "#cc99aa", - expect: [349.049331623372325, 57.3580941092039609, 68.4044417972397838] + expect: [349.049331623372325, 57.3580941092039609, 68.4044417972397838], }, { args: "cyan", - expect: [192.17705063006116, 369.190533917051368, 91.114752316705065] + expect: [192.17705063006116, 369.190533917051368, 91.114752316705065], }, { args: "white", - expect: [0, 0, 100] + expect: [0, 0, 100], }, { args: "black", - expect: [0, 0, 0] - } - ] + expect: [0, 0, 0], + }, + ], }, { name: "Get coordinates", @@ -971,7 +971,7 @@ const tests = { run () { return this.data.slategray.c; }, - expect: 11.23415 + expect: 11.23415, }, { @@ -979,28 +979,28 @@ const tests = { run () { return this.data.slategray.lch[1]; }, - expect: 11.23415 + expect: 11.23415, }, { name: "color.lch.c", run () { return this.data.slategray.lch.c; }, - expect: 11.23415 + expect: 11.23415, }, { name: "color.oklch.c", run () { return this.data.slategray.oklch.c; }, - expect: 0.03100055 + expect: 0.03100055, }, { name: "color.jzazbz.Jz", run () { return this.data.slategray.jzazbz.jz; }, - expect: 0.11646942 + expect: 0.11646942, }, { name: "color.jzazbz.Jz", @@ -1008,11 +1008,11 @@ const tests = { var color = new Color("color(jzazbz 0.54 0 0)"); return color.jzazbz.jz; }, - expect: 0.54 - } - ] - } - ] + expect: 0.54, + }, + ], + }, + ], }; export default tests; diff --git a/test/delta.js b/test/delta.js index 9565bc677..69f3a186c 100644 --- a/test/delta.js +++ b/test/delta.js @@ -18,59 +18,59 @@ export default { { name: "100% L = 100", args: ["white", "black"], - expect: 100 + expect: 100, }, { name: "0% L = 0", args: ["white", "white"], - expect: 0 + expect: 0, }, { name: "barely off-white", args: ["#fffffe", "white"], - expect: 0.4966 + expect: 0.4966, }, { name: "Pythagorean 3,4,5 triangle", args: ["lab(50% 30 40)", "lab(50% 0 0)"], - expect: 50 + expect: 50, }, { name: "Sharma test 17: large color differences", args: ["lab(50% 2.5 0)", "lab(73% 25 -18)"], - expect: 36.8680 + expect: 36.8680, }, { name: "Sharma test 18: large color differences", args: ["lab(50% 2.5 0)", "lab(61% -5 29)"], - expect: 31.9100 + expect: 31.9100, }, { name: "Sharma test 19: large color differences", args: ["lab(50% 2.5 0)", "lab(56% -27 -3)"], - expect: 30.2531 + expect: 30.2531, }, { name: "Sharma test 20: large color differences", args: ["lab(50% 2.5 0)", "lab(58% 24 15)"], - expect: 27.4089 + expect: 27.4089, }, { name: "Brilliant Yellow with Hue error", args: ["lab(84.25% 5.74 96.00)", "lab(84.46% 8.88 96.49)"], - expect: 3.1849 + expect: 3.1849, }, { name: "Brilliant Yellow with low Chroma error", args: ["lab(84.25% 5.74 96.00)", "lab(84.52% 5.75 93.09)"], - expect: 2.9225 + expect: 2.9225, }, { name: "Brilliant Yellow with high Chroma error", args: ["lab(84.25% 5.74 96.00)", "lab(84.37% 5.86 99.42)"], - expect: 3.4242 + expect: 3.4242, }, - ] + ], }, { name: "DeltaE CMC(2:1)", @@ -80,64 +80,64 @@ export default { { name: "100% L = 100", args: ["white", "black"], - expect: 33.7401 + expect: 33.7401, }, { name: "0%L = 0", args: ["white", "white"], - expect: 0 + expect: 0, }, { name: "barely off-white", args: ["#fffffe", "white"], - expect: 0.7780 + expect: 0.7780, }, { name: "barely off-white", args: ["#fffffe", "lab(100% 0 0)"], - expect: 0.7780 + expect: 0.7780, }, { name: "Pythagorean 3,4,5 triangle", args: ["lab(50% 30 40)", "lab(50% 0 0)"], - expect: 19.4894 + expect: 19.4894, }, { name: "Brilliant Yellow with Hue error", args: ["lab(84.25% 5.74 96.00)", "lab(84.46% 8.88 96.49)"], - expect: 1.6364 + expect: 1.6364, }, { name: "Brilliant Yellow with low Chroma error", args: ["lab(84.25% 5.74 96.00)", "lab(84.52% 5.75 93.09)"], - expect: 0.8770 + expect: 0.8770, }, { name: "Brilliant Yellow with high Chroma error", args: ["lab(84.25% 5.74 96.00)", "lab(84.37% 5.86 99.42)"], - expect: 1.0221 + expect: 1.0221, }, { name: "Sharma test 17: large color differences", args: ["lab(50% 2.5 0)", "lab(73% 25 -18)"], - expect: 37.9233 + expect: 37.9233, }, { name: "Sharma test 18: large color differences", args: ["lab(50% 2.5 0)", "lab(61% -5 29)"], - expect: 34.4758 + expect: 34.4758, }, { name: "Sharma test 19: large color differences", args: ["lab(50% 2.5 0)", "lab(56% -27 -3)"], - expect: 38.0618 + expect: 38.0618, }, { name: "Sharma test 20: large color differences", args: ["lab(50% 2.5 0)", "lab(58% 24 15)"], - expect: 33.3342 + expect: 33.3342, }, - ] + ], }, { name: "DeltaE 2000", @@ -152,142 +152,142 @@ export default { { name: "100% L = 100", args: ["white", "black"], - expect: 100 + expect: 100, }, { name: "0%L = 0", args: ["white", "white"], - expect: 0 + expect: 0, }, { name: "barely off-white", args: ["#fffffe", "white"], - expect: 0.51125 + expect: 0.51125, }, { name: "Pythagorean 3,4,5 triangle", args: ["lab(50% 30 40)", "lab(50% 0 0)"], - expect: 24.1218 + expect: 24.1218, }, { name: "Sharma test 1: signed ΔH", args: ["lab(50% 2.6772 -79.7751)", "lab(50% 0 -82.7485)"], - expect: 2.0425 + expect: 2.0425, }, { name: "Sharma test 2: signed ΔH", args: ["lab(50% 3.1571 -77.2803)", "lab(50% 0 -82.7485)"], - expect: 2.8615 + expect: 2.8615, }, { name: "Sharma test 3: signed ΔH", args: ["lab(50% 2.8361 -74.0200)", "lab(50% 0 -82.7485)"], - expect: 3.4412 + expect: 3.4412, }, { name: "Sharma test 4: signed ΔC", args: ["lab(50% -1.3802 -84.2814)", "lab(50% 0 -82.7485)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 5: signed ΔC", args: ["lab(50% -1.1848 -84.8006)", "lab(50% 0 -82.7485)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 6: signed ΔC", args: ["lab(50% -0.9009 -85.5211)", "lab(50% 0 -82.7485)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 7: arctan hue and mean hue", args: ["lab(50% 0 0)", "lab(50% -1 2)"], - expect: 2.3669 + expect: 2.3669, }, { name: "Sharma test 8: arctan hue and mean hue", args: ["lab(50% -1 2)", "lab(50% 0 0)"], - expect: 2.3669 + expect: 2.3669, }, { name: "Sharma test 9: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0009)"], - expect: 7.1792 + expect: 7.1792, }, { name: "Sharma test 10: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0010)"], - expect: 7.1792 + expect: 7.1792, }, { name: "Sharma test 11: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0011)"], - expect: 7.2195 + expect: 7.2195, }, { name: "Sharma test 12: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0012)"], - expect: 7.2195 + expect: 7.2195, }, { name: "Sharma test 13: arctan hue and mean hue", args: ["lab(50% -0.0010 2.4900)", "lab(50% 0.0009 -2.4900)"], - expect: 4.8045 + expect: 4.8045, }, { name: "Sharma test 14: arctan hue and mean hue", args: ["lab(50% -0.0010 2.4900)", "lab(50% 0.00010 -2.4900)"], - expect: 4.8045 + expect: 4.8045, }, { name: "Sharma test 15: arctan hue and mean hue", args: ["lab(50% -0.0010 2.4900)", "lab(50% 0.0011 -2.4900)"], - expect: 4.7461 + expect: 4.7461, }, { name: "Sharma test 16: arctan hue and mean hue", args: ["lab(50% 2.5 0)", "lab(50% 0 -2.5)"], - expect: 4.3065 + expect: 4.3065, }, { name: "Sharma test 17: large color differences", args: ["lab(50% 2.5 0)", "lab(73% 25 -18)"], - expect: 27.1492 + expect: 27.1492, }, { name: "Sharma test 18: large color differences", args: ["lab(50% 2.5 0)", "lab(61% -5 29)"], - expect: 22.8977 + expect: 22.8977, }, { name: "Sharma test 19: large color differences", args: ["lab(50% 2.5 0)", "lab(56% -27 -3)"], - expect: 31.9030 + expect: 31.9030, }, { name: "Sharma test 20: large color differences", args: ["lab(50% 2.5 0)", "lab(58% 24 15)"], - expect: 19.4535 + expect: 19.4535, }, { name: "Sharma test 21: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 3.1736 0.5854)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 22: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 3.2972 0)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 23: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 1.8634 0.5757)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 24: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 3.2592 0.3350)"], - expect: 1.0000 + expect: 1.0000, }, // from "Improvement to industrial colour-difference // evaluation. Vienna: CIE Publication No. 142-2001 @@ -295,107 +295,107 @@ export default { name: "Sharma test 25: CIE Publication No. 142", args: [ "lab(60.2574% -34.0099 36.2677)", - "lab(60.4626% -34.1751 39.4387)" + "lab(60.4626% -34.1751 39.4387)", ], - expect: 1.2644 + expect: 1.2644, }, { name: "Sharma test 26: CIE Publication No. 142", args: [ "lab(63.0109% -31.0961 -5.8663)", - "lab(62.8187% -29.7946 -4.0864)" + "lab(62.8187% -29.7946 -4.0864)", ], - expect: 1.2630 + expect: 1.2630, }, { name: "Sharma test 27: CIE Publication No. 142", args: [ "lab(61.2901% 3.7196 -5.3901)", - "lab(61.4292% 2.2480 -4.9620)" + "lab(61.4292% 2.2480 -4.9620)", ], - expect: 1.8731 + expect: 1.8731, }, { name: "Sharma test 28: CIE Publication No. 142", args: [ "lab(35.0831% -44.1164 3.7933)", - "lab(35.0232% -40.0716 1.5901)" + "lab(35.0232% -40.0716 1.5901)", ], - expect: 1.8645 + expect: 1.8645, }, { name: "Sharma test 29: CIE Publication No. 142", args: [ "lab(22.7233% 20.0904 -46.6940)", - "lab(23.0331% 14.9730 -42.5619)" + "lab(23.0331% 14.9730 -42.5619)", ], - expect: 2.0373 + expect: 2.0373, }, { name: "Sharma test 30: CIE Publication No. 142", args: [ "lab(36.4612% 47.8580 18.3852)", - "lab(36.2715% 50.5065 21.2231)" + "lab(36.2715% 50.5065 21.2231)", ], - expect: 1.4146 + expect: 1.4146, }, { name: "Sharma test 31: CIE Publication No. 142", args: [ "lab(90.8027% -2.0831 1.4410)", - "lab(91.1528% -1.6435 0.0447)" + "lab(91.1528% -1.6435 0.0447)", ], - expect: 1.4441 + expect: 1.4441, }, { name: "Sharma test 32: CIE Publication No. 142", args: [ "lab(90.9257% -0.5406 -0.9208)", - "lab(88.6381% -0.8985 -0.7239)" + "lab(88.6381% -0.8985 -0.7239)", ], - expect: 1.5381 + expect: 1.5381, }, { name: "Sharma test 33: CIE Publication No. 142", args: [ "lab(6.7747% -0.2908 -2.4247)", - "lab(5.8714% -0.0985 -2.2286)" + "lab(5.8714% -0.0985 -2.2286)", ], - expect: 0.6377 + expect: 0.6377, }, { name: "Sharma test 34: CIE Publication No. 142", args: [ "lab(2.0776% 0.0795 -1.1350)", - "lab(0.9033% -0.0636 -0.5514)" + "lab(0.9033% -0.0636 -0.5514)", ], - expect: 0.9082 + expect: 0.9082, }, { name: "Brilliant Yellow with Hue error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.46% 8.88 96.49)" + "lab(84.46% 8.88 96.49)", ], - expect: 1.6743 + expect: 1.6743, }, { name: "Brilliant Yellow with low Chroma error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.52% 5.75 93.09)" + "lab(84.52% 5.75 93.09)", ], - expect: 0.5887 + expect: 0.5887, }, { name: "Brilliant Yellow with high Chroma error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.37% 5.86 99.42)" + "lab(84.37% 5.86 99.42)", ], - expect: 0.6395 + expect: 0.6395, }, - ] + ], }, { name: "DeltaE ITP", @@ -411,142 +411,142 @@ export default { { name: "100% L = 100", args: ["white", "black"], - expect: 100 + expect: 100, }, { name: "0%L = 0", args: ["white", "white"], - expect: 0 + expect: 0, }, { name: "barely off-white", args: ["#fffffe", "white"], - expect: 0.4966 + expect: 0.4966, }, { name: "Pythagorean 3,4,5 triangle", args: ["lab(50% 30 40)", "lab(50% 0 0)"], - expect: 50 + expect: 50, }, { name: "Sharma test 1: signed ΔH", args: ["lab(50% 2.6772 -79.7751)", "lab(50% 0 -82.7485)"], - expect: 2.0425 + expect: 2.0425, }, { name: "Sharma test 2: signed ΔH", args: ["lab(50% 3.1571 -77.2803)", "lab(50% 0 -82.7485)"], - expect: 2.8615 + expect: 2.8615, }, { name: "Sharma test 3: signed ΔH", args: ["lab(50% 2.8361 -74.0200)", "lab(50% 0 -82.7485)"], - expect: 3.4412 + expect: 3.4412, }, { name: "Sharma test 4: signed ΔC", args: ["lab(50% -1.3802 -84.2814)", "lab(50% 0 -82.7485)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 5: signed ΔC", args: ["lab(50% -1.1848 -84.8006)", "lab(50% 0 -82.7485)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 6: signed ΔC", args: ["lab(50% -0.9009 -85.5211)", "lab(50% 0 -82.7485)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 7: arctan hue and mean hue", args: ["lab(50% 0 0)", "lab(50% -1 2)"], - expect: 2.3669 + expect: 2.3669, }, { name: "Sharma test 8: arctan hue and mean hue", args: ["lab(50% -1 2)", "lab(50% 0 0)"], - expect: 2.3669 + expect: 2.3669, }, { name: "Sharma test 9: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0009)"], - expect: 7.1792 + expect: 7.1792, }, { name: "Sharma test 10: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0010)"], - expect: 7.1792 + expect: 7.1792, }, { name: "Sharma test 11: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0011)"], - expect: 7.2195 + expect: 7.2195, }, { name: "Sharma test 12: arctan hue and mean hue", args: ["lab(50% 2.4900 -0.0010)", "lab(50% -2.4900 0.0012)"], - expect: 7.2195 + expect: 7.2195, }, { name: "Sharma test 13: arctan hue and mean hue", args: ["lab(50% -0.0010 2.4900)", "lab(50% 0.0009 -2.4900)"], - expect: 4.8045 + expect: 4.8045, }, { name: "Sharma test 14: arctan hue and mean hue", args: ["lab(50% -0.0010 2.4900)", "lab(50% 0.00010 -2.4900)"], - expect: 4.8045 + expect: 4.8045, }, { name: "Sharma test 15: arctan hue and mean hue", args: ["lab(50% -0.0010 2.4900)", "lab(50% 0.0011 -2.4900)"], - expect: 4.7461 + expect: 4.7461, }, { name: "Sharma test 16: arctan hue and mean hue", args: ["lab(50% 2.5 0)", "lab(50% 0 -2.5)"], - expect: 4.3065 + expect: 4.3065, }, { name: "Sharma test 17: large color differences", args: ["lab(50% 2.5 0)", "lab(73% 25 -18)"], - expect: 27.1492 + expect: 27.1492, }, { name: "Sharma test 18: large color differences", args: ["lab(50% 2.5 0)", "lab(61% -5 29)"], - expect: 22.8977 + expect: 22.8977, }, { name: "Sharma test 19: large color differences", args: ["lab(50% 2.5 0)", "lab(56% -27 -3)"], - expect: 31.9030 + expect: 31.9030, }, { name: "Sharma test 20: large color differences", args: ["lab(50% 2.5 0)", "lab(58% 24 15)"], - expect: 19.4535 + expect: 19.4535, }, { name: "Sharma test 21: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 3.1736 0.5854)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 22: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 3.2972 0)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 23: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 1.8634 0.5757)"], - expect: 1.0000 + expect: 1.0000, }, { name: "Sharma test 24: unit color differences", args: ["lab(50% 2.5 0)", "lab(50% 3.2592 0.3350)"], - expect: 1.0000 + expect: 1.0000, }, // from "Improvement to industrial colour-difference // evaluation. Vienna: CIE Publication No. 142-2001 @@ -554,107 +554,107 @@ export default { name: "Sharma test 25: CIE Publication No. 142", args: [ "lab(60.2574% -34.0099 36.2677)", - "lab(60.4626% -34.1751 39.4387)" + "lab(60.4626% -34.1751 39.4387)", ], - expect: 1.2644 + expect: 1.2644, }, { name: "Sharma test 26: CIE Publication No. 142", args: [ "lab(63.0109% -31.0961 -5.8663)", - "lab(62.8187% -29.7946 -4.0864)" + "lab(62.8187% -29.7946 -4.0864)", ], - expect: 1.2630 + expect: 1.2630, }, { name: "Sharma test 27: CIE Publication No. 142", args: [ "lab(61.2901% 3.7196 -5.3901)", - "lab(61.4292% 2.2480 -4.9620)" + "lab(61.4292% 2.2480 -4.9620)", ], - expect: 1.8731 + expect: 1.8731, }, { name: "Sharma test 28: CIE Publication No. 142", args: [ "lab(35.0831% -44.1164 3.7933)", - "lab(35.0232% -40.0716 1.5901)" + "lab(35.0232% -40.0716 1.5901)", ], - expect: 1.8645 + expect: 1.8645, }, { name: "Sharma test 29: CIE Publication No. 142", args: [ "lab(22.7233% 20.0904 -46.6940)", - "lab(23.0331% 14.9730 -42.5619)" + "lab(23.0331% 14.9730 -42.5619)", ], - expect: 2.0373 + expect: 2.0373, }, { name: "Sharma test 30: CIE Publication No. 142", args: [ "lab(36.4612% 47.8580 18.3852)", - "lab(36.2715% 50.5065 21.2231)" + "lab(36.2715% 50.5065 21.2231)", ], - expect: 1.4146 + expect: 1.4146, }, { name: "Sharma test 31: CIE Publication No. 142", args: [ "lab(90.8027% -2.0831 1.4410)", - "lab(91.1528% -1.6435 0.0447)" + "lab(91.1528% -1.6435 0.0447)", ], - expect: 1.4441 + expect: 1.4441, }, { name: "Sharma test 32: CIE Publication No. 142", args: [ "lab(90.9257% -0.5406 -0.9208)", - "lab(88.6381% -0.8985 -0.7239)" + "lab(88.6381% -0.8985 -0.7239)", ], - expect: 1.5381 + expect: 1.5381, }, { name: "Sharma test 33: CIE Publication No. 142", args: [ "lab(6.7747% -0.2908 -2.4247)", - "lab(5.8714% -0.0985 -2.2286)" + "lab(5.8714% -0.0985 -2.2286)", ], - expect: 0.6377 + expect: 0.6377, }, { name: "Sharma test 34: CIE Publication No. 142", args: [ "lab(2.0776% 0.0795 -1.1350)", - "lab(0.9033% -0.0636 -0.5514)" + "lab(0.9033% -0.0636 -0.5514)", ], - expect: 0.9082 + expect: 0.9082, }, { name: "Brilliant Yellow with Hue error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.46% 8.88 96.49)" + "lab(84.46% 8.88 96.49)", ], - expect: 1.6364 + expect: 1.6364, }, { name: "Brilliant Yellow with low Chroma error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.52% 5.75 93.09)" + "lab(84.52% 5.75 93.09)", ], - expect: 0.5887 + expect: 0.5887, }, { name: "Brilliant Yellow with high Chroma error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.37% 5.86 99.42)" + "lab(84.37% 5.86 99.42)", ], - expect: 0.6395 + expect: 0.6395, }, - ] + ], }, { name: "DeltaE Jz", @@ -663,62 +663,62 @@ export default { { name: "100% L = 100", args: ["white", "black"], - expect: 0.222065 + expect: 0.222065, }, { name: "0%L = 0", args: ["white", "white"], - expect: 0 + expect: 0, }, { name: "barely off-white", args: ["#fffffe", "white"], - expect: 0.00048 + expect: 0.00048, }, { name: "Pythagorean 3,4,5 triangle", args: [ "color(jzazbz 0.1 0.03 0.04)", - "color(jzazbz 0.1 0 0)" + "color(jzazbz 0.1 0 0)", ], - expect: 0.05 + expect: 0.05, }, { name: "Sharma test 17: large color differences", args: ["lab(50% 2.5 0)", "lab(73% 25 -18)"], - expect: 0.070538 + expect: 0.070538, }, { name: "Sharma test 18: large color differences", args: ["lab(50% 2.5 0)", "lab(61% -5 29)"], - expect: 0.059699 + expect: 0.059699, }, { name: "Sharma test 19: large color differences", args: ["lab(50% 2.5 0)", "lab(56% -27 -3)"], - expect: 0.039590 + expect: 0.039590, }, { name: "Sharma test 20: large color differences", args: ["lab(50% 2.5 0)", "lab(58% 24 15)"], - expect: 0.051967 + expect: 0.051967, }, { name: "Brilliant Yellow with Hue error", args: ["lab(84.25% 5.74 96.00)", "lab(84.46% 8.88 96.49)"], - expect: 0.008447 + expect: 0.008447, }, { name: "Brilliant Yellow with low Chroma error", args: ["lab(84.25% 5.74 96.00)", "lab(84.52% 5.75 93.09)"], - expect: 0.002969 + expect: 0.002969, }, { name: "Brilliant Yellow with high Chroma error", args: ["lab(84.25% 5.74 96.00)", "lab(84.37% 5.86 99.42)"], - expect: 0.003113 + expect: 0.003113, }, - ] + ], }, { name: "DeltaE OK", @@ -728,42 +728,42 @@ export default { { name: "100% L = 100", args: ["white", "black"], - expect: 1 + expect: 1, }, { name: "0%L = 0", args: ["white", "white"], - expect: 0 + expect: 0, }, { name: "barely off-white", args: ["#fffffe", "white"], - expect: 0.001343 + expect: 0.001343, }, { name: "Pythagorean 3,4,5 triangle", args: ["lab(50% 30 40)", "lab(50% 0 0)"], - expect: 0.118679 + expect: 0.118679, }, { name: "Sharma test 17: large color differences", args: ["lab(50% 2.5 0)", "lab(73% 25 -18)"], - expect: 0.223724 + expect: 0.223724, }, { name: "Sharma test 18: large color differences", args: ["lab(50% 2.5 0)", "lab(61% -5 29)"], - expect: 0.117703 + expect: 0.117703, }, { name: "Sharma test 19: large color differences", args: ["lab(50% 2.5 0)", "lab(56% -27 -3)"], - expect: 0.096109 + expect: 0.096109, }, { name: "Sharma test 20: large color differences", args: ["lab(50% 2.5 0)", "lab(58% 24 15)"], - expect: 0.103834 + expect: 0.103834, }, // from "Improvement to industrial colour-difference // evaluation. Vienna: CIE Publication No. 142-2001 @@ -771,107 +771,107 @@ export default { name: "Sharma test 25: CIE Publication No. 142", args: [ "lab(60.2574% -34.0099 36.2677)", - "lab(60.4626% -34.1751 39.4387)" + "lab(60.4626% -34.1751 39.4387)", ], - expect: 0.006934 + expect: 0.006934, }, { name: "Sharma test 26: CIE Publication No. 142", args: [ "lab(63.0109% -31.0961 -5.8663)", - "lab(62.8187% -29.7946 -4.0864)" + "lab(62.8187% -29.7946 -4.0864)", ], - expect: 0.006478 + expect: 0.006478, }, { name: "Sharma test 27: CIE Publication No. 142", args: [ "lab(61.2901% 3.7196 -5.3901)", - "lab(61.4292% 2.2480 -4.9620)" + "lab(61.4292% 2.2480 -4.9620)", ], - expect: 0.004552 + expect: 0.004552, }, { name: "Sharma test 28: CIE Publication No. 142", args: [ "lab(35.0831% -44.1164 3.7933)", - "lab(35.0232% -40.0716 1.5901)" + "lab(35.0232% -40.0716 1.5901)", ], - expect: 0.011480 + expect: 0.011480, }, { name: "Sharma test 29: CIE Publication No. 142", args: [ "lab(22.7233% 20.0904 -46.6940)", - "lab(23.0331% 14.9730 -42.5619)" + "lab(23.0331% 14.9730 -42.5619)", ], - expect: 0.014549 + expect: 0.014549, }, { name: "Sharma test 30: CIE Publication No. 142", args: [ "lab(36.4612% 47.8580 18.3852)", - "lab(36.2715% 50.5065 21.2231)" + "lab(36.2715% 50.5065 21.2231)", ], - expect: 0.009265 + expect: 0.009265, }, { name: "Sharma test 31: CIE Publication No. 142", args: [ "lab(90.8027% -2.0831 1.4410)", - "lab(91.1528% -1.6435 0.0447)" + "lab(91.1528% -1.6435 0.0447)", ], - expect: 0.005109 + expect: 0.005109, }, { name: "Sharma test 32: CIE Publication No. 142", args: [ "lab(90.9257% -0.5406 -0.9208)", - "lab(88.6381% -0.8985 -0.7239)" + "lab(88.6381% -0.8985 -0.7239)", ], - expect: 0.019893 + expect: 0.019893, }, { name: "Sharma test 33: CIE Publication No. 142", args: [ "lab(6.7747% -0.2908 -2.4247)", - "lab(5.8714% -0.0985 -2.2286)" + "lab(5.8714% -0.0985 -2.2286)", ], - expect: 0.009068 + expect: 0.009068, }, { name: "Sharma test 34: CIE Publication No. 142", args: [ "lab(2.0776% 0.0795 -1.1350)", - "lab(0.9033% -0.0636 -0.5514)" + "lab(0.9033% -0.0636 -0.5514)", ], - expect: 0.032252 + expect: 0.032252, }, { name: "Brilliant Yellow with Hue error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.46% 8.88 96.49)" + "lab(84.46% 8.88 96.49)", ], - expect: 0.009285 + expect: 0.009285, }, { name: "Brilliant Yellow with low Chroma error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.52% 5.75 93.09)" + "lab(84.52% 5.75 93.09)", ], - expect: 0.0039230 + expect: 0.0039230, }, { name: "Brilliant Yellow with high Chroma error", args: [ "lab(84.25% 5.74 96.00)", - "lab(84.37% 5.86 99.42)" + "lab(84.37% 5.86 99.42)", ], - expect: 0.003800 + expect: 0.003800, }, - ] - } - ] + ], + }, + ], }; diff --git a/test/gamut.js b/test/gamut.js index 43ea0b355..78757100c 100644 --- a/test/gamut.js +++ b/test/gamut.js @@ -17,7 +17,7 @@ export default { const color = new Color(c); return this.data.checkAlpha ? [ ...color.coords, - color.alpha + color.alpha, ] : color.coords; }, check: check.deep(check.proximity({ epsilon: 0.001 })), @@ -28,30 +28,30 @@ export default { tests: [ { args: ["color(display-p3 1 0 0)"], - expect: "rgb(100% 4.457% 4.5932%)" + expect: "rgb(100% 4.457% 4.5932%)", }, { args: ["color(display-p3 0 1 0)"], - expect: "rgb(0% 98.576% 15.974%)" + expect: "rgb(0% 98.576% 15.974%)", }, { args: ["color(display-p3 0 0 1)"], - expect: "rgb(0% 0% 100%)" + expect: "rgb(0% 0% 100%)", }, { args: ["color(display-p3 1 1 0)"], - expect: "rgb(99.623% 99.901% 0%)" + expect: "rgb(99.623% 99.901% 0%)", }, { args: ["color(display-p3 0 1 1)"], - expect: "rgb(0% 99.645% 98.471%)" + expect: "rgb(0% 99.645% 98.471%)", }, { args: ["color(display-p3 1 0 1)"], - expect: "rgb(100% 16.736% 98.264%)" + expect: "rgb(100% 16.736% 98.264%)", }, - ] + ], }, { name: "P3 to sRGB whites/blacks CSS algorithm", @@ -59,21 +59,21 @@ export default { tests: [ { args: ["color(display-p3 1 1 1)"], - expect: "rgb(100% 100% 100%)" + expect: "rgb(100% 100% 100%)", }, { args: ["color(display-p3 2 0 1)"], - expect: "rgb(100% 100% 100%)" + expect: "rgb(100% 100% 100%)", }, { args: ["color(display-p3 0 0 0)"], - expect: "rgb(0% 0% 0%)" + expect: "rgb(0% 0% 0%)", }, { args: ["color(display-p3 -1 0 0)"], - expect: "rgb(0% 0% 0%)" - } - ] + expect: "rgb(0% 0% 0%)", + }, + ], }, { name: "Maintains alpha", @@ -81,29 +81,29 @@ export default { tests: [ { args: ["color(display-p3 1 1 1 / 1)"], - expect: "rgb(100% 100% 100%)" + expect: "rgb(100% 100% 100%)", }, { args: ["color(display-p3 1 1 1 / 0.5)"], - expect: "rgb(100% 100% 100% / 0.5)" + expect: "rgb(100% 100% 100% / 0.5)", }, { args: ["color(display-p3 1 1 1 / 0)"], - expect: "rgb(100% 100% 100% / 0)" + expect: "rgb(100% 100% 100% / 0)", }, { args: ["color(display-p3 1 0 0 / 1)"], - expect: "rgb(100% 4.457% 4.5932%)" + expect: "rgb(100% 4.457% 4.5932%)", }, { args: ["color(display-p3 1 0 0 / 0.5)"], - expect: "rgb(100% 4.457% 4.5932% / 0.5)" + expect: "rgb(100% 4.457% 4.5932% / 0.5)", }, { args: ["color(display-p3 1 0 0 / 0)"], - expect: "rgb(100% 4.457% 4.5932% / 0)" + expect: "rgb(100% 4.457% 4.5932% / 0)", }, - ] + ], }, { name: "P3 primaries to sRGB, LCH chroma Reduction", @@ -111,30 +111,30 @@ export default { tests: [ { args: ["color(display-p3 1 0 0)"], - expect: "rgb(98.20411139286732% 21.834053137266363% 0%)" + expect: "rgb(98.20411139286732% 21.834053137266363% 0%)", }, { args: ["color(display-p3 0 1 0)"], - expect: "rgb(0% 99.7921930734509% 0%)" + expect: "rgb(0% 99.7921930734509% 0%)", }, { args: ["color(display-p3 0 0 1)"], - expect: "rgb(0% 0% 100%)" + expect: "rgb(0% 0% 100%)", }, { args: ["color(display-p3 1 1 0)"], - expect: "rgb(100% 99.45446271521069% 0%)" + expect: "rgb(100% 99.45446271521069% 0%)", }, { args: ["color(display-p3 0 1 1)"], - expect: "rgb(0% 100% 98.93709142382755%)" + expect: "rgb(0% 100% 98.93709142382755%)", }, { args: ["color(display-p3 1 0 1)"], - expect: "rgb(100% 8.637212218104592% 98.22133121285436%)" - } - ] + expect: "rgb(100% 8.637212218104592% 98.22133121285436%)", + }, + ], }, { @@ -143,29 +143,29 @@ export default { tests: [ { args: ["color(display-p3 1 0 0)"], - expect: "rgb(100% 0% 0%)" + expect: "rgb(100% 0% 0%)", }, { args: ["color(display-p3 0 1 0)"], - expect: "rgb(0% 75.29% 0%)" + expect: "rgb(0% 75.29% 0%)", }, { args: ["color(display-p3 0 0 1)"], - expect: "rgb(0% 0% 100%)" + expect: "rgb(0% 0% 100%)", }, { args: ["color(display-p3 1 1 0)"], - expect: "rgb(84.872% 84.872% 0%)" + expect: "rgb(84.872% 84.872% 0%)", }, { args: ["color(display-p3 0 1 1)"], - expect: "rgb(0% 76.098% 75.455%))" + expect: "rgb(0% 76.098% 75.455%))", }, { args: ["color(display-p3 1 0 1)"], - expect: "rgb(100% 0% 100%)" - } - ] + expect: "rgb(100% 0% 100%)", + }, + ], }, { name: "Using clipping", @@ -173,17 +173,17 @@ export default { tests: [ { args: ["color(display-p3 1 0 0)"], - expect: "rgb(100% 0% 0%)" + expect: "rgb(100% 0% 0%)", }, { args: ["color(display-p3 0 1 0)"], - expect: "rgb(0% 100% 0%)" + expect: "rgb(0% 100% 0%)", }, { args: ["color(display-p3 0 0 1)"], - expect: "rgb(0% 0% 100%)" + expect: "rgb(0% 0% 100%)", }, - ] + ], }, { name: "P3 primaries to sRGB, HCT chroma reduction", @@ -191,29 +191,29 @@ export default { tests: [ { args: ["color(display-p3 1 0 0)"], - expect: "rgb(100% 5.7911% 0%)" + expect: "rgb(100% 5.7911% 0%)", }, { args: ["color(display-p3 0 1 0)"], - expect: "rgb(0% 99.496% 0%)" + expect: "rgb(0% 99.496% 0%)", }, { args: ["color(display-p3 0 0 1)"], - expect: "rgb(0% 0% 100%)" + expect: "rgb(0% 0% 100%)", }, { args: ["color(display-p3 1 1 0)"], - expect: "rgb(99.749% 99.792% 0%)" + expect: "rgb(99.749% 99.792% 0%)", }, { args: ["color(display-p3 0 1 1)"], - expect: "rgb(0% 100% 99.135%)" + expect: "rgb(0% 100% 99.135%)", }, { args: ["color(display-p3 1 0 1)"], - expect: "rgb(100% 13.745% 96.626%)" - } - ] + expect: "rgb(100% 13.745% 96.626%)", + }, + ], }, { name: "HCT Gamut Mapping. Demonstrates tonal palettes (blue).", @@ -221,69 +221,69 @@ export default { tests: [ { args: ["color(--hct 282.762176394358 87.22803916105873 0)"], - expect: "rgb(0% 0% 0%)" + expect: "rgb(0% 0% 0%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 5)"], - expect: "rgb(0% 0.07618% 30.577%)" + expect: "rgb(0% 0.07618% 30.577%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 10)"], - expect: "rgb(0% 0.12788% 43.024%)" + expect: "rgb(0% 0.12788% 43.024%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 15)"], - expect: "rgb(0% 0.16162% 54.996%)" + expect: "rgb(0% 0.16162% 54.996%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 20)"], - expect: "rgb(0% 0.16388% 67.479%)" + expect: "rgb(0% 0.16388% 67.479%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 25)"], - expect: "rgb(0% 0.10802% 80.421%)" + expect: "rgb(0% 0.10802% 80.421%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 30)"], - expect: "rgb(0% 0% 93.775%)" + expect: "rgb(0% 0% 93.775%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 35)"], - expect: "rgb(10.099% 12.729% 100%)" + expect: "rgb(10.099% 12.729% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 40)"], - expect: "rgb(20.18% 23.826% 100%)" + expect: "rgb(20.18% 23.826% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 50)"], - expect: "rgb(35.097% 39.075% 100%)" + expect: "rgb(35.097% 39.075% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 60)"], - expect: "rgb(48.508% 51.958% 100%)" + expect: "rgb(48.508% 51.958% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 70)"], - expect: "rgb(61.603% 64.093% 100%)" + expect: "rgb(61.603% 64.093% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 80)"], - expect: "rgb(74.695% 75.961% 100%)" + expect: "rgb(74.695% 75.961% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 90)"], - expect: "rgb(87.899% 87.77% 100%)" + expect: "rgb(87.899% 87.77% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 95)"], - expect: "rgb(94.558% 93.686% 100%)" + expect: "rgb(94.558% 93.686% 100%)", }, { args: ["color(--hct 282.762176394358 87.22803916105873 100)"], - expect: "rgb(100% 100% 100%)" - } - ] + expect: "rgb(100% 100% 100%)", + }, + ], }, - ] + ], }; diff --git a/test/hpluv.js b/test/hpluv.js index 8ff9b3fa1..7f3df2c1c 100644 --- a/test/hpluv.js +++ b/test/hpluv.js @@ -31,24 +31,24 @@ const tests = { return checkProximity(actual, expect); }), data: { - epsilon: .00000001 + epsilon: .00000001, }, tests: [ { name: "sRGB to HPLuv", data: { - toSpace: "hpluv" + toSpace: "hpluv", }, - tests: srgbToHpluv + tests: srgbToHpluv, }, { name: "HPLuv to sRGB", data: { - toSpace: "srgb" + toSpace: "srgb", }, - tests: hpluvToSrgb - } - ] + tests: hpluvToSrgb, + }, + ], }; export default tests; diff --git a/test/hsluv.js b/test/hsluv.js index 40bc4731f..38ab31bc6 100644 --- a/test/hsluv.js +++ b/test/hsluv.js @@ -31,24 +31,24 @@ const tests = { return checkProximity(actual, expect); }), data: { - epsilon: .00000001 + epsilon: .00000001, }, tests: [ { name: "sRGB to HSLuv", data: { - toSpace: "hsluv" + toSpace: "hsluv", }, - tests: srgbToHsluv + tests: srgbToHsluv, }, { name: "HSLuv to sRGB", data: { - toSpace: "srgb" + toSpace: "srgb", }, - tests: hsluvToSrgb - } - ] + tests: hsluvToSrgb, + }, + ], }; export default tests; diff --git a/test/in_gamut.js b/test/in_gamut.js index 4badb88a5..285ccf4a3 100644 --- a/test/in_gamut.js +++ b/test/in_gamut.js @@ -13,94 +13,94 @@ export default { { name: "HSLuv (gamutSpace of srgb)", data: { - gamut: "hsluv" + gamut: "hsluv", }, tests: [ { args: "red", - expect: true + expect: true, }, { args: "color(--hsluv 150 100% 100%)", - expect: true + expect: true, }, { args: "color(display-p3 1 0 0)", - expect: false + expect: false, }, { args: "color(--hsluv 150 101% 50%)", - expect: false + expect: false, }, - ] + ], }, { name: "HPLuv (gamutSpace of 'self')", data: { - gamut: "hpluv" + gamut: "hpluv", }, tests: [ { args: "#cc99aa", - expect: true + expect: true, }, { args: "color(--hpluv 90 25% 75)", - expect: true + expect: true, }, { args: "red", - expect: false + expect: false, }, { args: "color(display-p3 1 0 0)", - expect: false + expect: false, }, - ] + ], }, { name: "Lab (unbounded color space)", data: { - gamut: "lab" + gamut: "lab", }, tests: [ { args: "lab(1000 1000 1000)", - expect: true - } - ] + expect: true, + }, + ], }, { name: "HSL (polar space, defaults to the base space)", data: { - gamut: "hsl" + gamut: "hsl", }, tests: [ { args: "hsl(0 100% 50%)", - expect: true + expect: true, }, { args: "hsl(0 101% 50%)", - expect: false + expect: false, }, { args: "color(display-p3 1 0 0)", - expect: false - } - ] + expect: false, + }, + ], }, { name: "Angle coordinates should not be gamut checked", data: { - gamut: "hpluv" + gamut: "hpluv", }, tests: [ { args: "color(--hpluv 720 50 25)", - expect: true - } - ] - } - ] + expect: true, + }, + ], + }, + ], }; diff --git a/test/index-fn.js b/test/index-fn.js index ba55bf33b..16a4a40f1 100644 --- a/test/index-fn.js +++ b/test/index-fn.js @@ -12,5 +12,5 @@ let tests = await Promise.all([ export default { name: "All Color.js tests", - tests + tests, }; diff --git a/test/parse.js b/test/parse.js index 84310ee02..4c232968d 100644 --- a/test/parse.js +++ b/test/parse.js @@ -23,338 +23,338 @@ const tests = { { name: "Color keyword", args: "blue", - expect: '{"spaceId":"srgb","coords":[0,0,1],"alpha":1}' + expect: '{"spaceId":"srgb","coords":[0,0,1],"alpha":1}', }, { name: "Color keyword", args: "transparent", - expect: '{"spaceId":"srgb","coords":[0,0,0],"alpha":0}' + expect: '{"spaceId":"srgb","coords":[0,0,0],"alpha":0}', }, { name: "#rrggbb", args: "#ff0066", - expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":1}' + expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":1}', }, { name: "#rgb", args: "#f06", - expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":1}' + expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":1}', }, { name: "#rrggbbaa", args: "#ff006688", - expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":0.5333333333333333}' + expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":0.5333333333333333}', }, { name: "#rgba", args: "#f068", - expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":0.5333333333333333}' + expect: '{"spaceId":"srgb","coords":[1,0,0.4],"alpha":0.5333333333333333}', }, { name: "rgba(% % % / a)", args: "rgba(0% 50% 200% / 0.5)", - expect: '{"spaceId":"srgb","coords":[0,0.5,2],"alpha":0.5}' + expect: '{"spaceId":"srgb","coords":[0,0.5,2],"alpha":0.5}', }, { name: "rgb(r g b / a)", args: "rgb(0 127.5 300 / .5)", - expect: '{"spaceId":"srgb","coords":[0,0.5,1.1764705882352942],"alpha":0.5}' + expect: '{"spaceId":"srgb","coords":[0,0.5,1.1764705882352942],"alpha":0.5}', }, { name: "rgba(n, n, n, a)", args: "rgba(0, 127.5, 300, 0.5)", - expect: '{"spaceId":"srgb","coords":[0,0.5,1.1764705882352942],"alpha":0.5}' + expect: '{"spaceId":"srgb","coords":[0,0.5,1.1764705882352942],"alpha":0.5}', }, { name: "angles not allowed in rgb()", args: "rgb(10deg 10 10)", - expect: "TypeError" - } - ] + expect: "TypeError", + }, + ], }, { name: "Lab and LCH colors", tests: [ { args: "lab(100% 0 0)", - expect: '{"spaceId":"lab","coords":[100,0,0],"alpha":1}' + expect: '{"spaceId":"lab","coords":[100,0,0],"alpha":1}', }, { name: "case", args: "Lab(100% 0 0)", - expect: '{"spaceId":"lab","coords":[100,0,0],"alpha":1}' + expect: '{"spaceId":"lab","coords":[100,0,0],"alpha":1}', }, { name: "no percent", args: "lab(80 0 0)", - expect: '{"spaceId":"lab","coords":[80,0,0],"alpha":1}' + expect: '{"spaceId":"lab","coords":[80,0,0],"alpha":1}', }, { args: "lab(100 -50 50)", - expect: '{"spaceId":"lab","coords":[100,-50,50],"alpha":1}' + expect: '{"spaceId":"lab","coords":[100,-50,50],"alpha":1}', }, { name: "lab percentage", args: "lab(50% 25% -25% / 50%)", - expect: '{"spaceId":"lab","coords":[50,31.25,-31.25],"alpha":0.5}' + expect: '{"spaceId":"lab","coords":[50,31.25,-31.25],"alpha":0.5}', }, { name: "lab transparency", args: "lab(100 -50 5 / .5)", - expect: '{"spaceId":"lab","coords":[100,-50,5],"alpha":0.5}' + expect: '{"spaceId":"lab","coords":[100,-50,5],"alpha":0.5}', }, { args: "lch(100% 0 0)", - expect: '{"spaceId":"lch","coords":[100,0,0],"alpha":1}' + expect: '{"spaceId":"lch","coords":[100,0,0],"alpha":1}', }, { name: "no percentage", args: "lch(100 50 50)", - expect: '{"spaceId":"lch","coords":[100,50,50],"alpha":1}' + expect: '{"spaceId":"lch","coords":[100,50,50],"alpha":1}', }, { name: "lch percentage", args: "lch(50% 50% 50 / 50%)", - expect: '{"spaceId":"lch","coords":[50,75,50],"alpha":0.5}' + expect: '{"spaceId":"lch","coords":[50,75,50],"alpha":0.5}', }, { name: "Hue over 360", args: "lch(100 50 450)", - expect: '{"spaceId":"lch","coords":[100,50,450],"alpha":1}' + expect: '{"spaceId":"lch","coords":[100,50,450],"alpha":1}', }, { name: "none hue", args: "lch(100 0 none)", - expect: '{"spaceId":"lch","coords":[100,0,null],"alpha":1}' - } - ] + expect: '{"spaceId":"lch","coords":[100,0,null],"alpha":1}', + }, + ], }, { name: "Oklab colors", tests: [ { args: "oklab(100% 0 0)", - expect: '{"spaceId":"oklab","coords":[1,0,0],"alpha":1}' + expect: '{"spaceId":"oklab","coords":[1,0,0],"alpha":1}', }, { name: "alpha", args: "oklab(100% 0 0 / 0.5)", - expect: '{"spaceId":"oklab","coords":[1,0,0],"alpha":0.5}' + expect: '{"spaceId":"oklab","coords":[1,0,0],"alpha":0.5}', }, { name: "case", args: "OKLab(100% 0 0)", - expect: '{"spaceId":"oklab","coords":[1,0,0],"alpha":1}' + expect: '{"spaceId":"oklab","coords":[1,0,0],"alpha":1}', }, { name: "all percentages", args: "oklab(42% 100% -50%)", - expect: '{"spaceId":"oklab","coords":[0.42,0.4,-0.2],"alpha":1}' + expect: '{"spaceId":"oklab","coords":[0.42,0.4,-0.2],"alpha":1}', }, { name: "all numbers", args: "oklab(1 -0.20 0.20)", - expect: '{"spaceId":"oklab","coords":[1,-0.2,0.2],"alpha":1}' + expect: '{"spaceId":"oklab","coords":[1,-0.2,0.2],"alpha":1}', }, { name: "all numbers out of range", args: "oklab(10 -0.80 0.80)", - expect: '{"spaceId":"oklab","coords":[10,-0.8,0.8],"alpha":1}' - } - ] + expect: '{"spaceId":"oklab","coords":[10,-0.8,0.8],"alpha":1}', + }, + ], }, { name: "Oklch colors", tests: [ { args: "oklch(100% 0 0)", - expect: '{"spaceId":"oklch","coords":[1,0,0],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[1,0,0],"alpha":1}', }, { name: "alpha", args: "oklch(100% 0 0 / 50%)", - expect: '{"spaceId":"oklch","coords":[1,0,0],"alpha":0.5}' + expect: '{"spaceId":"oklch","coords":[1,0,0],"alpha":0.5}', }, { name: "case", args: "OKLch(100% 0 0)", - expect: '{"spaceId":"oklch","coords":[1,0,0],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[1,0,0],"alpha":1}', }, { name: "all numbers", args: "oklch(1 0.2 50)", - expect: '{"spaceId":"oklch","coords":[1,0.2,50],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[1,0.2,50],"alpha":1}', }, { name: "all numbers out of range", args: "oklch(10 2 500 / 10)", - expect: '{"spaceId":"oklch","coords":[10,2,500],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[10,2,500],"alpha":1}', }, { name: "C as percentage", args: "oklch(100% 50% 50)", - expect: '{"spaceId":"oklch","coords":[1,0.2,50],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[1,0.2,50],"alpha":1}', }, { name: "C as percentage over 100%", args: "oklch(100% 150% 50)", - expect: '{"spaceId":"oklch","coords":[1,0.6000000000000001,50],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[1,0.6000000000000001,50],"alpha":1}', }, { name: "H as degrees", args: "oklch(100% 0 30deg)", - expect: '{"spaceId":"oklch","coords":[1,0,30],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[1,0,30],"alpha":1}', }, { name: "none hue", args: "oklch(1 0 none)", - expect: '{"spaceId":"oklch","coords":[1,0,null],"alpha":1}' + expect: '{"spaceId":"oklch","coords":[1,0,null],"alpha":1}', }, { name: "none alpha", args: "oklch(1 0 120 / none)", - expect: '{"spaceId":"oklch","coords":[1,0,120],"alpha":null}' - } - ] + expect: '{"spaceId":"oklch","coords":[1,0,120],"alpha":null}', + }, + ], }, { name: "color()", tests: [ { args: "color(srgb 0 1 .5)", - expect: '{"spaceId":"srgb","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"srgb","coords":[0,1,0.5],"alpha":1}', }, { args: "color(srgb 0 100% 50%)", - expect: '{"spaceId":"srgb","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"srgb","coords":[0,1,0.5],"alpha":1}', }, { args: "color(srgb-linear 0 1 .5)", - expect: '{"spaceId":"srgb-linear","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"srgb-linear","coords":[0,1,0.5],"alpha":1}', }, { args: "color(srgb-linear 0 100% 50%)", - expect: '{"spaceId":"srgb-linear","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"srgb-linear","coords":[0,1,0.5],"alpha":1}', }, { args: "color(display-p3 0 1 .5)", - expect: '{"spaceId":"p3","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"p3","coords":[0,1,0.5],"alpha":1}', }, { args: "color(display-p3 0% 100% 50%)", - expect: '{"spaceId":"p3","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"p3","coords":[0,1,0.5],"alpha":1}', }, { args: "color(rec2020 0 1 .5)", - expect: '{"spaceId":"rec2020","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"rec2020","coords":[0,1,0.5],"alpha":1}', }, { args: "color(rec2020 0 100% 50%)", - expect: '{"spaceId":"rec2020","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"rec2020","coords":[0,1,0.5],"alpha":1}', }, { args: "color(a98-rgb 0 1 .5)", - expect: '{"spaceId":"a98rgb","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"a98rgb","coords":[0,1,0.5],"alpha":1}', }, { args: "color(a98-rgb 0 100% 50%)", - expect: '{"spaceId":"a98rgb","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"a98rgb","coords":[0,1,0.5],"alpha":1}', }, { args: "color(prophoto-rgb 0 1 .5)", - expect: '{"spaceId":"prophoto","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"prophoto","coords":[0,1,0.5],"alpha":1}', }, { args: "color(prophoto-rgb 0 100% 50%)", - expect: '{"spaceId":"prophoto","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"prophoto","coords":[0,1,0.5],"alpha":1}', }, { args: "color(acescc 0 1 .5)", - expect: '{"spaceId":"acescc","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"acescc","coords":[0,1,0.5],"alpha":1}', }, { args: "color(acescc 0 100% 50%)", - expect: '{"spaceId":"acescc","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"acescc","coords":[0,1,0.5],"alpha":1}', }, { args: "color(acescg 0 1 .5)", - expect: '{"spaceId":"acescg","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"acescg","coords":[0,1,0.5],"alpha":1}', }, { args: "color(acescg 0 100% 50%)", - expect: '{"spaceId":"acescg","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"acescg","coords":[0,1,0.5],"alpha":1}', }, { args: "color(xyz 0 1 .5)", - expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}', }, { args: "color(xyz 0 100% 50%)", - expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}', }, { args: "color(xyz-d65 0 1 .5)", - expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}', }, { args: "color(xyz-d65 0 100% 50%)", - expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"xyz-d65","coords":[0,1,0.5],"alpha":1}', }, { args: "color(xyz-d50 0 1 .5)", - expect: '{"spaceId":"xyz-d50","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"xyz-d50","coords":[0,1,0.5],"alpha":1}', }, { args: "color(xyz-d50 0 100% 50%)", - expect: '{"spaceId":"xyz-d50","coords":[0,1,0.5],"alpha":1}' + expect: '{"spaceId":"xyz-d50","coords":[0,1,0.5],"alpha":1}', }, { args: "color(jzazbz 0 25% -50%)", - expect: '{"spaceId":"jzazbz","coords":[0,0.125,-0.25],"alpha":1}' + expect: '{"spaceId":"jzazbz","coords":[0,0.125,-0.25],"alpha":1}', }, { args: "color(--jzazbz 0 25% -50%)", - expect: '{"spaceId":"jzazbz","coords":[0,0.125,-0.25],"alpha":1}' + expect: '{"spaceId":"jzazbz","coords":[0,0.125,-0.25],"alpha":1}', }, { args: "color(--hct 0.25turn 50% 25)", - expect: '{"spaceId":"hct","coords":[90,72.5,25],"alpha":1}' + expect: '{"spaceId":"hct","coords":[90,72.5,25],"alpha":1}', }, { args: "color(--hsv 25deg 50% 75)", - expect: '{"spaceId":"hsv","coords":[25,50,75],"alpha":1}' + expect: '{"spaceId":"hsv","coords":[25,50,75],"alpha":1}', }, { name: "With transparency", args: "color(display-p3 0 1 0 / .5)", - expect: '{"spaceId":"p3","coords":[0,1,0],"alpha":0.5}' + expect: '{"spaceId":"p3","coords":[0,1,0],"alpha":0.5}', }, { name: "No arguments", args: "color(display-p3)", - expect: '{"spaceId":"p3","coords":[0,0,0],"alpha":1}' + expect: '{"spaceId":"p3","coords":[0,0,0],"alpha":1}', }, { name: "No arguments / alpha", args: "color(display-p3 / .5)", - expect: '{"spaceId":"p3","coords":[0,0,0],"alpha":0.5}' + expect: '{"spaceId":"p3","coords":[0,0,0],"alpha":0.5}', }, { name: "Fewer arguments", args: "color(display-p3 1)", - expect: '{"spaceId":"p3","coords":[1,0,0],"alpha":1}' + expect: '{"spaceId":"p3","coords":[1,0,0],"alpha":1}', }, { name: "Fewer arguments / alpha", args: "color(display-p3 1 / .5)", - expect: '{"spaceId":"p3","coords":[1,0,0],"alpha":0.5}' + expect: '{"spaceId":"p3","coords":[1,0,0],"alpha":0.5}', }, { name: "none red", args: "color(display-p3 none 1 .5)", - expect: '{"spaceId":"p3","coords":[null,1,0.5],"alpha":1}' - } - ] + expect: '{"spaceId":"p3","coords":[null,1,0.5],"alpha":1}', + }, + ], }, { name: "hsl()", @@ -362,70 +362,70 @@ const tests = { { name: "hsl(), commas", args: "hsl(180, 50%, 50%)", - expect: '{"spaceId":"hsl","coords":[180,50,50],"alpha":1}' + expect: '{"spaceId":"hsl","coords":[180,50,50],"alpha":1}', }, { name: "hsl(), negative hue", args: "hsl(-180, 50%, 50%)", - expect: '{"spaceId":"hsl","coords":[-180,50,50],"alpha":1}' + expect: '{"spaceId":"hsl","coords":[-180,50,50],"alpha":1}', }, { name: "hsl(), hue > 360", args: "hsl(900, 50%, 50%)", - expect: '{"spaceId":"hsl","coords":[900,50,50],"alpha":1}' + expect: '{"spaceId":"hsl","coords":[900,50,50],"alpha":1}', }, { name: "hsla(), degrees for hue, spaces and slash", args: "hsl(90deg 0% 0% / .5)", - expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}' + expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}', }, { name: "hsla(), rad for hue, spaces and slash", args: "hsl(1.5707963267948966rad 0% 0% / .5)", - expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}' + expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}', }, { name: "hsla(), grad for hue, spaces and slash", args: "hsl(100grad 0% 0% / .5)", - expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}' + expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}', }, { name: "hsla(), turns for hue, spaces and slash", args: "hsl(0.25turn 0% 0% / .5)", - expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}' + expect: '{"spaceId":"hsl","coords":[90,0,0],"alpha":0.5}', }, { name: "hsla(), none hue, spaces and slash", args: "hsl(none 0% 0% / .5)", - expect: '{"spaceId":"hsl","coords":[null,0,0],"alpha":0.5}' + expect: '{"spaceId":"hsl","coords":[null,0,0],"alpha":0.5}', }, { name: "hsla(), oog color(rec2020 0 0 1)", args: "hsl(230.6 179.7% 37.56% / 1)", - expect: '{"spaceId":"hsl","coords":[230.6,179.7,37.56],"alpha":1}' + expect: '{"spaceId":"hsl","coords":[230.6,179.7,37.56],"alpha":1}', }, { name: "hsl(), none hue ", args: "hsl(none, 50%, 50%)", - expect: '{"spaceId":"hsl","coords":[null,50,50],"alpha":1}' - } - ] + expect: '{"spaceId":"hsl","coords":[null,50,50],"alpha":1}', + }, + ], }, { name: "hwb()", tests: [ { args: "hwb(180 20% 30%)", - expect: '{"spaceId":"hwb","coords":[180,20,30],"alpha":1}' + expect: '{"spaceId":"hwb","coords":[180,20,30],"alpha":1}', }, { name: "none hue", args: "hwb(none 20% 30%)", - expect: '{"spaceId":"hwb","coords":[null,20,30],"alpha":1}' - } - ] - } - ] + expect: '{"spaceId":"hwb","coords":[null,20,30],"alpha":1}', + }, + ], + }, + ], }; export default tests; diff --git a/types/test/spaces.ts b/types/test/spaces.ts index 38fb58def..ee25b34ff 100644 --- a/types/test/spaces.ts +++ b/types/test/spaces.ts @@ -18,16 +18,16 @@ new ColorSpace({ coords: { a: { refRange: [0, 360], - name: "A" + name: "A", }, b: { range: [0, 100], - name: "B" + name: "B", }, c: { range: [0, 100], - name: "C" - } + name: "C", + }, }, white: "D50", cssId: "abc",