gka / chroma.js

JavaScript library for all kinds of color manipulations
https://gka.github.io/chroma.js/
Other
10.08k stars 543 forks source link

Performance (Feature request) #238

Open wellcaffeinated opened 4 years ago

wellcaffeinated commented 4 years ago

I love this library and use it all the time. But one drawback is that when i use it in animation, the overhead of creating new chroma instances and inferring argument lists gets in the way of my precious FPS.

Would you consider giving direct access to the low level "io" conversion functions for those of us who need efficiency over user-friendliness?

Thanks for your hard work!

gka commented 4 years ago

I think you should be able to import source files directly, e.g.

> const rgb2lab = require('chroma-js/src/io/lab/rgb2lab')
> rgb2lab(255, 0, 0);
// [ 53.24079414130722, 80.09245959641109, 67.20319651585301 ]

The only "convenience" happening then is that the function accepts parameters either as array or spread out.

wellcaffeinated commented 4 years ago

Ah fantastic. I was using it in jsfiddle and wasn't able to access these lower level functions from the built library. I suppose this will suffice for most use-cases. thanks!