AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   Colors (https://forums.alliedmods.net/showthread.php?t=85014)

Scherzo 02-04-2009 10:56

Colors
 
9 Attachment(s)
Update v1.3
I decided to add support all ways of saving color i know.

name (english name of color, fe. 'red')
hex #RRGGBB
dec RRRGGGBBB (3chars color value require, 12->012)
dec(2) RRR GGG BBB

Code:

---------
It helps in work with colors.
Default support dec&hexRGB colors, but when you call colors_init() can convert names*1 too.

From different ways of showing color gets array of RGB colors

    new iColor[3]={R, G, B}

for plugin configuration.


Functions:
---------------------------------------------------------
get_full_color(const color[], iColor[3])
    - main function of .inc

    get_full_color("#FFFFFF",iColor); //iColor={255,255,255}
    get_full_color("white",iColor); //iColor={255,255,255}
    get_full_color("255255255",iColor); //iColor={255,255,255}   
    get_full_color("255 255 255",iColor); //iColor={255,255,255}
   
    get_full_color("255 25 255",iColor); //iColor={255,25,255}

---------------------------------------------------------
get_color(const color[],ColorsP:type)
    - work with hexRGB or named color
    - type is one from list:
    enum ColorsP
    {
        R=1, // Red
        G, // Green
        B // Blue
    }
---------------------------------------------------------

*1 please check configs/colors.ini

---------


Hawk552 02-04-2009 11:18

Re: Colors
 
You might consider using an enum for R/G/B instead of 1/2/3. That way, you could also tag it so it's more understandable.

Scherzo 02-04-2009 11:29

Re: Colors
 
Sure, thanks. Updated

YamiKaitou 02-04-2009 11:54

Re: Colors
 
Please upload using ZIP format to avoid issues

xPaw 02-04-2009 12:24

Re: Colors
 
thats nice! GJ!

Scherzo 04-02-2009 15:56

Re: Colors
 
v1.2
new function and little optimalized

Scherzo 06-22-2009 09:44

Re: Colors
 
Update v1.3

Example added.

[MSI] Creator 07-10-2009 10:17

Re: Colors
 
this is not finishet

Scherzo 07-16-2009 06:22

Re: Colors
 
Quote:

Originally Posted by [MSI] Creator (Post 868920)
this is not finishet

Hmm?

Shard 09-02-2009 13:15

Re: Colors
 
Thanks! Finally, im able to get the code for teal :P


All times are GMT -4. The time now is 08:34.

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