diff --git a/public/lang-docs.md b/public/lang-docs.md index 0ab166c6..162984c3 100644 --- a/public/lang-docs.md +++ b/public/lang-docs.md @@ -1144,6 +1144,16 @@ Description: Categorical values should have an even distribution around the hue Natural Language: (std(speed(sort(colors, x => lch.h(x)), => )) < 10 or std(speed(sort(colors, x => lch.h(x) + 180 % 360), => )) < 10) +Palettes that will fail this test: + +- #ffb9ba, #67de25, #25d4c3, #724dd6, #6d0e44 with a #fff background + + + +Palettes that will pass this test: + +- #ffc5b8, #00dec1, #006095, #b7d119, #6e0074 with a #fff background + Program: diff --git a/src/lib/ColorLint.test.ts b/src/lib/ColorLint.test.ts index f71abe93..87214ade 100644 --- a/src/lib/ColorLint.test.ts +++ b/src/lib/ColorLint.test.ts @@ -15,6 +15,7 @@ import BackgroundContrast from "./lints/background-contrast"; import CatOrderSimilarity from "./lints/cat-order-similarity"; import ColorBlindness from "./lints/color-blindness"; import ColorNameDiscriminability, { getName } from "./lints/name-discrim"; +import EvenDistribution from "./lints/even-distribution"; import Fair from "./lints/fair"; import Gamut from "./lints/in-gamut"; import MaxColors from "./lints/max-colors"; @@ -59,6 +60,10 @@ test("ColorLint - UglyColors", () => { autoTest(UglyColors); }); +test("ColorLint - EvenDistribution", () => { + autoTest(EvenDistribution); +}); + test("ColorLint - Fair Nominal", () => { autoTest(Fair[0]); }); diff --git a/src/lib/__snapshots__/ColorLint.test.ts.snap b/src/lib/__snapshots__/ColorLint.test.ts.snap index 1ef81b0d..c3de6d6c 100644 --- a/src/lib/__snapshots__/ColorLint.test.ts.snap +++ b/src/lib/__snapshots__/ColorLint.test.ts.snap @@ -52,6 +52,10 @@ exports[`ColorLint - ColorNameDiscriminability 1`] = `"The following pairs of co exports[`ColorLint - ColorNameDiscriminability 2`] = `"The following pairs of colors have the same name: #5260d1 and #005ebe"`; +exports[`ColorLint - EvenDistribution 1`] = `"This palette does not evenly distribute the colors around its range correctly. Try making the spacing between the colors more regular to resolve this issue. "`; + +exports[`ColorLint - EvenDistribution 2`] = `"This palette does not evenly distribute the colors around its range correctly. Try making the spacing between the colors more regular to resolve this issue. "`; + exports[`ColorLint - Fair Nominal 1`] = `"This palette is unfair (meaning that some values may unduely stand out). Note that this check is naturally at odds with color blind friendly palettes. Maximum chroma range: 80, maximum luminance range: 50."`; exports[`ColorLint - Fair Nominal 2`] = `"This palette is unfair (meaning that some values may unduely stand out). Note that this check is naturally at odds with color blind friendly palettes. Maximum chroma range: 80, maximum luminance range: 50."`; diff --git a/src/lib/__snapshots__/LintDocs.test.ts.snap b/src/lib/__snapshots__/LintDocs.test.ts.snap index 64f6a621..a2c632c2 100644 --- a/src/lib/__snapshots__/LintDocs.test.ts.snap +++ b/src/lib/__snapshots__/LintDocs.test.ts.snap @@ -1147,6 +1147,16 @@ Description: Categorical values should have an even distribution around the hue Natural Language: (std(speed(sort(colors, x => lch.h(x)), => )) < 10 or std(speed(sort(colors, x => lch.h(x) + 180 % 360), => )) < 10) +Palettes that will fail this test: + +- #ffb9ba, #67de25, #25d4c3, #724dd6, #6d0e44 with a #fff background + + + +Palettes that will pass this test: + +- #ffc5b8, #00dec1, #006095, #b7d119, #6e0074 with a #fff background + Program: diff --git a/src/lib/lints/affects.ts b/src/lib/lints/affects.ts index a7334e24..0e3eb735 100644 --- a/src/lib/lints/affects.ts +++ b/src/lib/lints/affects.ts @@ -27,6 +27,8 @@ theseAffects.forEach((affect) => { failMessage: `This palette has colors which are highly saturated and light, which may not be appropriate for a ${affect} palette.`, id: `saturated-${affect}-built-in`, blameMode: "single", + expectedPassingTests: [], + expectedFailingTests: [], }; lints.push(lint); }); diff --git a/src/lib/lints/even-distribution.ts b/src/lib/lints/even-distribution.ts index 28f5853c..ca8191cb 100644 --- a/src/lib/lints/even-distribution.ts +++ b/src/lib/lints/even-distribution.ts @@ -46,5 +46,11 @@ const lint: CustomLint = { failMessage: `This palette does not evenly distribute the colors around its range correctly. Try making the spacing between the colors more regular to resolve this issue. `, id: "even-colors-built-in", blameMode: "none", + expectedPassingTests: [ + makePalFromString(["#ffc5b8", "#00dec1", "#006095", "#b7d119", "#6e0074"]), + ], + expectedFailingTests: [ + makePalFromString(["#ffb9ba", "#67de25", "#25d4c3", "#724dd6", "#6d0e44"]), + ], }; export default lint;