PDA

View Full Version : RGB colors



Grandelf
12-29-2014, 09:11 PM
General information
I decided to do a small release that may not be of any use to you at all.
However if you're interested in this type of thing or use a lot of colors in your scripts
this might be useful to you.
So why have RGB colors when we can already use hexadecimal codes?
Absolutely no reason, I just had this idea in my head for a while and wanted
to do something different aswell as freshing some things up.
It may actually be a little easier to use colors and memorize them with this script,
especially if you have no idea what a hexadecimal number is.

So what does this do?
This is a script that will allow you to use RGB colors. You basically call a function and
it will convert it into a usable color code for you.

How does it work?
For those of you who don't really know what RGB is, you can either look it up on google
or read my explanation. RGB basically stands for R (red), B (blue) and G (green).
With those three colors you can mix around and create 16777216 colors to be exact.
For each color type you use a number between 0 and 255. The number depends on
how intense you want the color to be.

http://upload.wikimedia.org/wikipedia/commons/c/c2/AdditiveColor.svg

Some examples:

Red:

255, 0, 0
We are using the highest intensity on the first argument (red), the other two are 0
which means they are not used at all.

Dark(er) red:

150, 0, 0
Here we are using a lower intensity on red then before and the other two are 0 again.
Because the intensity is lower the color we get will be darker.

Green:

0, 255, 0
Here we are only using the 2nd one (green) on the highest intensity

Purple:

255, 0, 255
Here we mix up red with blue which makes purple (see picture above).

More examples: RGB colors (http://www.rapidtables.com/web/color/RGB_Color.htm)

How to use this script?

Simply put it in your scripts folder. Then use the global function to get a color code.

local red = RGB(255, 0, 0);
So to send a red message to a player you could do:


function sendRedMessage(player)
local red = RGB(255, 0, 0);
player:SendBroadcastMessage(red .. "This message will be red");
end


Script: http://pastebin.com/b4TFN7Ti

Grandelf.

Tommy
12-29-2014, 09:47 PM
Great release!

shotsofdeath98
12-31-2014, 06:32 PM
more colors; http://www.rapidtables.com/web/color/RGB_Color.htm

Hyperion
12-31-2014, 06:33 PM
more colors; http://www.rapidtables.com/web/color/RGB_Color.htm

He already has that link in his post =P

Kaev
01-01-2015, 11:28 AM
Awesome release! A version for C++ scripts would be nice for those, who doesn't use Eluna.

Avatar789
07-24-2016, 05:12 AM
How to Use it? Let's insert this function in the Gossip?

Syphex
07-24-2016, 02:23 PM
How to Use it? Let's insert this function in the Gossip?
It's explained at the end of the post. - -

How to use this script
Simply put it in your scripts folder. Then use the global function to get a color code.