Closed totty90 closed 10 years ago
I don't understand the issue - a hex character should be 3 or 6 characters. If it cannot be represented with 3 characters then the input should be put into the 6 character notation. From http://www.w3.org/TR/css3-color/#rgb-color:
The format of an RGB value in hexadecimal notation is a ‘#’ immediately followed by either three or six hexadecimal characters. The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros
There are hex that are 4 like in the example in the title. I don't know if is standard or not, but might be used in this lib to accept more input types. Not only hex3 or hex6. If not, I have to convert all the time with the function..
I try to follow the CSS standard as closely as possible for the accepted string input to prevent any surprises. I've never seen the 4 character hex in any standard, so I'm inclined not to add it. You should be able to wrap the tinycolor function to support this use case using your example code in this issue.
ok, no problem then. I was not using for css but I was using it for a graphical application that uses webgl... I found that lib not limited to css
Use this function decimalToHex(d) { var hex = Number(d).toString(16); hex = "000000".substr(0, 6 - hex.length) + hex; return hex; }