color: int to string (hex) -
ATomas - 12.06.2013
I converting color to hex code using:
new color = 0xBB9911AA;
format(string,sizeof(string),"{%06x}nice color",color >>> 8 );
result is:
"{BB9911}nice color"
i need:
"{BB9911AA}nice color"
How to do to get there display parameter transparency (alpha prarametr) ?
Re: color: int to string (hex) -
OrMisicL - 12.06.2013
it only shows 6 characters instead of 8, is because u've requested only 6 to be showen with "{%06x}",
try "{%08x}"
Re: color: int to string (hex) -
feartonyb - 12.06.2013
I made stock for you:
Code:
stock GetHexColor( colorcode[ ] )
{
new ColorString[128]:
for(new i = 0; i < 11; i++ )
{
if ( colorcode[ i ] == '0x' )
colorcode[ i ] = ' ';
}
return format(ColorString,sizeof(ColorString),"{%s}nice color",colorcode );
}
Re: color: int to string (hex) -
ATomas - 13.06.2013
Quote:
Originally Posted by OrMisicL
it only shows 6 characters instead of 8, is because u've requested only 6 to be showen with "{%06x}",
try "{%08x}"
|
I try it. It doesnґt work. Result is: {00BB9911}
but i need {BB9911AA}
Re: color: int to string (hex) -
ATomas - 13.06.2013
Quote:
Originally Posted by feartonyb
I made stock for you:
Code:
stock GetHexColor( colorcode[ ] )
{
new ColorString[128]:
for(new i = 0; i < 11; i++ )
{
if ( colorcode[ i ] == '0x' )
colorcode[ i ] = ' ';
}
return format(ColorString,sizeof(ColorString),"{%s}nice color",colorcode );
}
|
I need convert integer to hex code. Your function work with text and delete "0x" from text. This not convert int to hex.
Re: color: int to string (hex) -
ATomas - 13.06.2013
Quote:
Originally Posted by Y_Less
Transparency doesn't work in embedded colours, so its pointless even trying to format them.
|
I do not want to use for the color of the text, but for listings. This was an example
new color = 0xBB9911AA;
format (string, sizeof (string), "color is: %06x", color >>> 8 );// i need Transparency
result:
"Color is: BB9911"
bud i need
"Color is: BB9911AA"
Re: color: int to string (hex) -
Vince - 13.06.2013
Quote:
Originally Posted by ATomas
I know, I want them to be used elsewhere in the script, the code which I showed was just an example:
|
Why, and what for? As Y_Less said you can't display alpha transparency anywhere. Colors should otherwise be stored as numbers.
Re: color: int to string (hex) -
ATomas - 13.06.2013
Quote:
Originally Posted by Vince
Why, and what for? As Y_Less said you can't display alpha transparency anywhere. Colors should otherwise be stored as numbers.
|
I understood wrong sorry
problem is if a use AARRGGBB format (alpha transparency is first, for colored objects).
new color = 0xAABB9911;
format(string,sizeof(string),"%06x",color>>>8 );
result is:"AABB99"
but color is:
"BB9911"