Skip to content

Commit

Permalink
docs: Tidy spelling inconsistencies (#66)
Browse files Browse the repository at this point in the history
* docs: tidy up inconsistencies
  • Loading branch information
Marabyte authored May 6, 2024
1 parent 2726662 commit 4eda577
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/CIEDE2000.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function ciede2000(colour1: LabColour, colour2: LabColour): number {
* Glossary
* L - Lightness as defined by L*a*b*
* a - Describes the green–red opponent colors as defined by L*a*b*
* b - Describes the blue–yellow opponent colors as defined by L*a*b*
* b - Describes the blue–yellow opponent colours as defined by L*a*b*
* C - Chroma as defined by CIE94
*
* Math notation
Expand Down Expand Up @@ -107,7 +107,7 @@ export function ciede2000(colour1: LabColour, colour2: LabColour): number {
/** Lightness Mean value*/
const = (L1 + L2) / 2;

/** Compensation for neutral colors (the primed values in the L*C*h differences) */
/** Compensation for neutral colours (the primed values in the L*C*h differences) */
const T =
1 -
0.17 * Math.cos(toRadians(H̅_d - 30)) +
Expand Down
12 changes: 12 additions & 0 deletions src/RGBdistance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { ciede2000 } from "./CIEDE2000.js";
import { convertRGBtoLab } from "./convertRGBtoLab.js";
import type { RGBColour } from "./types.js";

/**
* Calculate the distance between two RGB colours using the CIEDE2000 colour-difference formula.
*
* The CIEDE2000 colour-difference formula is a standard method for calculating the perceptual difference
* between two colours in the CIELAB colour space. It takes into account human visual perception and the
* non-linearities in how we perceive colour differences.
*
* @param colour1 - The first colour to compare.
* @param colour2 - The second colour to compare.
* @returns The distance between the two colours. Smaller numbers (minimum 0) mean the colours are more similar,
* larger numbers (typically not exceeding 100 for visible colours) indicate more dissimilar colours.
*/
export const RGBdistance = (colour1: RGBColour, colour2: RGBColour): number => {
const c1 = convertRGBtoLab(colour1);
const c2 = convertRGBtoLab(colour2);
Expand Down
8 changes: 4 additions & 4 deletions src/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "./util/regexers.js";

/**
* Determines whether a string represents a valid CSS RGB or RGBA color value.
* Determines whether a string represents a valid CSS RGB or RGBA colour value.
*
* Captures the folowing CSS RGB formats:
* - `rgb(0,0,0)`
Expand All @@ -21,7 +21,7 @@ import {
* - `rgb(0 0 0 / 50%)`
*
* @param {string} colour - The string to test.
* @returns {boolean} `true` if the string represents a valid CSS RGB or RGBA color value, `false` otherwise.
* @returns {boolean} `true` if the string represents a valid CSS RGB or RGBA colour value, `false` otherwise.
*/
export function isCSSRGBColour(colour: string): boolean {
return !!colour.match(cssRGBARegex);
Expand All @@ -43,10 +43,10 @@ export function isHexColour(colour: string): boolean {
}

/**
* Determines whether a string represents a valid named CSS color.
* Determines whether a string represents a valid named CSS colour.
*
* @param {NamedCSSColour} colour - The string to test.
* @returns {boolean} `true` if the string represents a valid named CSS color, `false` otherwise.
* @returns {boolean} `true` if the string represents a valid named CSS colour, `false` otherwise.
*/
export function isNamedCSSColour(
colour: NamedCSSColour,
Expand Down
8 changes: 4 additions & 4 deletions src/findNearestColour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { findNearestRGBColour } from "./findNearestRGBColour.js";
import type { NamedCSSColour, RGBColour } from "./types.js";

/**
* Finds the nearest color in a palette to a given color.
* Finds the nearest colour in a palette to a given colour.
*
* @param {string | NamedCSSColour} colour - The color to match. It can be a hexadecimal color, a CSS RGB color, or a named CSS color.
* @param {string[] | NamedCSSColour[]} palette - The palette of colors to search.
* @returns {string} The nearest color in the palette to the given color.
* @param {string | NamedCSSColour} colour - The colour to match. It can be a hexadecimal colour, a CSS RGB colour, or a named CSS colour.
* @param {string[] | NamedCSSColour[]} palette - The palette of colours to search.
* @returns {string} The nearest colour in the palette to the given colour.
*/
export function findNearestColour(
colour: string | NamedCSSColour,
Expand Down
6 changes: 3 additions & 3 deletions src/tests/getLuminance.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import test from "ava";
import { getSRGBLuminanceFromHex } from "../getSRGBLuminanceFromHex.js";

test("should return the luminance of a hex color", ({ is }) => {
test("should return the luminance of a hex colour", ({ is }) => {
is(getSRGBLuminanceFromHex("#444"), 0.05780543019106723);
});

test("should return the luminance of an 8-digit hex color", ({ is }) => {
test("should return the luminance of an 8-digit hex colour", ({ is }) => {
is(getSRGBLuminanceFromHex("#6564CDB3"), 0.16288822420427432);
});

test("should return the luminance of an 4-digit hex color", ({ is }) => {
test("should return the luminance of an 4-digit hex colour", ({ is }) => {
is(getSRGBLuminanceFromHex("#0f08"), 0.7152);
});
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface RGBColour {
export interface LabColour {
/** A number between 0 and 100 to describe the colour's lightness. (0 - black, 100 - white) */
L: number;
/** A number between -128 and 127 to describe the green–red opponent colors, with negative values toward green and positive values toward red */
/** A number between -128 and 127 to describe the green–red opponent colours, with negative values toward green and positive values toward red */
a: number;
/** A number between -128 and 127 to describe blue–yellow opponents, with negative numbers toward blue and positive toward yellow */
b: number;
Expand Down

0 comments on commit 4eda577

Please sign in to comment.