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

How to add "Choose file for Image" and "print HEX value" in class="swatch" div #130

Closed
keshavnaidu opened this issue Nov 3, 2017 · 4 comments

Comments

@keshavnaidu
Copy link

Hi Lokesh,
Your app is excellent.

Can you help me out for adding a HEX values instead of RGB in class="swatch" .
Also a Choose file instead of Drag and drop.
I would like to credit & contribute u to using "color thief" for my site.

Thanks & Regards.

@AlfredJKwack
Copy link

Hi,

You can easily write your own routing to convert RGB to HEX. Converting the array returned by color-thief should be no more effort.

To get you started and pointed in the right direction:


function componentToHex(c) {
    var hex = c.toString(16);
    return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
    return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
alert( rgbToHex(0, 51, 255) ); // #0033ff

As for the choose file, instead of drag and drop... well. I'd hate to troll you so I'll leave it at that.

@lokesh
Copy link
Owner

lokesh commented Aug 25, 2019

Move instructions on rgb to hex conversion on to the demo site in a new FAQ section:
https://lokeshdhakar.com/projects/color-thief/#faq

@lokesh lokesh closed this as completed Aug 25, 2019
@lokesh
Copy link
Owner

lokesh commented Aug 25, 2019

Thanks. Added a FAQ section that includes the rgb to hex conversion code:
https://lokeshdhakar.com/projects/color-thief/#faq

@ApexisDev
Copy link

Is it possible to get RGBA-Values instead of RGB-Values?

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

No branches or pull requests

4 participants