color: int to string (hex)
#1

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) ?
Reply
#2

it only shows 6 characters instead of 8, is because u've requested only 6 to be showen with "{%06x}",
try "{%08x}"
Reply
#3

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 );
}
Reply
#4

Quote:
Originally Posted by OrMisicL
View Post
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}
Reply
#5

Quote:
Originally Posted by feartonyb
View Post
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.
Reply
#6

Quote:
Originally Posted by Y_Less
View Post
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"
Reply
#7

Quote:
Originally Posted by ATomas
View Post
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.
Reply
#8

Quote:
Originally Posted by Vince
View Post
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"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)