Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percentage of color #51

Open
sasharevzin opened this issue Nov 24, 2014 · 8 comments
Open

Percentage of color #51

sasharevzin opened this issue Nov 24, 2014 · 8 comments

Comments

@sasharevzin
Copy link

Hello,

Is it possible to know the percentage of picked color? If on output we receive 9 colors so what is the percentage of each of them?

Thanks

@fallenartist
Copy link

+1

1 similar comment
@kloneets
Copy link

kloneets commented Jun 3, 2015

+1

@Mysterarts
Copy link

Maybe not the best solution, but you can change the function palette line 351 in color-thief.js:

palette: function() {
        return this.vboxes.map(function(vb) { return vb.color.concat(vb.vbox._count);});
}

When you will use getColor() or getPalette(), the array of each color will still contains red, green and blue but also at the index 3, the count of pixels of this color (or close). Calculate the percentage should be easy with the size of the picture or the sum of the color counts!
(Return an object should be better but this solution avoid to change your code if you already use these functions.)

cbaconnier added a commit to cbaconnier/color-thief that referenced this issue Jul 4, 2016
This is just a quick add. 

When we will use getColor() or getPalette(), the array of each color will still contains red, green and blue but also at the index 3, the count of pixels of this color (or close)

See lokesh#51
@sedrakpc
Copy link

+1

4 similar comments
@upcesar
Copy link

upcesar commented May 25, 2017

+1

@fahim0623
Copy link

+1

@FengXianGuo
Copy link

+1

@aycabayraktar
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants