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}

Extracted kind

Values

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

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

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

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.