ig.

utilscolor

Static utilities for fill styles and color conversions.

Author:
  • Collin Hover - collinhover.com
Source:

<static> CSSToRGBA

Converts between style, i.e. rgb()/rgba()/etc, and RGBA values. IMPORTANT: this method has a relatively higher performance cost, avoid when possible.

Source:

<static> hexToRGBA(hex)

Converts between hex and RGBA values.

Parameters:
Name Type Description
hex Number hex color value.
Source:

<static> linearGradient(minX, minY, maxX, maxY, colors)

Creates canvas linear gradient fillStyle.

Parameters:
Name Type Description
minX Number x position of start of gradient.
minY Number y position of start of gradient.
maxX Number x position of end of gradient.
maxY Number y position of end of gradient.
colors Array list of colors in CSS style #000000 / rgb() / rgba() or object {r:0,g:0,b:0,a:0} format.
Source:

<static> radialGradient(radius, colors) → {Gradient}

Creates canvas radial gradient fillStyle.

Parameters:
Name Type Description
radius Number radius of gradient
colors Array list of colors in CSS style #000000 / rgb() / rgba() or object {r:0,g:0,b:0,a:0} format
Source:
Returns:
{ Gradient } canvas 2d gradient

<static> RGBAToCSS(r, g, b, a)

Converts r,g,b,a values to rgba() CSS style.

Parameters:
Name Type Description
r Number red value from 0 to 1.
g Number green value from 0 to 1.
b Number blue value from 0 to 1.
a Number alpha value from 0 to 1.
Source:

<static> RGBAToHex(r, g, b, a)

Converts r,g,b,a values to hex color.

Parameters:
Name Type Description
r Number red value from 0 to 1.
g Number green value from 0 to 1.
b Number blue value from 0 to 1.
a Number alpha value from 0 to 1.
Source:

<static> RGBToCSS(r, g, b)

Converts r,g,b values to rgb() CSS style.

Parameters:
Name Type Description
r Number red value from 0 to 1.
g Number green value from 0 to 1.
b Number blue value from 0 to 1.
Source:

<static> RGBToHex(r, g, b)

Converts r,g,b,a values to hex color.

Parameters:
Name Type Description
r Number red value from 0 to 1.
g Number green value from 0 to 1.
b Number blue value from 0 to 1.
Source: