Package detail

@microsoft/fast-colors

Microsoft235.3kMIT5.3.1

A color utility for generating a range of colors from a single color

readme

FAST Colors

@microsoft/fast-colors includes a number of color classes and utilities designed to make parsing and manipulating colors easy, fast, and light-weight.

Color classes

There are a number of color classes exported for common color formats. These include:

  • ColorHSL
  • ColorHSV
  • ColorLAB
  • ColorLCH
  • ColorRGBA64 (note each channel is a number from 0-1)
  • ColorXYZ
const myColor: new ColorRGBA64(0, 0, 0, 1);

myColor.toStringHexRGB() // "#000000"

Color parsers

A number of color parsers are also available to parse a variety of different color formats.

  • parseColorHexRGB(raw: string): ColorRGBA64 | null parses #RGB or #RRGGBB color strings
  • parseColorHexARGB(raw: string): ColorRGBA64 | null parses #ARGB or #AARRGGBB color strings
  • parseColorHexRGBA(raw: string): ColorRGBA64 | null parses #RGBA or #RRGGBBAA color strings
  • parseColorWebRGB(raw: string): ColorRGBA64 | null parses #rgb(R, G, B) color strings
  • parseColorWebRGBA(raw: string): ColorRGBA64 | null parses #rgb(R, G, B, A) color strings
  • parseColorNamned(raw: string): ColorRGBA64 | null parses named color strings

Color Palette

A utility for creating a palette of colors from a source color and configuration options:

  • baseColor?: ColorRGBA64
  • steps?: number
  • interpolationMode?: ColorInterpolationSpace
  • scaleColorLight?: ColorRGBA64
  • scaleColorDark?: ColorRGBA64
  • clipLight?: number
  • clipDark?: number
  • saturationAdjustmentCutoff?: number
  • saturationLight?: number
  • saturationDark?: number
  • overlayLight?: number
  • overlayDark?: number
  • multiplyLight?: number
  • multiplyDark?: number

Example:

const palette: ColorPalette = new ColorPalette({
    baseColor: new ColorRGBA64(.4, .4, .7, 1),
    steps: 99,
    interpolationMode: ColorInterpolationSpace.RGB
})

Color converters

A number of color converters are available to convert one color format to the other. Each color accepts a color class of the source type and returns a color class of the converted type:

  • hslToRGB
  • rgbToHSL
  • rgbToHSV
  • hsvToRGB
  • lchToLAB
  • labToLCH
  • labToXYZ
  • xyzToLAB
  • rgbToXYZ
  • xyzToRGB
  • rgbToLAB
  • labToRGB
  • rgbToLCH
  • lchToRGB
const rgb: ColorRGBA64 = new ColorRGBA64(.5, .5, .5, 1);
const hsl: ColorHSL = rgbToHSL(rgb);

changelog

Change Log - @microsoft/fast-colors

This log was last generated on Wed, 01 Jun 2022 17:53:14 GMT and should not be manually modified.

5.3.1

Wed, 01 Jun 2022 17:53:14 GMT

Patches

  • Upgrade TypeScript (nicholasrice@users.noreply.github.com)

5.3.0

Wed, 27 Apr 2022 07:21:09 GMT

Minor changes

  • update to typescript 4.6.2 and update ARIAMixin typings (chhol@microsoft.com)

Patches

  • Bump @microsoft/eslint-config-fast-dna to v2.1.0 (chhol@microsoft.com)

5.2.0

Sun, 03 Apr 2022 07:12:01 GMT

Minor changes

  • Convert package to type:module (nicholasrice@users.noreply.github.com)

5.1.5

Wed, 09 Feb 2022 07:14:00 GMT

Patches

  • Updated calculateOverlayColor to automatically determine the overlay color (47367562+bheston@users.noreply.github.com)

5.1.4

Sun, 31 Oct 2021 07:17:45 GMT

Patches

  • update fast eslint package version (chhol@microsoft.com)

5.1.3 (2021-04-06)

Bug Fixes

  • labToLCH problem for colors where a and b are near zero (#4505) (2db4ae1)

5.1.2 (2021-02-08)

Note: Version bump only for package @microsoft/fast-colors

5.1.1 (2021-02-08)

Note: Version bump only for package @microsoft/fast-colors

5.1.0 (2020-07-14)

Features

  • update typescript version and remove utility types dependencies for react packages (#3422) (09d07b5)

5.0.12 (2020-07-02)

Note: Version bump only for package @microsoft/fast-colors

5.0.11 (2020-06-26)

Note: Version bump only for package @microsoft/fast-colors

5.0.9 (2020-05-18)

Note: Version bump only for package @microsoft/fast-colors

5.0.8 (2020-04-29)

Note: Version bump only for package @microsoft/fast-colors

5.0.7 (2020-04-27)

Note: Version bump only for package @microsoft/fast-colors

5.0.6 (2020-04-22)

Note: Version bump only for package @microsoft/fast-colors

5.0.5 (2020-04-10)

Note: Version bump only for package @microsoft/fast-colors

5.0.4 (2020-03-25)

Note: Version bump only for package @microsoft/fast-colors

5.0.3 (2020-03-13)

Note: Version bump only for package @microsoft/fast-colors

5.0.2 (2019-11-07)

Note: Version bump only for package @microsoft/fast-colors

5.0.1 (2019-10-25)

Note: Version bump only for package @microsoft/fast-colors

5.0.0 (2019-08-22)

Features

BREAKING CHANGES

  • removes named color exports.

Use parseColor to retrieve a ColorRGBA64 instance of a named color.

4.2.1 (2019-08-09)

Bug Fixes

  • add deprecation notice to namedColors export #2114 (38dcb1f)

4.2.0 (2019-07-01)

Features

4.1.2 (2019-06-25)

Note: Version bump only for package @microsoft/fast-colors

4.1.1 (2019-05-31)

Note: Version bump only for package @microsoft/fast-colors

4.1.0 (2019-04-23)

Features

  • add image palette extractor and advanced palette generation routines (#1675) (c9318c1)

4.0.1 (2019-04-09)

Note: Version bump only for package @microsoft/fast-colors

4.0.0 (2019-03-25)

Bug Fixes

  • fixes jest failure due to upgrade (543922b)
  • update to use esModuleInterop in the TypeScript configuration files (#1211) (2ec0644)

Features

  • add color identifier functions (#1471) (9431278)
  • add color library with color space conversions (rpg, hsl, hsv, xyz, lab, lch), blending functions, and palette generation (#1432) (fe10b9f)
  • adds shorthand hex parsing to color parsers (#1487) (e3d3397)
  • remove chroma from color utilities (#1482) (b82fe4c)
  • remove legacy color utils (#1557) (3f39ff9)

BREAKING CHANGES

  • removes legacy color utilities
  • This will affect how imports will be handled by consumers

3.2.1 (2019-03-19)

Bug Fixes

3.2.0 (2019-03-11)

Features

3.1.5 (2019-02-21)

Note: Version bump only for package @microsoft/fast-colors

3.1.4 (2019-02-07)

Note: Version bump only for package @microsoft/fast-colors

3.1.3 (2019-01-22)

Note: Version bump only for package @microsoft/fast-colors

2.2.1 (2018-09-24)

Note: Version bump only for package @microsoft/fast-colors

2.2.0 (2018-09-11)

Features

2.1.0 (2018-08-29)

Features

  • update Lerna to ^3.0.0 (#795) (9ce9a56)
  • upgrade to TypeScript 3.0.0 (#793) (e203e86)
  • fast-components-react-base: add callback to horizontal overflow to return and object that informs scroll start and end (#797) (37975f3)
  • paragraph: adds paragraph as a new MSFT component (#805) (8325d3f)

2.0.0-corrected (2018-08-03)

Bug Fixes

  • fix tslint globbing issue and enforce whitespace in import/export statements (#219) (4637a90)
  • travis-CI build-break (#336) (bffbf5e)
  • fast-components-react-msft: fixes error running jest with components that require chroma (#687) (140457c)

Features

  • Image: add new component and msft styles (#237) (ea057ed)
  • add color utility package (#138) (f666c23)
  • colors: add contrast and luminosity utilities (#751) (b0e0313)
  • add form generator to the packages (#311) (a339b3c)
  • add snapshot test suite (#207) (7ceaafe)
  • catagorizing relevant dependencies as peerDependencies (#186) (7e15db6)
  • remove JSS manager dependency from React base components (#148) (48de34a)
  • update code coverage on travis (#330) (63ab4f4)
  • detail view: add detail view (#470) (665b871)
  • fast-css-editor-react: add default editor component and position component (#636) (72037a8)
  • form generator: updates styles found in configuration pane (#420) (919121b)
  • toggle: add new component and msft styles (#212) (b9dd3e0)

2.1.0 (2018-08-29)

Features

  • update Lerna to ^3.0.0 (#795) (9ce9a56)
  • upgrade to TypeScript 3.0.0 (#793) (e203e86)
  • fast-components-react-base: add callback to horizontal overflow to return and object that informs scroll start and end (#797) (37975f3)
  • paragraph: adds paragraph as a new MSFT component (#805) (8325d3f)

2.0.0 (2018-08-02)

Bug Fixes

  • fast-components-react-msft: fixes error running jest with components that require chroma (#687) (140457c)

Features

  • colors: add contrast and luminosity utilities (#751) (b0e0313)
  • detail view: add detail view (#470) (665b871)
  • fast-css-editor-react: add default editor component and position component (#636) (72037a8)

1.9.0 (2018-07-14)

Bug Fixes

  • fast-components-react-msft: fixes error running jest with components that require chroma (#687) (140457c)

Features

  • detail view: add detail view (#470) (665b871)
  • fast-css-editor-react: add default editor component and position component (#636) (72037a8)

1.8.0 (2018-06-12)

1.7.0 (2018-06-01)

Features

1.6.0 (2018-05-16)

1.5.0 (2018-05-16)

Features

  • form generator: updates styles found in configuration pane (#420) (919121b)

1.4.0 (2018-05-14)

Features

  • form generator: updates styles found in configuration pane (#420) (919121b)

1.2.0 (2018-05-10)

1.1.0 (2018-05-09)

Bug Fixes

  • fix tslint globbing issue and enforce whitespace in import/export statements (#219) (4637a90)
  • travis-CI build-break (#336) (bffbf5e)

Features

  • add color utility package (#138) (f666c23)
  • Image: add new component and msft styles (#237) (ea057ed)
  • toggle: add new component and msft styles (#212) (b9dd3e0)
  • add form generator to the packages (#311) (a339b3c)
  • add snapshot test suite (#207) (7ceaafe)
  • catagorizing relevant dependencies as peerDependencies (#186) (7e15db6)
  • remove JSS manager dependency from React base components (#148) (48de34a)
  • update code coverage on travis (#330) (63ab4f4)