Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/colorModels/cmykString.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { RgbaColor } from "../types";
import { clampCmyka, cmykaToRgba, rgbaToCmyka, roundCmyka } from "./cmyk";

const cmykMatcher = /^device-cmyk\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
const cmykMatcher = /^device-cmyk\(\s*([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)%(?:\s*\/\s*([+-]?\d{1,3}(?:\.\d+)?)%)?\)$/i;


/**
* Parses a valid CMYK CSS color function/string
Expand Down
4 changes: 2 additions & 2 deletions src/colorModels/hslString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { clampHsla, rgbaToHsla, hslaToRgba, roundHsla } from "./hsl";

// Functional syntax
// hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )
const commaHslaMatcher = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
const commaHslaMatcher = /^hsla?\(\s*([+-]?\d{1,3})(deg|rad|grad|turn)?\s*,\s*([+-]?\d{1,3})%\s*,\s*([+-]?\d{1,3})%\s*(?:,\s*([+-]?\d*\.?\d{1,3})(%)?\s*)?\)$/i;

// Whitespace syntax
// hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? )
const spaceHslaMatcher = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
const spaceHslaMatcher = /^hsla?\(\s*([+-]?\d{1,3}(?:\.\d+)?)\s*(deg|rad|grad|turn)?\s+([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)%\s*(?:\/\s*([+-]?\d{1,3}(?:\.\d+)?)%)?\)$/i;

/**
* Parses a valid HSL[A] CSS color function/string
Expand Down
2 changes: 1 addition & 1 deletion src/colorModels/hwbString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { clampHwba, rgbaToHwba, hwbaToRgba, roundHwba } from "./hwb";

// The only valid HWB syntax
// hwb( <hue> <percentage> <percentage> [ / <alpha-value> ]? )
const hwbaMatcher = /^hwb\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
const hwbaMatcher = /^hwb\(\s*([+-]?\d{1,3}(?:\.\d+)?)\s*(deg|rad|grad|turn)?\s+([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)%\s*(?:\/\s*([+-]?\d{1,3}(?:\.\d+)?)%)?\)$/i;

/**
* Parses a valid HWB[A] CSS color function/string
Expand Down
2 changes: 1 addition & 1 deletion src/colorModels/lchString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { clampLcha, rgbaToLcha, lchaToRgba, roundLcha } from "./lch";

// The only valid LCH syntax
// lch() = lch( <percentage> <number> <hue> [ / <alpha-value> ]? )
const lchaMatcher = /^lch\(\s*([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
const lchaMatcher = /^lch\(\s*([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)\s+([+-]?\d{1,3}(?:\.\d+)?)\s*(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d{1,3}(?:\.\d+)?)%)?\)$/i;

/**
* Parses a valid LCH CSS color function/string
Expand Down
4 changes: 2 additions & 2 deletions src/colorModels/rgbString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { roundRgba, clampRgba } from "./rgb";
// Functional syntax
// rgb( <percentage>#{3} , <alpha-value>? )
// rgb( <number>#{3} , <alpha-value>? )
const commaRgbaMatcher = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
const commaRgbaMatcher = /^rgba?\(\s*([+-]?\d{1,3}(?:\.\d+)?)%\s*,\s*([+-]?\d{1,3}(?:\.\d+)?)%\s*,\s*([+-]?\d{1,3}(?:\.\d+)?)%\s*(?:,\s*([+-]?\d{1,3}(?:\.\d+)?)%)?\)$/i;

// Whitespace syntax
// rgb( <percentage>{3} [ / <alpha-value> ]? )
// rgb( <number>{3} [ / <alpha-value> ]? )
const spaceRgbaMatcher = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
const spaceRgbaMatcher = /^rgba?\(\s*([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)%\s+([+-]?\d{1,3}(?:\.\d+)?)%\s*(?:\/\s*([+-]?\d{1,3}(?:\.\d+)?)%)?\)$/i;

/**
* Parses a valid RGB[A] CSS color function/string
Expand Down