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 http://nextjs.googlecode.com/svn/trunk/lib/Color.js.
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:
Array
Object
RGB
HEX
It have a helper function very cool when we need to check and use some color, lets say:
function dc(c){Its nothing special but still useful for the upcoming GFX stuff
if ((c=Next.Color.check(c))!==null){
alert(c);//toString method on Color class give you the hex value
}
}
dc("Red");//alert's "##FF0000"
dc("RGB(255,0,0)");//alert's "#FF0000"
dc("#FF0000");//alert's "#FF0000"
dc([255,0,0]);//alert's "#FF0000"
dc({r:255,g:0,b:0});//alert's "#FF0000"
dc({R:255,G:0,B:0});//alert's "#FF0000"
Its all for now!!
No comments:
Post a Comment