-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
decimal color / color count #76
Comments
Hey, thank you for the kind words and great suggestions! Converting hex <-> dec is pretty easy to do in JavaScript: // hex to decimal
var hex = '#ffffff';
var dec = parseInt(hex.replace('#', '0x'));
// decimal to hex
var dec = 16777215;
var hex = '#' + dec.toString(16).padStart(6, '0'); Since it's so simple to convert I suppose it makes sense to also include it in the library. Is there any preference for the property name? Something like The color limitation thing is also a good idea, although I think it would be a little more difficult to implement. I'm not sure whether it makes sense since wheel-style color pickers like iro.js aren't really meant for precision color choices anyway Cheers though :) |
Cool, great to hear from you! I think either of those names would work. I have seen it mostly as decimal, but that could be due to the way I search. Here it's called decimal as well. https://convertingcolors.com/decimal-color-16744576.html So, if I were to vote The limitation is to stay within some kind of standard. For example, it's impossible to choose real named colors, or even white. Just a thought. Thanks. |
@jaames maybe instead of putting this in Iro.JS itself, we should make it really easy to implement this sort of functions for the end-user. That will help different scenario's probably in the future (: |
@KaanMol Oh, like a way to easily extend |
Yeah, that keeps Iro.JS atleast small and straight to the point. Probably not everybody needs this |
Good point! Object.defineProperty(iro.Color.prototype, 'decimal', {
get: function() {
return parseInt(this.hexString.replace('#', '0x'));
},
set: function(newValue) {
this.hexString = '#' + newValue.toString(16).padStart(6, '0');
}
}) It's pretty simple, but perhaps a small wrapper around it would be useful |
Do you want to make this on the Typescript branch or on the current one? If you want to make it on the Typescript one, let's add it to a to-do list there. |
Closing this since I don't think it's important to add this I might consider adding a simple way to extend iro.Color to add extra properties, though |
Hey this is a great tool! The transparency plugin makes it top level.
I work with an older color data (vb) where colors are represented in decimal format, ie, #FFFFFF equals 16777215, This website is for reference: https://www.mathsisfun.com/hexadecimal-decimal-colors.html
It would be nice/convenient to get the decimal value of the color as well as the other options you provide.
Additionally, using the wheel on a small mobile device is great! It would also be nice to dumb down the colors quite a bit for fat thumbs or when color precision isn't necessary. It would be nice to have a parameter that would change the amount of colors available: 8, 16, 32, etc., up to millions.
Just some thoughts to make it next level.
Thanks,
Jake
The text was updated successfully, but these errors were encountered: