View Single Post
  #9  
Old 04-11-2011, 04:01 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
figure I show how to convert RGB to HSL to RGB
PHP Code:
function HSL2RGBtemp.huetemp.sattemp.lum)
{

  
temp.chroma = ( abstemp.lum 1)) * temp.sat;
  
temp.hue    temp.hue 60;
  
temp.xVal   temp.chroma * ( abs(( temp.hue 2) - 1));
  
temp.r      temp.hue == 00temp.hue 1temp.chromatemp.hue 2?   temp.xValtemp.hue 3?           0temp.hue 4?           0temp.hue 5?   temp.xValtemp.chroma;
  
temp.g      temp.hue == 00temp.hue 1?   temp.xValtemp.hue 2temp.chromatemp.hue 3temp.chromatemp.hue 4?   temp.xValtemp.hue 5?           0:           0;
  
temp.b      temp.hue == 00temp.hue 1?           0temp.hue 2?           0temp.hue 3?   temp.xValtemp.hue 4temp.chromatemp.hue 5temp.chroma:   temp.xVal;                 
  
temp.m      temp.lum 0.5 temp.chroma;          
 
  return { 
temp.temp.mtemp.temp.mtemp.temp.m};
 
}

function 
RGB2HSLtemp.rtemp.gtemp.b)
{

    
temp.max maxmaxtemp.rtemp.g), temp.b);
    
temp.min minmintemp.rtemp.g), temp.b);
    
temp.chroma temp.max temp.min;
    
temp.= (( temp.r) - temp.temp.b) / 2;
    
temp.= (( 0.5) / 2) * ( temp.temp.b);
    
temp.hue arctantemp.temp.a);
    
temp.lum 0.5 * ( temp.max temp.min);
    
temp.sat temp.chroma == 00: ( temp.chroma / ( abstemp.lum 1)));
    
  return { 
intradToDegtemp.hue) % 360), temp.sattemp.lum};


and now an example to find the Inverted color of an HSL color

lets say we want to find the inverted RGB color with red's HSL

PHP Code:
function onCreated()
{

  
temp.red = { 010.5}; //Red's HSL
  
temp.inv HSL2RGB(( temp.red0] - 180) % 360temp.red1], temp.red2]);
  echo( 
temp.inv);


which you get { 0, 1, 1} which is Cyan's RGB
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote