Skip to content

Colors

asbien edited this page Sep 24, 2015 · 6 revisions

WikiColors

Creating instances

Short API:

col = chroma.hex("#ff0000");
col = chroma.rgb(255,128,10);
col = chroma.hsl(120,100,50);
col = chroma.hsv(120,100,100);
col = chroma.lab(80,70,-40);
col = chroma.lch(120,100,100);

Long API:

col = new chroma.color(255,128,10,'rgb');
col = new chroma.color(120,100,50,'hsv');

Which color spaces are supported?

Conversion into different color spaces

Regardless of how you instanciated the color, you can convert

col.rgb // [255,0,0]
col.hex() // '#ff0000'
col.hsv() // [0,100,100]
col.hsl() // [0,100,50]
col.lab() // ...
col.lch() // ..

Interpolation between colors

Short API

chroma.interpolate("#c00", "#e88", .5, 'hsl')

Long API

col1 = chroma.hex('#c00');
col2 = chroma.hex('#e88'); 
col1.interpolate(.5, col2, 'hsl');
Something went wrong with that request. Please try again.