- colorutil
- draw
- draw
- draw
Get the endian used by the system.
https://developer.mozilla.org/en-US/docs/Glossary/Endianness
Returns number 0=little-endian, 1=big-endian, 2=unknown-endian
Run conversion functions for single color, array of colors or matrix of colors.
colors
any Array of colors or single colorconversionFunctions
...function Rest of the parameters are conversion functions which are executed in the order they are listed.
colorutil.convert(0xFF0000, colorutil.int.to.hex);
// output: "#ff0000"
colorutil.convert([0xFF0000, 0x00FF00], colorutil.int.to.hex);
// output: ["#ff0000", "#00ff00"]
colorutil.convert([[0xFF0000, 0x00FF00], 0x0000FF], colorutil.int.to.hex);
// output: [['#ff0000', '#00ff00'], '#0000ff']
colorutil.convert([[0xFF0000, 0x00FF00], 0x0000FF], colorutil.int.to.hex, colorutil.hex.to.cssrgb);
// output: [['rgb(255,0,0)', 'rgb(0,255,0)'], 'rgb(0,0,255)']
Returns Array
Stop gradient at the edge color
position
Repeat gradient with the same pattern
position
Immutable class which holds and caches all the color values
Create clone of this color.
Returns Color
Create clone of this color where hue is shifted to same as with the color in argument.
color
any Any color value
Returns Color
Create new color which is the hue color of this color. Cached
Returns Color
Rgb conversion functions
Rgb object notation is {r:RRR, g:GGG, b:BBB, a:AAA}
where each color component
(red, grean, blue, alpha) range is 0-255. In some conversion functions
alpha is not required. In those where it is required and not present in
rgb object, a fully opaque value is used as a default.
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
Creates a gradient.
options
Object Optionsoptions.colors
(Array | GradientData) Array of colors or instance of GradientData. There are multiple types of data structures. Data structure defines whether the gradient is one or two-dimensional.options.type
string Gradient type: linear | circular (optional, default'linear'
)options.verify
boolean Verify that each of the colors in colors property have valid data structure. If set to true, createGradient will throw an error if data structure is not correct. Data structure is tested from one sample to identify the data structure. This does not affect that behavior. (optional, defaultfalse
)options.validate
boolean Validate and add missing color stops and convert colors data structure to internal data structure (optional, defaulttrue
)options.defaultColor
function Default color used to fill the missing color components in gradient colors. If options.colors is GradientData, specify the defaultColor for GradientData instead. (optional, default{r:0,g:0,b:0,a:255}
)options.width
number Set size of the gradient in pixels. (optional, default100
)options.height
number Set size of the gradient in pixels. (optional, default100
)options.centerX
number Center position of a gradient. Value in range 0 to 1 where 0 is the left edge of the gradient and 1 is the right edge. centerX can be used with linear type of gradients to set point of rotation. (optional, default0
)options.centerY
number Center position of a gradient. Value in range 0 to 1 where 0 is the top edge of the gradient and 1 is the bottom edge. centerY can be used with linear type of gradients to set point of rotation. (optional, default0
)options.scale
number Scale of the gradient. Value in range 0 to 1. (optional, default1
)options.scaleX
number Scale of the gradient on x axis. Value in range 0 to 1. (optional, default1
)options.scaleY
number Scale of the gradient on y axis. Value in range 0 to 1. (optional, default1
)options.translateX
number Translate gradient along x axis. Value in range 0 to 1. (optional, default0
)options.translateY
number Translate gradient along y axis. Value in range 0 to 1. (optional, default0
)options.centralize
boolean Overrides translate values and automatically adjusts the positioning to the center. (optional, defaultfalse
)options.rotation
number Rotation of the gradient. Value in range 0 to 1. (optional, default0
)options.repeatX
function X repetition of gradient when calculating a color that is out of normal range 0 to 1. (optional, defaultcolorutil.repeat.repeat
)options.repeatY
function Y repetition of gradient when calculating a color that is out of normal range 0 to 1. (optional, defaultcolorutil.repeat.repeat
)
Returns function Function that calculates a color for a single point on gradient. Accepts x and y parameters. Though the x and y may exceed the limit, but gradient repeat will take effect.
Create a gradient data object which allows conversion between the supported data structures
data
Array Array of colors. There are multiple types of data structures.defaultColor
Object The default color (optional, default{r:0,g:0,b:0,a:255}
)
Returns GradientData
Returns Array Array of hue colors
rgb
Object Rgb object
Returns Object hue color in Rgb object notation
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to 24-bit number 0xRRGGBB
. Alpha is ignored.
rgb
Object
colorutil.rgb.to.int({r: 0, g: 128, b: 255});
// output: 33023
Returns number
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to 24-bit hex string '#RRGGBB'
. Alpha is ignored.
rgb
Object
colorutil.rgb.to.hex({r: 0, g: 128, b: 255});
// output: "#0080ff"
Returns string
Convert rgb object {r:RRR, g:GGG, b:BBB}
to rgb functional notation string 'rgb(RRR,GGG,BBB)'
.
Alpha is converted from range 0-255 to 0-1.
rgb
Object
colorutil.rgb.to.cssrgb({r: 0, g: 128, b: 255});
// output: "rgb(0,128,255)"
Returns string
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to rgb functional notation string 'rgba(RRR,GGG,BBB,A)'
.
Alpha is converted from range 0-255 to 0-1.
rgb
Object
colorutil.rgb.to.cssrgba({r: 0, g: 128, b: 255, a: 85});
// output: "rgba(0,128,255,0.3333333333333333)"
Returns string
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to 32-bit number 0xAABBGGRR
(little-endian)
Resulting value is positive
rgb
Object
colorutil.rgb.to.uintabgr({r: 0, g: 128, b: 255, a: 255});
// output: 4294934528
colorutil.rgb.to.uintabgr({r: 0, g: 128, b: 255, a: 85});
// output: 1442807808
Returns number
Convert rgb object {r:RRR, g:GGG, b:BBB}
to 32-bit number 0xAABBGGRR
(little-endian)
Alpha value is discarded and fully opaque value is used. Resulting value is positive
rgb
Object
colorutil.rgb.to.uintabgrOpaque({r: 0, g: 128, b: 255})
// output: 4294934528
Returns number
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to 32-bit number 0xRRGGBBAA
(big-endian)
Resulting value is positive
rgb
Object
colorutil.rgb.to.uintrgba({r: 0, g: 128, b: 255, a: 255});
// output: 8454143
colorutil.rgb.to.uintrgba({r: 0, g: 128, b: 255, a: 85});
// output: 8453973
Returns number
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to 32-bit number 0xAABBGGRR
(little-endian)
Resulting value can be negative.
rgb
Object
colorutil.rgb.to.intabgr({r: 0, g: 128, b: 255, a: 255});
// output: -32768
colorutil.rgb.to.intabgr({r: 0, g: 128, b: 255, a: 85});
// output: 1442807808
Returns number
Convert rgb object {r:RRR, g:GGG, b:BBB}
to 32-bit number 0xAABBGGRR
(little-endian)
Alpha value is discarded and fully opaque value is used. Resulting value can be negative.
rgb
Object
colorutil.rgb.to.intabgrOpaque({r: 0, g: 128, b: 255})
// output: -32768
Returns number
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to 32-bit number 0xRRGGBBAA
(big-endian).
Resulting value can be negative.
rgb
Object
colorutil.rgb.to.intrgba({r: 0, g: 128, b: 255, a: 255});
// output: 8454143
colorutil.rgb.to.intrgba({r: 0, g: 128, b: 255, a: 85});
// output: 8453973
Returns number
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to hsl object {h:H, s:S, l:L, a:A}
where h, s, l, a (saturation, luminosity, alpha) are in range 0-1.
rgb
Object
colorutil.rgb.to.hsl({r: 255, g: 0, b: 0, a: 255});
// output: {h: 0, s: 1, l: 0.5, a: 1}
Returns Object
Convert rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
to hsv object {h:H, s:S, v:V, a:A}
where h, s, v, a (hue, saturation, value, alpha) are in range 0-1.
rgb
Object
colorutil.rgb.to.hsv({r: 255, g: 0, b: 0, a: 255});
// output: {h: 0, s: 1, v: 1, a: 1}
Returns Object
Any conversion functions.
Converts color notations to any notation. (Except for Intrgba and Int32ABGR)
The any conversion functions provide an easy way to convert to specific notation without knowing the notation of a source color. This is just a collection of convenience methods making the usage a little bit easier. These functions are not as fast as the direct conversion functions.
Convert any color to rgb object notation {r:RRR, g:GGG, b:BBB, a:AAA}
color
Object Color in any notation
colorutil.any.to.rgb(0xFF0000);
// output: {r: 255, g: 0, b: 0, a: 255}
colorutil.any.to.rgb({h: 1/6, s: 0.5, l: 0.5});
// output: {r: 191, g: 191, b: 64, a: 255}
Returns Object
Convert any color to number notation 0xRRGGBB
color
Object Color in any notation
colorutil.any.to.int('hsl(180, 50%, 60%)');
// output: 6737100
Returns number
Convert any color to hex notation '#RRGGBB'
color
Object Color in any notation
colorutil.any.to.hex('hsl(180, 50%, 60%)');
// output: "#66cccc"
Returns string
Convert any color to rgb functional notation 'rgb(RRR,GGG,BBB)'
color
Object Color in any notation
colorutil.any.to.cssrgb('hsl(180, 50%, 60%)');
// output: "rgb(102,204,204)"
Returns string
Convert any color to rgb functional notation 'rgba(RRR,GGG,BBB,A)'
color
Object Color in any notation
colorutil.any.to.cssrgba('hsl(180, 50%, 60%)');
// output: "rgba(102,204,204,1)"
Returns string
Convert any color to hsl object notation {h:H, s:S, v:V, a:A}
color
Object Color in any notation
colorutil.any.to.hsl('hsl(180, 50%, 60%)');
// output: {h: 0.5, s: 0.5, l: 0.6, a: 1}
Returns Object
Convert any color to hsv object notation {h:H, s:S, v:V, a:A}
color
Object Color in any notation
colorutil.any.to.hsv('hsl(180, 50%, 60%)');
// output: {h: 0.5, s: 0.5000000000000001, v: 0.8, a: 1}
Returns Object
Convert any color to hsl functional notation string 'hsl(HHH,SSS%,LLL%)'
color
Object Color in any notation
colorutil.any.csshsl({h: 0.5, s: 0.5, l: 0.6, a: 1});
// output: "hsl(180,50%,60%)"
Returns string
Convert any color to hsl functional notation string 'hsla(HHH,SSS%,LLL%,A)'
color
Object Color in any notation
colorutil.any.csshsla({h: 0.5, s: 0.5, l: 0.6, a: 1});
// output: "hsla(180,50%,60%,1)"
Returns string
Number conversion functions.
Int notation is 24-bit number representing the RGB values 0xRRGGBB
.
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
24-bit number 0xRRGGBB
to rgb {r:RRR, g:GGG, b:BBB, a:AAA}
colorutil.int.to.rgb(0xFF0000);
// output: {r: 255, g: 0, b: 0, a: 255}
colorutil.int.to.rgb(0xFF0000, 128);
// output: {r: 255, g: 0, b: 0, a: 128}
Returns Object
24-bit number 0xRRGGBB
to 24-bit hex string '#RRGGBB'
.
int
number Integer
colorutil.int.to.hex(0x00FF00);
// output: "#00ff00"
Returns string
24-bit number 0xRRGGBB
to rgb functional notation string 'rgb(RRR,GGG,BBB)'
int
number Integer
colorutil.int.to.cssrgb(0x00FF00);
// output: "rgb(0,255,0)"
Returns string
24-bit number 0xRRGGBB
to rgb functional notation string 'rgba(RRR,GGG,BBB,A)'
colorutil.int.to.cssrgba(0x00FF00);
// output: "rgba(0,255,0,1)"
colorutil.int.to.cssrgba(0x00FF00, 0.5);
// output: "rgba(0,255,0,0.5)"
Returns string
Hexadecimal conversion functions
Hex notation is 24-bit hex string representing the RGB values '#RRGGBB'
.
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
24-bit hex string '#RRGGBB'
to rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
colorutil.hex.to.rgb('#00FF00');
// output: {r: 0, g: 255, b: 0, a: 255}
colorutil.hex.to.rgb('#00FF00', 127);
// output: {r: 0, g: 255, b: 0, a: 127}
Returns Object
24-bit hex string '#RRGGBB'
to 24-bit integer 0xRRGGBB
hex
string Hexadecimal string
colorutil.hex.to.int('#00FF00');
// output: 65280
Returns number
24-bit hex string '#RRGGBB'
to rgb functional notation string 'rgb(RRR,GGG,BBB)'
hex
string Hexadecimal string
colorutil.hex.to.cssrgb('#00FF00')
// output: "rgb(0,255,0)"
Returns string
24-bit hex string '#RRGGBB'
to rgb functional notation string 'rgba(RRR,GGG,BBB,A)'
colorutil.hex.to.cssrgba('#00FF00')
// output: "rgba(0,255,0,1)"
colorutil.hex.to.cssrgba('#00FF00', 0.5)
// output: "rgba(0,255,0,0.5)"
Returns string
cssrgb conversion functions
cssrgb notation is 'rgb(RRR,GGG,BBB)'
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
Rgb functional notation string 'rgb(RRR,GGG,BBB)'
to rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
colorutil.cssrgb.to.rgb('rgb(0,255,0)')
// output: {r: 0, g: 255, b: 0, a: 255}
Returns Object
Rgb functional notation string 'rgb(RRR,GGG,BBB)'
to 24-bit integer 0xRRGGBB
. Alpha is ignored.
cssrgb
string Rgba string
colorutil.cssrgb.to.int('rgb(0,255,0)')
// output: 65280
Returns number
Rgb functional notation string 'rgb(RRR,GGG,BBB)'
to hexadecimal string '#RRGGBB'
. Alpha is ignored.
cssrgb
string Rgb string
colorutil.cssrgb.to.hex('rgb(0,255,0)')
// output: "#00ff00"
Returns string
cssrgba conversion functions
cssrgba notation is 'rgba(RRR,GGG,BBB,A)'
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
Rgba functional notation string 'rgba(RRR,GGG,BBB,A)'
to rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
cssrgba
string Rgba string
colorutil.cssrgba.to.rgb('rgba(0,255,0,0.5)')
// output: {r: 0, g: 255, b: 0, a: 127}
Returns Object
Rgba functional notation string 'rgba(RRR,GGG,BBB,A)'
to 24-bit integer 0xRRGGBB
. Alpha is ignored.
cssrgba
string Rgba string
colorutil.cssrgba.to.int('rgba(0,255,0,0.5)')
// output: 65280
Returns number
Rgba functional notation string 'rgba(RRR,GGG,BBB,A)'
to hexadecimal string '#RRGGBB'
. Alpha is ignored.
cssrgba
string Rgba string
colorutil.cssrgba.to.hex('rgba(0,255,0,0.5)')
// output: "#00ff00"
Returns string
Hsl conversion functions
Hsl notation is {h:H, s:S, l:L, a:A}
where each component (hue, saturation,
luminosity, alpha) is in range 0-1.
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
Creates a gradient.
options
Object Options provided by useroptions.colors
(Array | GradientData) Array of colors or instance of GradientData. There are multiple types of data structures. Data structure defines whether the gradient is one or two-dimensional.options.type
string Gradient type: linear | circular (optional, default'linear'
)options.verify
boolean Verify that each of the colors in colors property have valid data structure. If set to true, createGradient will throw an error if data structure is not correct. Data structure is tested from one sample to identify the data structure. This does not affect that behavior. (optional, defaultfalse
)options.validate
boolean Validate and add missing color stops and convert colors data structure to internal data structure (optional, defaulttrue
)options.defaultColor
function Default color used to fill the missing color components in gradient colors. If options.colors is GradientData, specify the defaultColor for GradientData instead. (optional, default{h:0,s:0,l:0,a:1}
)options.width
number Set size of the gradient in pixels. (optional, default100
)options.height
number Set size of the gradient in pixels. (optional, default100
)options.centerX
number Center position of a gradient. Value in range 0 to 1 where 0 is the left edge of the gradient and 1 is the right edge. centerX can be used with linear type of gradients to set point of rotation. (optional, default0
)options.centerY
number Center position of a gradient. Value in range 0 to 1 where 0 is the top edge of the gradient and 1 is the bottom edge. centerY can be used with linear type of gradients to set point of rotation. (optional, default0
)options.scale
number Scale of the gradient. Value in range 0 to 1. (optional, default1
)options.scaleX
number Scale of the gradient on x axis. Value in range 0 to 1. (optional, default1
)options.scaleY
number Scale of the gradient on y axis. Value in range 0 to 1. (optional, default1
)options.translateX
number Translate gradient along x axis. Value in range 0 to 1. (optional, default0
)options.translateY
number Translate gradient along y axis. Value in range 0 to 1. (optional, default0
)options.centralize
boolean Overrides translate values and automatically adjusts the positioning to the center. (optional, defaultfalse
)options.rotation
number Rotation of the gradient. Value in range 0 to 1. (optional, default0
)options.repeatX
function X repetition of gradient when calculating a color that is out of normal range 0 to 1. (optional, defaultcolorutil.repeat.repeat
)options.repeatY
function Y repetition of gradient when calculating a color that is out of normal range 0 to 1. (optional, defaultcolorutil.repeat.repeat
)
Returns function Function that calculates a color for a single point on gradient. Accepts x and y parameters. Though the x and y may exceed the limit, but gradient repeat will take effect.
Create a gradient data object which allows conversion between the supported data structures
data
Array Array of colors. There are multiple types of data structures.defaultColor
Object The default color (optional, default{h:0,s:0,l:0,a:1}
)
Returns GradientData
Hsl object {h:H, s:S, l:L, a:A}
to rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
hsl
Object Hsl object
colorutil.hsl.to.rgb({h: 1/6, s: 0.5, l: 0.5});
// output: {r: 191, g: 191, b: 64, a: 255}
colorutil.hsl.to.rgb({h: 1/6, s: 0.5, l: 0.5, a: 0.5});
// output: {r: 191, g: 191, b: 64, a: 128}
Returns Object
Hsl object {h:H, s:S, l:L, a:A}
to hsv object {h:H, s:S, v:V, a:A}
hsl
Object Hsl object
colorutil.hsl.to.hsv({h: 1/6, s: 0.5, l: 0.5});
// output: {h: 0.16666666666666666, s: 0.6666666666666666, v: 0.75, a: 1}
Returns Object
Convert hsl object {h:H, s:S, l:L}
to hsl functional notation string 'hsl(HHH,SSS%,LLL%)'
.
hsl
Object
colorutil.hsl.to.cssHsl({h:2/6, s:0.5, l:0.5});
// output: "hsl(120,50%,50%)"
Returns string
Convert hsl object {h:H, s:S, l:L, a:A}
to hsl functional notation string 'hsla(HHH,SSS%,LLL%,A)'
.
hsl
Object
colorutil.hsl.to.csshsla({h:2/6, s:0.5, l:0.5, a:0.5});
// output: "hsla(120,50%,50%,0.5)"
Returns string
csshsl conversion functions
Hsl functional notation is 'hsl(HHH,SSS%,LLL%)'
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
Hsl functional notation string 'hsl(HHH,SSS%,LLL%)'
to hsl object {h:H, s:S, l:L, a:A}
colorutil.csshsl.to.hsl('hsl(180, 50%, 60%)');
// output: {h: 0.5, s: 0.5, l: 0.6, a: 1}
Returns Object
csshsla conversion functions
Hsla functional notation is 'hsla(HHH,SSS%,LLL%,A)'
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
Hsl functional notation string 'hsla(HHH,SSS%,LLL%,A)'
to hsl object {h:H, s:S, l:L, a:A}
csshsla
string Hsl string
colorutil.csshsla.to.hsl('hsla(180, 50%, 60%, 0.5)');
// output: {h: 0.5, s: 0.5, l: 0.6, a: 0.5}
Returns Object
Hsv conversion functions
Hsv notation is {h:H, s:S, v:V, a:A}
where each component
(hue, saturation, value, alpha) are in range 0-1.
Test validity of a color whether it is in correct notation for this class.
color
any The color
Returns boolean True if valid, False otherwise.
Creates a gradient.
options
Object Options provided by useroptions.colors
(Array | GradientData) Array of colors or instance of GradientData. There are multiple types of data structures. Data structure defines whether the gradient is one or two-dimensional.options.type
string Gradient type: linear | circular (optional, default'linear'
)options.verify
boolean Verify that each of the colors in colors property have valid data structure. If set to true, createGradient will throw an error if data structure is not correct. Data structure is tested from one sample to identify the data structure. This does not affect that behavior. (optional, defaultfalse
)options.validate
boolean Validate and add missing color stops and convert colors data structure to internal data structure (optional, defaulttrue
)options.defaultColor
function Default color used to fill the missing color components in gradient colors. If options.colors is GradientData, specify the defaultColor for GradientData instead. (optional, default{h:0,s:0,v:0,a:1}
)options.width
number Set size of the gradient in pixels. (optional, default100
)options.height
number Set size of the gradient in pixels. (optional, default100
)options.centerX
number Center position of a gradient. Value in range 0 to 1 where 0 is the left edge of the gradient and 1 is the right edge. centerX can be used with linear type of gradients to set point of rotation. (optional, default0
)options.centerY
number Center position of a gradient. Value in range 0 to 1 where 0 is the top edge of the gradient and 1 is the bottom edge. centerY can be used with linear type of gradients to set point of rotation. (optional, default0
)options.scale
number Scale of the gradient. Value in range 0 to 1. (optional, default1
)options.scaleX
number Scale of the gradient on x axis. Value in range 0 to 1. (optional, default1
)options.scaleY
number Scale of the gradient on y axis. Value in range 0 to 1. (optional, default1
)options.translateX
number Translate gradient along x axis. Value in range 0 to 1. (optional, default0
)options.translateY
number Translate gradient along y axis. Value in range 0 to 1. (optional, default0
)options.centralize
boolean Overrides translate values and automatically adjusts the positioning to the center. (optional, defaultfalse
)options.rotation
number Rotation of the gradient. Value in range 0 to 1. (optional, default0
)options.repeatX
function X repetition of gradient when calculating a color that is out of normal range 0 to 1. (optional, defaultcolorutil.repeat.repeat
)options.repeatY
function Y repetition of gradient when calculating a color that is out of normal range 0 to 1. (optional, defaultcolorutil.repeat.repeat
)
Returns function Function that calculates a color for a single point on gradient. Accepts x and y parameters. Though the x and y may exceed the limit, but gradient repeat will take effect.
Create a gradient data object which allows conversion between the supported data structures
data
Array Array of colors. There are multiple types of data structures.defaultColor
Object The default color (optional, default{h:0,s:0,v:0,a:1}
)
Returns GradientData
Hsv object {h:H, s:S, v:V, a:A}
to rgb object {r:RRR, g:GGG, b:BBB, a:AAA}
hsv
Object Hsv object
colorutil.hsv.to.rgb({h: 0, s: 1, v: 1});
// output: {r: 255, g: 0, b: 0, a: 255}
colorutil.hsv.to.rgb({h: 0, s: 1, v: 1, a: 0.5});
// output: {r: 255, g: 0, b: 0, a: 128}
Returns Object
Hsv object {h:H, s:S, v:V, a:A}
to hsl object {h:H, s:S, l:L, a:A}
hsv
Object Hsl object
colorutil.hsv.to.hsl({h: 1/6, s: 0.5, v: 0.5});
// output: {h: 0.16666666666666666, s: 0.3333333333333333, l: 0.375, a: 1}
Returns Object
Number conversion functions.
Int32 notation converion functions for 32-bit numbers 0xAABBGGRR
(little-endian).
32-bit number 0xAABBGGRR
(little-endian) to rgb {r:RRR, g:GGG, b:BBB, a:AAA}
int
number 32-bit number
colorutil.intabgr.to.rgb(0xFF112233)
// output: {a: 255, b: 17, g: 34, r: 51}
Returns Object
Number conversion functions.
Int32 notation converion functions for 32-bit numbers 0xRRGGBBAA
(big-endian).
32-bit number 0xRRGGBBAA
(big-endian) to rgb {r:RRR, g:GGG, b:BBB, a:AAA}
int
number 32-bit number
colorutil.intrgba.to.rgb(0xFF112233)
// output: {r: 255, g: 17, b: 34, a: 51}
Returns Object
Draw a gradient on canvas
target
(HTMLCanvasElement | string) The canvas on which gradient is drawn. Target may be canvas or css selector to canvas (evaluated with querySelector)options
(Object | Function) Options of gradient or gradient function
Draw a gradient on canvas
target
(HTMLCanvasElement | string) The canvas on which gradient is drawn. Target may be canvas or css selector to canvas (evaluated with querySelector)options
(Object | Function) Options of gradient or gradient function
Draw a gradient on canvas
target
(HTMLCanvasElement | string) The canvas on which gradient is drawn. Target may be canvas or css selector to canvas (evaluated with querySelector)options
(Object | Function) Options of gradient or gradient function