color question

For all the help you need with Armagetron!
User avatar
^}LC}<SolJah*KF
On Lightcycle Grid
Posts: 19
Joined: Sat Dec 16, 2006 1:55 pm
Location: Nebraska
Contact:

color question

Post by ^}LC}<SolJah*KF »

When you type a message in AA, your message comes in a color. Do you know the hex code for that color? I need this ASAP!
| / \ |
Why i did thatt? i do not know..
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

0xffff7f
There's no place like ::1
User avatar
DDMJ
Reverse Outside Corner Grinder
Posts: 1882
Joined: Thu Jun 08, 2006 12:15 am
Location: LA, CA, USA, NA
Contact:

Post by DDMJ »

0xffff88
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

no, 0xffff7f
There's no place like ::1
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

0xffff7f indeed (now we're the majority)
ˌɑrməˈɡɛˌtrɑn
User avatar
ed
Match Winner
Posts: 613
Joined: Mon Feb 13, 2006 12:34 pm
Location: UK

Post by ed »

Durka's right. The colour he's after is 0xffff88.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Some evidence.

ePlayer.cpp:

Code: Select all

static void se_DisplayChatLocally( ePlayerNetID* p, const tString& say )
{
    // ...

    if ( p && !p->IsSilenced() )
    {
        //tColoredString say2( say );
        //say2.RemoveHex();
        tColoredString message;
        message << *p;
        message << tColoredString::ColorString(1,1,.5);
        message << ": " << say << '\n';

        con << message;
    }
}

// ...

// builds a colored chat string
static tColoredString se_BuildChatString( ePlayerNetID const * sender, tString const & message )
{
    tColoredString console;
    console << *sender;
    console << tColoredString::ColorString(1,1,.5) << ": ";
    se_AppendChat( console, message );

    return console;
}

// Build a colored /team message
static tColoredString se_BuildChatString( eTeam const *team, ePlayerNetID const *sender, tString const &message )
{
    tColoredString console;
    console << *sender;

    if (sender->CurrentTeam() == team) {
        // foo --> Teammates: some message here
        console << tColoredString::ColorString(1,1,.5) << " --> ";
        console << tColoredString::ColorString(team->R(),team->G(),team->B()) << "Teammates";
    }
    else {
        // foo (Red Team) --> Blue Team: some message here
        eTeam *senderTeam = sender->CurrentTeam();
        console << tColoredString::ColorString(1,1,.5) << " (";
        console << tColoredString::ColorString(senderTeam->R(),senderTeam->G(),senderTeam->B()) << senderTeam->Name();
        console << tColoredString::ColorString(1,1,.5) << ") --> ";
        console << tColoredString::ColorString(team->R(),team->G(),team->B()) << team->Name();
    }

    console << tColoredString::ColorString(1,1,.5) << ": ";
    se_AppendChat( console, message );

    return console;
}

// builds a colored chat /msg string
static tColoredString se_BuildChatString( ePlayerNetID const * sender, ePlayerNetID const * receiver, tString const & message )
{
    tColoredString console;
    console << *sender;
    console << tColoredString::ColorString(1,1,.5) << " --> ";
    console << *receiver;
    console << tColoredString::ColorString(1,1,.5) << ": ";
    se_AppendChat( console, message );

    return console;
}
Note the (1,1,.5) all over the place.

tString.h:

Code: Select all

//! proxy class for inserting color markings
struct tColoredStringProxy
{
    REAL r_, g_, b_;

    tColoredStringProxy( REAL r, REAL g, REAL b )
            : r_(r), g_(g), b_(b)
    {}
};

//!< strings that know about color markings
class tColoredString: public tString
{
public:
    // ...

    //! Creates a color string inserter
    inline static tColoredStringProxy ColorString( REAL r,REAL g,REAL b )
    {
        return tColoredStringProxy( r, g, b );
    }
};
Let's see what happens when a tColoredStringProxy is appended.

tString.cpp:

Code: Select all

static int RTC(REAL x){
    int ret=int(x*255);
    if (ret<0)
        ret=0;
    if (ret>255)
        ret=255;
    return ret;
}

static char hex_array[]="0123456789abcdef";

static char int_to_hex(int i){
    if (i<0 || i >15)
        return 'Q';
    else
        return hex_array[i];
}

tColoredString & operator <<(tColoredString &s, const tColoredStringProxy &colorCode )
{
    if (st_colorStrings)
    {
        char cs[9];
        cs[0]='0';
        cs[1]='x';

        int RGB[3];
        RGB[0]=RTC(colorCode.r_);
        RGB[1]=RTC(colorCode.g_);
        RGB[2]=RTC(colorCode.b_);

        for(int i=0;i<3;i++){
            int lp=RGB[i]%16;
            int hp=(RGB[i]-lp)/16;
            cs[2+2*i]=int_to_hex(hp);
            cs[2+2*i+1]=int_to_hex(lp);
        }
        cs[8]=0;

        s << cs;
    }

    return s;
}
FYI, int(x*255) rounds down (at least for the range we're considering), so it's 0xffff7f, not 0xffff80, let alone 0xffff88.
ˌɑrməˈɡɛˌtrɑn
User avatar
Lucifer
Project Developer
Posts: 8747
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas

Post by Lucifer »

Jonathan's basically declaring himself right and using code to support it. I'd suggest using a color picker app if you don't want to believe jonathan.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
DDMJ
Reverse Outside Corner Grinder
Posts: 1882
Joined: Thu Jun 08, 2006 12:15 am
Location: LA, CA, USA, NA
Contact:

Post by DDMJ »

I didn't see what wrlt's image showed. It didn't load correctly for me. It looked like Image.

There's not much of a difference between the 2 colors. Here's a screenshot:

Image
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

If it's so hard to see, why did someone claim it's exactly ffff88 with absolute certainty (i.e. claim the real value is wrong)?

BTW, I took a similar screenshot which also captures the graininess of the grid quite well. I fixed that in the version I had on my broken HD. Would it seem like a good idea if I fix it again (=place vertices closer to the viewpoint so the GPU doesn't run out of precision so soon) and try multitexturing as well, and publish it this time?

Edit: uploaded aforementioned screenshot.
Attachments
Only reaches ~99% of full brightness, probably due to unlucky interpolation.
Only reaches ~99% of full brightness, probably due to unlucky interpolation.
ˌɑrməˈɡɛˌtrɑn
User avatar
Z-Man
God & Project Admin
Posts: 11715
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

Additional vertices? Sure, why not?
User avatar
^}LC}<SolJah*KF
On Lightcycle Grid
Posts: 19
Joined: Sat Dec 16, 2006 1:55 pm
Location: Nebraska
Contact:

Post by ^}LC}<SolJah*KF »

So it's declared. 0xffff7f and 0xffff88.

They are both the same.
| / \ |
Why i did thatt? i do not know..
User avatar
ed
Match Winner
Posts: 613
Joined: Mon Feb 13, 2006 12:34 pm
Location: UK

Post by ed »

nah, they're not the same.
Me, I thought it was a stupid question, like "what number am I thinking of?".
Turns out the question was fine, it was me who was stupid.

Trying to unravel what jonathon posted from a non programmers point of view:
ColorString(1,1,.5)
int_to_hex(int i)
would make decimal: 255 255 127
converted to hex would be FF FF 7F

although ffff88 looks the same, it's not.
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

ffff7f is/looks similar but not identical to ffff88. Even 16-bit mode (5-bit blue) shouldn't change that if rounding isn't totally broken.

Unraveling: for each number passed to ColorString, multiply with 255, round down, clamp to 0≤x≤255 (in case input isn't in that range), and print as two hex digits.
ˌɑrməˈɡɛˌtrɑn
User avatar
wrtlprnft
Reverse Outside Corner Grinder
Posts: 1679
Joined: Wed Jan 04, 2006 4:42 am
Location: 0x08048000
Contact:

Post by wrtlprnft »

Actually I wasn't even doing any calculations, I just hacked arma to display all color codes :)
There's no place like ::1
Post Reply