-
Notifications
You must be signed in to change notification settings - Fork 56
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
Can palette shows up color occurence amount #5
Comments
i added an option to disable palette sorting, by default it is ordered by highest to lowest occurrence counts: var pal = quant.palette(false, true);
var palHist = [];
quant.idxi32.forEach(function(i32) {
palHist.push({color: quant.i32rgb[i32], count: quant.histogram[i32]});
});
console.log(palHist); or // called with no arguments (auto-sorted)
var pal = quant.palette();
var palHist = [];
quant.idxi32.forEach(function(i32) {
palHist.push({color: quant.i32rgb[i32], count: quant.histogram[i32]});
});
// sort it yourself
palHist.sort(function(a,b) {
return a.count == b.count ? 0 : a.count < b.count ? 1 : -1;
});
console.log(palHist); fixed by a397b7e |
Ah ok I didn't know that the color output palette is ordered. Thank you very much! Edit: I just want to say that the output is not sorted. Here is an example that is in my code:
This isn't ordered... but now I know how to order it, thank you... |
since last commit, it should be ordered by counts if you disable sorting by using it will still sort by default if you did not change the way the palette generation is called. |
Ok thank you! |
in your case it may be |
Is there a possibility to get information about the occurence amount of the final colors? My intention is to sort the palette by occurence amount.
The text was updated successfully, but these errors were encountered: