color question
- ^}LC}<SolJah*KF
- On Lightcycle Grid
- Posts: 19
- Joined: Sat Dec 16, 2006 1:55 pm
- Location: Nebraska
- Contact:
color question
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..
Why i did thatt? i do not know..
- Jonathan
- A Brave Victim
- Posts: 3391
- Joined: Thu Feb 03, 2005 12:50 am
- Location: Not really lurking anymore
Some evidence.
ePlayer.cpp:
Note the (1,1,.5) all over the place.
tString.h:
Let's see what happens when a tColoredStringProxy is appended.
tString.cpp:
FYI, int(x*255) rounds down (at least for the range we're considering), so it's 0xffff7f, not 0xffff80, let alone 0xffff88.
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;
}
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 );
}
};
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;
}
ˌɑrməˈɡɛˌtrɑn
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
Be the devil's own, Lucifer's my name.
- Iron Maiden
- Jonathan
- A Brave Victim
- Posts: 3391
- Joined: Thu Feb 03, 2005 12:50 am
- Location: Not really lurking anymore
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.
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.
ˌɑrməˈɡɛˌtrɑn
- ^}LC}<SolJah*KF
- On Lightcycle Grid
- Posts: 19
- Joined: Sat Dec 16, 2006 1:55 pm
- Location: Nebraska
- Contact:
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.
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.
- Jonathan
- A Brave Victim
- Posts: 3391
- Joined: Thu Feb 03, 2005 12:50 am
- Location: Not really lurking anymore
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.
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