Saturday, January 19, 2008

Next! - Color

Hi again.

some time ago i have done a class to deal with colors, since i think about create some kind of GFX support ( SVG,VML) , i decided to put it here

Its just 8,00 KB Minified, so its not that much, and much of the sise is because of the default colors, that can be removed.
Eg. it have Next.Color.Red="##FF0000" etc...;

You can access the source of the class here
If you have a SVN copy on your pc just do an update to it.

The class is named Next.Color

This class give many ways to convert color formats

* Usage:
* new Next.Color(r,g,b);//parameters
* new Next.Color([r,g,b]);//array with 3 numbers
* new Next.Color({R:r,G:g,B:b});//object with R,G,b or r,g,b members
* new Next.Color("RGB(r,g,b)");//String RGB CSS
* new Next.Color("#FFFFFF");//String HEX CSS

You can export to:

It have a helper function very cool when we need to check and use some color, lets say:

function dc(c){
if ((c=Next.Color.check(c))!==null){
alert(c);//toString method on Color class give you the hex value

dc("Red");//alert's "##FF0000"
;//alert's "#FF0000"
dc("#FF0000");//alert's "#FF0000"
dc([255,0,0]);//alert's "#FF0000"
;//alert's "#FF0000"
dc({R:255,G:0,B:0});//alert's "#FF0000"
Its nothing special but still useful for the upcoming GFX stuff

Its all for now!!

No comments: