Closed jsdario closed 8 years ago
As suggested by github user @eduardo-costa we could implement an API more like the following:
var colorsys = require('colorsys') colorsys.rgb.hsv({ r: 255, g: 255, b: 255 }) colorsys.hsv.rgb(...) //also vector format (good for webgl) colorsys.rgb.vec({ r: 255, g: 255, b: 255 }); //returns [1.0,1.0,1.0] or new Float32Array(...) //Alpha for some applications is important colorsys.rgb.vec({ r: 255, g: 255, b: 255, a: 128 }); //returns [1.0,1.0,1.0,0.5] or new Float32Array(...) color.rgb.int({ r: 255, g: 255, b: 255 }); //returns 0xffffff color.rgb.int({ r: 255, g: 255, b: 255, a:128 }); //returns 0x80ffffff ARGB color.rgb.int({ r: 255, g: 255, b: 255, a:128 },true); //returns 0xffffff80 RGBA color.int.rgb(0xffffff); //returns { r: 255, g: 255, b: 255 } //lerp color.rgb.lerp({rgb},{rgb},ratio); // blend 2 colors color.int.lerp(...,r) color.hsv.lerp(...,r) //gradient (this one is useful some times) color.rgb.gradient([{rgb},{rgb},{rgb},{rgb},...],r); //returns the correct blend between color intervals
Maybe we should keep the repo for the lightest version and open another one slightly more elaborated, written in ES6.
Closing for lack of discussion.
As suggested by github user @eduardo-costa we could implement an API more like the following:
Maybe we should keep the repo for the lightest version and open another one slightly more elaborated, written in ES6.