// Create a color from an array
col = hx.color([123,190,49,1])
// Create a color from a css string
col = hx.color('#7BBE31')
col = hx.color('rgb(123,190,49)')
col = hx.color('rgba(123,190,49,1)')
col = hx.color('hsl(88.5,59%,46.9%)')
col = hx.color('hsla(88.5,59%,46.9%,1)')
// Output a color to an array
col.rgb() // returns [123, 190, 49, 1]
// Lighten a color
hx.color([50,50,50]).lighten(0.5) // returns color object equivalent to [75,75,75,1]
// Darken a color
hx.color([50,50,50]).lighten(-0.5) // returns color object equivalent to [25,25,25,1]
// Mix colors on a 50/50 ratio
hx.color([50,50,50]).mix(hx.color([100,100,100])) // returns color object equivalent to [75,75,75,1]
// Mix colors on a 70/30 ratio
hx.color([50,50,50]).mix(hx.color([100,100,100]), 0.3) // returns color object equivalent to [65,65,65,1]
hx.isColor
hx.color(255, 255, 255)
hx.color(255, 255, 255, 1)
Color
prototype contains several methods to allow for modification of a color. toString()
method to show the hex value and set the background color of the cells. exCol
is the example color object that we are manipulating. clone()
function returns a new color with the same r, g, b and a values as the current color. Cloning a color object is useful for situations where you need a version of a color without modifying the original value. The methods on the Color
class all modify the selected object. Cloning is useful for situations where you need a new version of a color without altering the original. newColor = exCol.clone()
newColor
object can be modified freely without altering exCol
color. exCol.alpha(0.7) | exCol.fade(0.2) | exCol.fade(-0.2) | exCol.alpha(0.3) |
exCol
with purple: exCol | exColAlt = hx.color([103,23,112]) | exCol.mix(exColAlt) | exCol.mix(exColAlt,0.3) |
exCol.range()
exCol.range(5,5)
exCol.range(3,1)
exCol.range(3,3,0.75)