bgrins / TinyColor

Fast, small color manipulation and conversion for JavaScript
https://bgrins.github.io/TinyColor/
MIT License
5.05k stars 437 forks source link

Full format and output support for RGBA hex8/6/4/3 (as CSS 4, section 4.2) #136

Closed MarkGriffiths closed 8 years ago

MarkGriffiths commented 8 years ago

I only started using TinyColor a few days ago due to its inclusion in project I'm hacking on, and one of the things I really needed was good RGBA hex output for UI theme scripting in Sublime Edit.

After an hour of confusing colour shifts and head scratching I'm not getting back, I spotted the ARGB note and sort of fell into a nostalgic flashback of slow redraws, flickering backgrounds and Zune vs iPod arguments…

I noticed it's been on the wish list for ages, so here you go… code, tests and docs and hopefully no change to toFilter. I've added some new tests and tweaked a few others - a few .5's have become .4 or .6 so that Hex4 values can be tested, but only where the .5 seemed arbitrary

The old ARGB behaviour is in a new utility function rgbaToArgb() so the both internal and second colours can use it when setting the filter. I've scoured and grep'ed for things that needed to be updated… let me know if I've missed anything. (The very tidy) Style, low complexity and ES3ness has all been respected… Should satisfy #133

bgrins commented 8 years ago

Looks great, thanks

bgrins commented 8 years ago

@MarkGriffiths I'll tag a release with this, appreciate the help