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

documentation on how to provide a proper long as a starting point? #3

Open
vaporstack opened this issue Jul 11, 2020 · 1 comment
Open

Comments

@vaporstack
Copy link

Thank you for this lovely library. I've been using it with much pleasure. I had a hard time finding how to provide a properly configured long though, in the documentation you pass it a literal:

var oldColor = 0x20F186;

I wasn't able to figure out how to define my color as such, I ended up doing something like:

oldColor = eval('0x' + hex);

where hex was my string value. Is there a "good" way to do this? Might help a future user.

Thanks again! lovely piece of kit.

@Belonit
Copy link
Owner

Belonit commented Jul 12, 2020

I'm not really sure I should explain how to use standard JS functions like parseInt([radix]) or Number.prototype.toString([radix]).
Moreover, I use the same interface as the standard ColorPicker.
Anyway, here is a small example:

var stringColor = "20F186";
var numberColor = parseInt(stringColor, 16);

alert(
    '"stringColor" = ' + stringColor + "\r\n" + 
    '"numberColor" = ' + numberColor + "\r\n" + 
    '"numberColor to string" = ' + numberColor.toString(16).toUpperCase() + "\r\n" + 
    '"numberColor to string === stringColor" = ' + (numberColor.toString(16).toUpperCase() === stringColor).toString()
);

Thanks for the feedback, I'll think about how I can improve the description.

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

2 participants