Javascript color manipulation
Posted by admin | Filed under MadeByPi® Labs
Recently I needed to write some code which involved matching any given colour against a custom palette of colours. I found it hard to find any decent javascript out there... So I wrote my own.
Introducing: Color Utils
Main features:
- Convert any colour format to any other colour format
- Match colours against a custom palette
- Match colours against a websafe palette
- Increase/decrease Hue, Saturation and Brightness of a colour
- Find different colour harmonies for a color
- Fade from one colour to another
- Easy to use
- No dependancies such as prototype or jQuery
- Small file size. Just 11kb!













Hello, thanks for this – it’s an excellent, concisely presented library. Could you please comment on the license you’re distributing it under as I’d like to use it for a website I’m building.
Thanks.
Hi Michael,
Sorry for the late reply – I’ve only just found out about this comment.
I’d like to use a BSD-style licence on this work so you’re free to use it in commercial work.
I’ll update the docs with proper licence information soon – for now I’ll leave you with a limerick.
——————
© 2008 MadeByPi®
This work ‘as-is’ we provide.
No warranty, express or implied.
We’ve done our best,
to debug and test.
Liability for damages denied.
Permission is granted hereby,
to copy, share, and modify.
Use as is fit,
free or for profit.
On this notice these rights rely.
Excellent license, great to know, thank Mike.
… “[var] grey” should be changed to “red” on first
line at .greyscale() example — yay!
Hi yeah, thanks for that ben – I’ll get that fixed.
Hi, can it be used to convert CMYK Image to RGB?