JavaScript Color Parsing – TinyColor
I threw together a color parsing library to help make my JavaScript colorpicker as small and accurate as possible. It is called TinyColor. One of the main goals is a small footprint – it clocks in at 8.98KB (3.41KB gzipped).
I have written in more detail about this on my TinyColor page. In it, I talk about the Color conversion, input recognition, color manipulation, scheme (combination) generation, and more.
January 16th, 2012 at 7:09 pm
very nice!
check oute this patteren to scrap a few more bytes for places like line 185
from
to
better looking and less code
January 20th, 2012 at 9:56 am
Yes, many of the conversion functions were modified from other sources, so I didn’t make many changes besides changing the bounding of the parameters (normalizing the input to a 0-1 scale).
I usually avoid nested ternary expressions because it is hard to visually parse them out (at least when reading the code months later) so I end up explicitly parenthesizing the nesting, which makes it a little more verbose.