Little script to correct the decimal to hex color convertion.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Josué Alba
    Forum Member
    • Mar 2005
    • 225

    Little script to correct the decimal to hex color convertion.

    Well I was trying to use the colorButton plugin () and trying to convert some of the values to it's Hex using another plugin named MathEx (http://www.amspublic.com/) but there are several colors that makes the conversion fail (those having 00's) so I write this little script suing both plug ins.

    Code:
    newColor = ColorButton.GetColor("colorBtn");
    if newColor == 0 then
    	textCola = "00";
    	textColb = "00";
    	textColc = "00";
    	else
    	colorHex = MathEx.Base10ToBaseX(newColor, 16);
    	
    	if String.Length(colorHex) == 1 then
    				textCola = "00";
    				textColb = "00";
    				textColc = "0"..String.Right(colorHex, 1);
    				elseif String.Length(colorHex) == 2 then
    					textCola = "00";
    					textColb = "00";
    					textColc = String.Right(colorHex, 2);
    					elseif String.Length(colorHex) == 3 then
    					textCola = "00";
    					textColb = "0"..String.Mid(colorHex, 1, 1);
    					textColc = String.Right(colorHex, 2);
    					elseif String.Length(colorHex) == 4 then
    						textCola = "00";
    						textColb = String.Left(colorHex, 2);
    						textColc = String.Right(colorHex, 2);
    						elseif String.Length(colorHex) == 5 then
    							textCola = "0" .. String.Left(newColor, 1);
    							textColb = String.Mid(colorHex, 2, 2);
    							textColc = String.Right(colorHex, 2);
    							elseif String.Length(colorHex) == 6 then
    								textCola = String.Left(colorHex, 2);
    								textColb = String.Mid(colorHex, 3, 2);
    								textColc = String.Right(colorHex, 2);
    	end
    end
Working...
X