
Added by roScripts on August-25-2007, 2:44 pm
/*
************************************************************
Developed by R.Arul Kumaran [arul@shockwave-india.com] *
for more code keep visiting [www.shockwave-india.com/blog] *
************************************************************
*/
//Set of funtions for handling color values in different format
/*-----------------------------------------------------
//getHexStr: returns a string representing the
//HEX value for the specified R,G,B values
*/
_global.getHexStr = function(r, g, b) {
return twoDigit(r.toString(16))+twoDigit(g.toString(16))+twoDigit(b.toString(16));
};
/*
//Usage:-
trace(getHexStr(255,255,255));
//traces "ffffff"
*/
/*-----------------------------------------------------
//getHex: returns the HEX value for the
//specified R,G,B values
*/
_global.getHex = function(r, g, b) {
return r << 16 | g << 8 | b;
};
/*
//Usage:-
trace(getHex(255,255,255));
//traces 16777215
*/
/*-----------------------------------------------------
//HexToRGB: returns the RGB (as Object) for the
//specified HEX value
*/
_global.HexToRGB = function(HEX) {
return {r:HEX >> 16, g:(HEX >> 8) & 0xff, b:HEX & 0xff};
};
/*
//Usage:-
trace(HexToRGB(0x0c0c0c).r);
//traces 12 (the red value)
*/
/*-----------------------------------------------------
//twoDigit: adds "0" in front if the string is only
// one digit also useful for converting date time strings
*/
function twoDigit(str) {
return str.length == 1 ? "0"+str : str;
}
/*
//Example:-
var myDate = new Date();
var timeStr = twoDigit(myDate.getHours())+twoDigit(myDate.getMinutes());
trace(timeStr);
//traces "01:09"
*/
Added by roScripts on March-26-2008, 5:14 pm
Added by roScripts on March-26-2008, 5:13 pm
Added by roScripts on March-26-2008, 5:09 pm
Added by roScripts on March-26-2008, 5:08 pm
Added by roScripts on March-26-2008, 5:07 pm