AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Converting colors (3 to 1) (https://forums.alliedmods.net/showthread.php?t=346756)

Hellkong 03-15-2024 13:12

Converting colors (3 to 1)
 
As the title said,

The issue I don't know how to convert 3 values of colors to 1, let's say yellow ( R = 255, G = 255, B = 0), in the 255 one color value is 111 ( I didnt calculate this, I have a pic that has every value from 0 to 255).

I want to know how to calculate that.

Jhob94 03-15-2024 13:17

Re: Converting colors (3 to 1)
 
What? Rgb is 3 colors, red, green and blue. What do you mean 1 value? For rgb you always need 3.

Hellkong 03-15-2024 15:47

Re: Converting colors (3 to 1)
 
Quote:

Originally Posted by Jhob94 (Post 2819527)
What? Rgb is 3 colors, red, green and blue. What do you mean 1 value? For rgb you always need 3.

Yes, I know, an example is best way to describe:

I am using random values to make random color to an entity (glow), and this chance we've got this value

PHP Code:

static Float:fColors[3]
fColors[0] = 255.0
fColors
[1] = 255.0
fColors
[2] = 0.0

set_pev
(Entpev_rendercolorfColors)
// And ofcourse render mode 

and I am using pev_colormap as well as one of the textures of the model has the flag, basically coloring the same color, the issue is pev_colormap is 0-255, one value... not three dimensions.

WATCH_D0GS UNITED 03-15-2024 16:19

Re: Converting colors (3 to 1)
 
Quote:

Originally Posted by Hellkong (Post 2819540)
PHP Code:

static Float:fColors[3]
fColors[0] = random_num(0,255)
fColors[1] = random_num(0,255)
fColors[2] = random_num(0,255)

set_pev(Entpev_rendercolorfColors)
// And ofcourse render mode 



Hellkong 03-15-2024 17:04

Re: Converting colors (3 to 1)
 

You didnt get me, that was just an example of the color yellow, the issue is converting the 3 dimensions of the color values to 1 dimension so I can spawn the same color in pev_colormap

X value / 3 is not the solution for sure, it will give another color in pev_colormap.

pev_rendercolor = 3 dimensions RGB 0-255 0-255 0-256
pev_colormap = 1 dimension 0-255


Edit : correct, its random_float

Jhob94 03-15-2024 17:31

Re: Converting colors (3 to 1)
 
pev_colormap is not what you think it is
https://forums.alliedmods.net/showpo...01&postcount=7

Natsheh 03-16-2024 04:27

Re: Converting colors (3 to 1)
 
Search hue to RGB colors

Hellkong 03-16-2024 08:43

Re: Converting colors (3 to 1)
 
I believe this is what I want, I've searched a bit and it's complicated maths, can you give me direct calculation?
I am using random RGB floats for each dimension.

Jhob94 03-16-2024 10:06

Re: Converting colors (3 to 1)
 
I already gave you the answer of how colormap works.
Watch this video, maybe it helps you understand what colormap does

Hellkong 03-16-2024 13:04

Re: Converting colors (3 to 1)
 
1 Attachment(s)
Here ya go a model I use for more clarification, spawn an entity with the glow render mode, make random color values and see how to figure out the same color :


All times are GMT -4. The time now is 13:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.