Open alexeyr-ci opened 1 year ago
That is true. I am currently working on a big PR, so I could add that as an option... What would you think the API should look like? I can think of three reasonable options:
getColor
to getColor( img: HMTLImageElement | HTMLCanvaasElement, [other options] )
img
argument optional and add canvas
optional argument. One would have to be supplied (this would be a breaking change, as that argument shouldn't be added to the end, which is not ideal)getColorCanvas( canvas: CanvasImage, [other options] )
getColor( img: HTMLImageElement )
which would call getColorCanvas@alexeyr-ci
I think 1 is clear enough, 3 is reasonable if you want to avoid 1.
@alexeyr-ci I have implemented this, it is available in my npm package, run npm i @janishutz/colorthief
to install it. You may also find the repo at https://github.com/janishutz/color-thief. The new version also features TypeScript support with TypeDefinitions of all functions, as well as updated functions with promises, which have replaced the now deprecated (but still available) async options
In my use-case I already have a
Canvas
and want to find its dominant colors. It doesn't make much sense to convert it to an image and then draw that image on a canvas.