Generated ReScript API reference

rescript-tinycolor

ReScript bindings for @ctrl/tinycolor, providing typed color manipulation and conversion.

npm install rescript-tinycolor GitHub ↗ v5.1.3 · 129 API entries

Extracted kind

Types

type

t

Source ↗

A validated TinyColor instance.

type t
type

rgb

Source ↗

An RGB color with channels from 0 through 255.

type rgb = {r: int, g: int, b: int}
type

rgba

Source ↗

An RGB color with channels from 0 through 255 and alpha from 0.0 through 1.0.

type rgba = {r: int, g: int, b: int, a: float}
type

rgbaPercentage

Source ↗

An RGB color expressed as percentages and alpha from 0.0 through 1.0.

type rgbaPercentage = {
  r: string,
  g: string,
  b: string,
  a: float,
}
type

rgbRatio

Source ↗

An RGB color with channels expressed as ratios from 0.0 through 1.0.

type rgbRatio = {r: float, g: float, b: float}
type

rgbaRatio

Source ↗

An RGB color with channels and alpha expressed as ratios from 0.0 through 1.0.

type rgbaRatio = {r: float, g: float, b: float, a: float}
type

hsl

Source ↗

An HSL color with hue in degrees and saturation and lightness as ratios.

type hsl = {h: int, s: float, l: float}
type

hsla

Source ↗

An HSL color with hue in degrees and the other values expressed as ratios.

type hsla = {h: int, s: float, l: float, a: float}
type

hslRatio

Source ↗

An HSL color with every value expressed as a ratio from 0.0 through 1.0.

type hslRatio = {h: float, s: float, l: float}
type

hslaRatio

Source ↗

An HSLA color with every value expressed as a ratio from 0.0 through 1.0.

type hslaRatio = {h: float, s: float, l: float, a: float}
type

hsv

Source ↗

An HSV color with hue in degrees and saturation and value as ratios.

type hsv = {h: int, s: float, v: float}
type

hsva

Source ↗

An HSV color with hue in degrees and the other values expressed as ratios.

type hsva = {h: int, s: float, v: float, a: float}
type

hsvRatio

Source ↗

An HSV color with every value expressed as a ratio from 0.0 through 1.0.

type hsvRatio = {h: float, s: float, v: float}
type

hsvaRatio

Source ↗

An HSVA color with every value expressed as a ratio from 0.0 through 1.0.

type hsvaRatio = {h: float, s: float, v: float, a: float}
type

cmyk

Source ↗

A CMYK color with values from 0 through 100.

type cmyk = {c: int, m: int, y: int, k: int}
type Deprecated

randomConfigType

Source ↗

Deprecated configuration type retained for compatibility.

Deprecated. Pass labeled arguments directly to random or randomMultiple. Scheduled for removal in v6.
type randomConfigType = {
  hue?: [
    | #blue
    | #green
    | #monochrome
    | #orange
    | #pink
    | #purple
    | #red
    | #yellow
  ],
  luminosity?: [#bright | #dark | #light],
  seed?: int,
  alpha?: float,
  count?: int,
}
type Deprecated

wcagOptionType

Source ↗

Deprecated configuration type retained for compatibility.

Deprecated. Pass labeled arguments directly to isReadable. Scheduled for removal in v6.
type wcagOptionType = {
  level?: [#AA | #AAA],
  size?: [#large | #small],
}
type Deprecated

mostReadableConfigType

Source ↗

Deprecated configuration type retained for compatibility.

Deprecated. Pass labeled arguments directly to mostReadable. Scheduled for removal in v6.
type mostReadableConfigType = {
  includeFallbackColors?: bool,
  level?: [#AA | #AAA],
  size?: [#large | #small],
}

Extracted kind

Values

value Deprecated

rgbToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbToJs: rgb => {"b": int, "g": int, "r": int}
value Deprecated

rgbFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbFromJs: {.."b": int, "g": int, "r": int} => rgb
value Deprecated

rgbaToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbaToJs: rgba => {"a": float, "b": int, "g": int, "r": int}
value Deprecated

rgbaFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbaFromJs: {.."a": float, "b": int, "g": int, "r": int} => rgba
value Deprecated

rgbaPercentageToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbaPercentageToJs: rgbaPercentage => {
  "a": float,
  "b": string,
  "g": string,
  "r": string,
}
value Deprecated

rgbaPercentageFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbaPercentageFromJs: {..
  "a": float,
  "b": string,
  "g": string,
  "r": string,
} => rgbaPercentage
value Deprecated

rgbRatioToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbRatioToJs: rgbRatio => {"b": float, "g": float, "r": float}
value Deprecated

rgbRatioFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbRatioFromJs: {.."b": float, "g": float, "r": float} => rgbRatio
value Deprecated

rgbaRatioToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbaRatioToJs: rgbaRatio => {
  "a": float,
  "b": float,
  "g": float,
  "r": float,
}
value Deprecated

rgbaRatioFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let rgbaRatioFromJs: {..
  "a": float,
  "b": float,
  "g": float,
  "r": float,
} => rgbaRatio
value Deprecated

hslToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hslToJs: hsl => {"h": int, "l": float, "s": float}
value Deprecated

hslFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hslFromJs: {.."h": int, "l": float, "s": float} => hsl
value Deprecated

hslaToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hslaToJs: hsla => {"a": float, "h": int, "l": float, "s": float}
value Deprecated

hslaFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hslaFromJs: {.."a": float, "h": int, "l": float, "s": float} => hsla
value Deprecated

hslRatioToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hslRatioToJs: hslRatio => {"h": float, "l": float, "s": float}
value Deprecated

hslRatioFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hslRatioFromJs: {.."h": float, "l": float, "s": float} => hslRatio
value Deprecated

hslaRatioToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hslaRatioToJs: hslaRatio => {
  "a": float,
  "h": float,
  "l": float,
  "s": float,
}
value Deprecated

hslaRatioFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hslaRatioFromJs: {..
  "a": float,
  "h": float,
  "l": float,
  "s": float,
} => hslaRatio
value Deprecated

hsvToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvToJs: hsv => {"h": int, "s": float, "v": float}
value Deprecated

hsvFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvFromJs: {.."h": int, "s": float, "v": float} => hsv
value Deprecated

hsvaToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvaToJs: hsva => {"a": float, "h": int, "s": float, "v": float}
value Deprecated

hsvaFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvaFromJs: {.."a": float, "h": int, "s": float, "v": float} => hsva
value Deprecated

hsvRatioToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvRatioToJs: hsvRatio => {"h": float, "s": float, "v": float}
value Deprecated

hsvRatioFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvRatioFromJs: {.."h": float, "s": float, "v": float} => hsvRatio
value Deprecated

hsvaRatioToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvaRatioToJs: hsvaRatio => {
  "a": float,
  "h": float,
  "s": float,
  "v": float,
}
value Deprecated

hsvaRatioFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let hsvaRatioFromJs: {..
  "a": float,
  "h": float,
  "s": float,
  "v": float,
} => hsvaRatio
value Deprecated

cmykToJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Pass ReScript records to the public TinyColor APIs instead. Scheduled for removal in v6.
let cmykToJs: cmyk => {"c": int, "k": int, "m": int, "y": int}
value Deprecated

cmykFromJs

Source ↗

Deprecated generated interop helper retained for compatibility.

Deprecated. Use ReScript records with the public TinyColor APIs instead. Scheduled for removal in v6.
let cmykFromJs: {.."c": int, "k": int, "m": int, "y": int} => cmyk
value

isValid

Source ↗

Returns whether a TinyColor instance is valid.

let isValid: t => bool
value

isMonochrome

Source ↗

Returns whether a color has no saturation.

let isMonochrome: t => bool
value Deprecated

returnSomeIfValid

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use the makeFrom* functions, which validate their input. Scheduled for removal in v6.
let returnSomeIfValid: t => option<t>
value Deprecated

isFraction

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Validate application-specific ranges locally. Scheduled for removal in v6.
let isFraction: float => bool
value Deprecated

isValidHue

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Validate application-specific ranges locally. Scheduled for removal in v6.
let isValidHue: int => bool
value Deprecated

validateColorNumber

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromNumber, which validates the input and creates a color. Scheduled for removal in v6.
let validateColorNumber: int => option<int>
value Deprecated

validateRgb

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromRgb, which validates the input and creates a color. Scheduled for removal in v6.
let validateRgb: rgb => option<rgb>
value Deprecated

validateRgba

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromRgba, which validates the input and creates a color. Scheduled for removal in v6.
let validateRgba: rgba => option<rgba>
value Deprecated

validateHsl

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromHsl, which validates the input and creates a color. Scheduled for removal in v6.
let validateHsl: hsl => option<hsl>
value Deprecated

validateHsla

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromHsla, which validates the input and creates a color. Scheduled for removal in v6.
let validateHsla: hsla => option<hsla>
value Deprecated

validateHsv

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromHsv, which validates the input and creates a color. Scheduled for removal in v6.
let validateHsv: hsv => option<hsv>
value Deprecated

validateHsva

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromHsva, which validates the input and creates a color. Scheduled for removal in v6.
let validateHsva: hsva => option<hsva>
value Deprecated

validateCmyk

Source ↗

Deprecated validation helper retained for compatibility.

Deprecated. Use makeFromCmyk, which validates the input and creates a color. Scheduled for removal in v6.
let validateCmyk: cmyk => option<cmyk>
value Deprecated

make

Source ↗

Deprecated untyped constructor retained for compatibility.

Deprecated. Use the typed makeFrom* functions. Scheduled for removal in v6.
let make: 'tinyColor => t
value

makeFromString

Source ↗

Creates a color from a CSS color name, hex value, or color function.

let makeFromString: string => option<t>
value

makeFromNumber

Source ↗

Creates a color from a non-negative numeric color value.

let makeFromNumber: int => option<t>
value

makeFromRgb

Source ↗

Creates a color from RGB channels from 0 through 255.

let makeFromRgb: rgb => option<t>
value

makeFromRgba

Source ↗

Creates a color from RGB channels from 0 through 255 and alpha from 0.0 through 1.0.

let makeFromRgba: rgba => option<t>
value

makeFromRgbRatio

Source ↗

Creates a color from RGB channel ratios from 0.0 through 1.0.

let makeFromRgbRatio: rgbRatio => option<t>
value

makeFromRgbaRatio

Source ↗

Creates a color from RGB channel and alpha ratios from 0.0 through 1.0.

let makeFromRgbaRatio: rgbaRatio => option<t>
value

makeFromHsl

Source ↗

Creates a color from a hue in degrees and saturation and lightness ratios.

let makeFromHsl: hsl => option<t>
value

makeFromHsla

Source ↗

Creates a color from a hue in degrees and saturation, lightness, and alpha ratios.

let makeFromHsla: hsla => option<t>
value

makeFromHslRatio

Source ↗

Creates a color from HSL ratios from 0.0 through 1.0.

let makeFromHslRatio: hslRatio => option<t>
value

makeFromHslaRatio

Source ↗

Creates a color from HSLA ratios from 0.0 through 1.0.

let makeFromHslaRatio: hslaRatio => option<t>
value

makeFromHsv

Source ↗

Creates a color from a hue in degrees and saturation and value ratios.

let makeFromHsv: hsv => option<t>
value

makeFromHsva

Source ↗

Creates a color from a hue in degrees and saturation, value, and alpha ratios.

let makeFromHsva: hsva => option<t>
value

makeFromHsvRatio

Source ↗

Creates a color from HSV ratios from 0.0 through 1.0.

let makeFromHsvRatio: hsvRatio => option<t>
value

makeFromHsvaRatio

Source ↗

Creates a color from HSVA ratios from 0.0 through 1.0.

let makeFromHsvaRatio: hsvaRatio => option<t>
value

makeFromCmyk

Source ↗

Creates a color from CMYK values from 0 through 100.

let makeFromCmyk: cmyk => option<t>
value

getFormat

Source ↗

Returns the format used to create the color.

let getFormat: t => string
value

getOriginalInput

Source ↗

Returns the original color input.

let getOriginalInput: t => 'tinyColor
value

getBrightness

Source ↗

Returns perceived brightness from 0.0 through 255.0.

let getBrightness: t => float
value

isLight

Source ↗

Returns whether the color is considered light.

let isLight: t => bool
value

isDark

Source ↗

Returns whether the color is considered dark.

let isDark: t => bool
value

getLuminance

Source ↗

Returns relative luminance from 0.0 through 1.0.

let getLuminance: t => float
value

getAlpha

Source ↗

Returns alpha from 0.0 through 1.0.

let getAlpha: t => float
value

setAlpha

Source ↗

Returns a copy with the supplied alpha value.

let setAlpha: (float, t) => t
value

toNumber

Source ↗

Returns the numeric RGB representation of the color.

let toNumber: t => int
value

clone

Source ↗

Returns a copy of the color.

let clone: t => t
value

onBackground

Source ↗

Composites the color over a background color.

let onBackground: (t, t) => t
value

toHsv

Source ↗

Converts the color to HSVA.

let toHsv: t => hsva
value

toHsvString

Source ↗

Converts the color to an HSV or HSVA string.

let toHsvString: t => string
value

toHsl

Source ↗

Converts the color to HSLA.

let toHsl: t => hsla
value

toHslString

Source ↗

Converts the color to an HSL or HSLA string.

let toHslString: t => string
value

toHex

Source ↗

Converts the color to a hex value without a leading hash.

let toHex: t => string
value

toHexString

Source ↗

Converts the color to a six-digit hex string.

let toHexString: t => string
value

toHex8

Source ↗

Converts the color to an eight-digit hex value without a leading hash.

let toHex8: t => string
value

toHex8String

Source ↗

Converts the color to an eight-digit hex string.

let toHex8String: t => string
value

toHexShortString

Source ↗

Converts the color to the shortest equivalent hex string.

let toHexShortString: t => string
value

toRgb

Source ↗

Converts the color to RGBA.

let toRgb: t => rgba
value

toRgbString

Source ↗

Converts the color to an RGB or RGBA string.

let toRgbString: t => string
value

toPercentageRgb

Source ↗

Converts the color to percentage RGBA.

let toPercentageRgb: t => rgbaPercentage
value

toPercentageRgbString

Source ↗

Converts the color to a percentage RGB or RGBA string.

let toPercentageRgbString: t => string
value

toCmyk

Source ↗

Converts the color to CMYK.

let toCmyk: t => cmyk
value

toCmykString

Source ↗

Converts the color to a CMYK string.

let toCmykString: t => string
value

toName

Source ↗

Returns the CSS color name when one exactly matches.

let toName: t => option<'a>
value

toMsFilter

Source ↗

Creates a Microsoft gradient filter from two color strings.

let toMsFilter: (string, string) => string
value

toString

Source ↗

Converts the color to a string using its original format when possible.

let toString: t => string
value Deprecated

callIfValidModificationValue

Source ↗

Deprecated modification helper retained for compatibility.

Deprecated. Use lighten, brighten, darken, tint, shade, desaturate, saturate, or mix. Scheduled for removal in v6.
let callIfValidModificationValue: (int, ('a, int) => 'b, 'a) => option<'b>
value

lighten

Source ↗

Lightens the color by a percentage from 0 through 100.

let lighten: (~value: int=?, t) => option<t>
value

brighten

Source ↗

Brightens the color by a percentage from 0 through 100.

let brighten: (~value: int=?, t) => option<t>
value

darken

Source ↗

Darkens the color by a percentage from 0 through 100.

let darken: (~value: int=?, t) => option<t>
value

tint

Source ↗

Mixes the color with white by a percentage from 0 through 100.

let tint: (~value: int=?, t) => option<t>
value

shade

Source ↗

Mixes the color with black by a percentage from 0 through 100.

let shade: (~value: int=?, t) => option<t>
value

desaturate

Source ↗

Decreases saturation by a percentage from 0 through 100.

let desaturate: (~value: int=?, t) => option<t>
value

saturate

Source ↗

Increases saturation by a percentage from 0 through 100.

let saturate: (~value: int=?, t) => option<t>
value

spin

Source ↗

Rotates the hue by the supplied number of degrees.

let spin: (~value: int=?, t) => t
value

mix

Source ↗

Mixes two colors using a percentage from 0 through 100.

let mix: (~value: int=?, t, t) => option<t>
value

greyscale

Source ↗

Returns the greyscale equivalent of the color.

let greyscale: t => t
value

analogous

Source ↗

Returns an analogous color scheme.

let analogous: (t, ~results: int=?, ~slices: int=?, unit) => array<t>
value

monochromatic

Source ↗

Returns a monochromatic color scheme.

let monochromatic: (t, ~results: int=?, unit) => array<t>
value

splitcomplement

Source ↗

Returns a split-complementary color scheme.

let splitcomplement: t => array<t>
value

triad

Source ↗

Returns a triadic color scheme.

let triad: t => array<t>
value

tetrad

Source ↗

Returns a tetradic color scheme.

let tetrad: t => array<t>
value

polyad

Source ↗

Returns a color scheme with the requested number of colors.

let polyad: (t, ~n: int=?, unit) => array<t>
value

complement

Source ↗

Returns the complementary color.

let complement: t => t
value

equals

Source ↗

Returns whether two colors have the same RGB and alpha values.

let equals: (t, t) => bool
value

random

Source ↗

Returns a random color.

let random: (
  ~hue: [
    | #blue
    | #green
    | #monochrome
    | #orange
    | #pink
    | #purple
    | #red
    | #yellow
  ]=?,
  ~luminosity: [#bright | #dark | #light]=?,
  ~seed: int=?,
  ~alpha: float=?,
  unit,
) => t
value

randomMultiple

Source ↗

Returns the requested number of random colors.

let randomMultiple: (
  ~hue: [
    | #blue
    | #green
    | #monochrome
    | #orange
    | #pink
    | #purple
    | #red
    | #yellow
  ]=?,
  ~luminosity: [#bright | #dark | #light]=?,
  ~seed: int=?,
  ~alpha: float=?,
  ~count: int,
  unit,
) => array<t>
value

readability

Source ↗

Returns the WCAG contrast ratio between two colors.

let readability: (t, t) => float
value

isReadable

Source ↗

Returns whether two colors meet the requested WCAG readability level.

let isReadable: (
  ~level: [#AA | #AAA]=?,
  ~size: [#large | #small]=?,
  t,
  t,
) => bool
value Deprecated

mostReadableNullable

Source ↗

Deprecated nullable binding retained for compatibility.

Deprecated. Use mostReadable, which returns option<t>. Scheduled for removal in v6.
let mostReadableNullable: (t, array<t>, 'config) => Null.t<t>
value

mostReadable

Source ↗

Returns the most readable color from a list of candidates.

let mostReadable: (
  ~includeFallbackColors: bool=?,
  ~level: [#AA | #AAA]=?,
  ~size: [#large | #small]=?,
  array<t>,
  t,
) => option<t>

No API entries match that search.