KITASENJU DESIGN BLOG

memo, html, javascript, unity

chroma.js with typescript

I wanted to use Lab color space for making a gradient between two color. so I used chroma.js.

//import
import chroma from 'chroma-js';

//definition
let color1:chroma.Color = chroma(255,0,0);
let color2:chroma.Color = chroma(0,255,0);

//mix
let col = chroma.mix('#ff0000', '#00ff00', ratio, 'lab').rgb();

this.mat.color.r =col[0]/255;
this.mat.color.g =col[1]/255;
this.mat.color.b =col[2]/255; 
"FOOTER"