et colors as html hex

Any discussions that are non-rtcw/et related go here.

Moderators: Forum moderators, developers

User avatar
Spoofeh
Posts: 296
Joined: Sat Jul 26, 2003 4:50 am

Post by Spoofeh »

gotenks wrote:ANY computer casting (to an int type number, eg non floating point) rounds down...
It doesn't round, it discards (or truncates) the decimal part.

1.9 => 1
-1.9 => -1
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

:oops: i was going to say that, but i thought it'd be easier to understand :oops:
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
User avatar
ouroboro
Posts: 662
Joined: Mon Jul 26, 2004 6:52 pm

Post by ouroboro »

gotenks wrote:ANY computer casting (to an int type number, eg non floating point) rounds down...
f = float, no?
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

float = float, unless you're using something i'm unaware of...byte = non-floatingpoint value
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
User avatar
ReyalP
Posts: 1663
Joined: Fri Jul 25, 2003 11:44 am

Post by ReyalP »

ouroboro wrote:< .5 rounds down. >= .5 rounds up. every elementary school kid knows that.
Yes, but kids who know C know that converting a float to an integer type doesn't necessarily round.

If I remember right, what actually happens is up to the implementation, but all the implementations that interest us in this truncate.
send lawyers, guns and money
Dersaidin
Posts: 197
Joined: Fri Aug 06, 2004 1:55 pm
Location: Australia

Post by Dersaidin »

Made this a while ago

http://www.mercness.net/dersaidin/namecolor.php

With every working character.
User avatar
ouroboro
Posts: 662
Joined: Mon Jul 26, 2004 6:52 pm

Post by ouroboro »

gotenks wrote:float = float, unless you're using something i'm unaware of...byte = non-floatingpoint value
q_math.c wrote:{ 0.7f, 0.1f, 0.1f, 1.0 }, // J
i would translate those values to an RGB of 178.5, 25.5, 25.5 - and i would round them to 179, 26, 26 (^J = #B31A1A).

i can only assume the f's in those RGBA values = "float". you can correct me if they mean something else (i'm no coder), but it really doesn't matter, because at least one source agrees with me - adobe photoshop. it rounds RGB values according to the "elementary school method".

i'll stick with the HEX values i came up with. they make logical sense (to me and adobe), and even if they're wrong somehow, they're damn close, as rounding down would give #B21919 in this example - not exactly a drastic difference.
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

those would be floats, and if, before they are converted to integers, they use math.round (or what ever the C code is, i think it's right, but not sure) then you are correct, but if the values are directly stored as integers, then you are incorrect
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
User avatar
ouroboro
Posts: 662
Joined: Mon Jul 26, 2004 6:52 pm

Post by ouroboro »

gotenks wrote:...if, before they are converted to integers, they use math.round...
how would i find out?

edit - i searched the entire source code for "math.round" with no hits :(
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

so they're truncated... not rounded
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
User avatar
ouroboro
Posts: 662
Joined: Mon Jul 26, 2004 6:52 pm

Post by ouroboro »

then i fail. delete this thread :cry:

one thing though: why would photoshop round up for RGB values >= .5 if it goes against the standard for programming?
User avatar
WeblionX
Posts: 762
Joined: Sun Sep 08, 2002 1:03 pm
Contact:

Post by WeblionX »

Because they felt like using rounding instead of dropping it. Why? They probably thought it would be more consumer friendly.
Got any old idtech3 tutorials you made or saved? Send them my way.
User avatar
gotenks
Posts: 3465
Joined: Fri Nov 15, 2002 4:12 pm
Location: out of my mind
Contact:

Post by gotenks »

they're also not a programming language... 2 ways of handling it, both are correct, 1 is correct for programming, 1 is correct for web aps
My Website
Image
After a night of binge drinking:
=FF=im2good4u wrote:WTF wanst i on top ?
User avatar
Spoofeh
Posts: 296
Joined: Sat Jul 26, 2003 4:50 am

Post by Spoofeh »

gotenks wrote:so they're truncated... not rounded
The absence of "math.round" in the source doesn't prove anything (it's not a standard C function).

That's beside the point though, since it looks to me like colours are float throughout cgame. Conversion is either done in the engine or the gfx driver/hardware (my guess).
User avatar
ouroboro
Posts: 662
Joined: Mon Jul 26, 2004 6:52 pm

Post by ouroboro »

Spoofeh wrote:
gotenks wrote:so they're truncated... not rounded
The absence of "math.round" in the source doesn't prove anything (it's not a standard C function).

That's beside the point though, since it looks to me like colours are float throughout cgame. Conversion is either done in the engine or the gfx driver/hardware (my guess).
mmmkay, so does this mean i win? 8)
Post Reply