PDA

View Full Version : Introduction/Explanation of RGB color + AutoColoring with RGB!



R0b0t1
09-09-2007, 05:23 PM
Welcome to the land of RGB!

Since almost every one knows what RGB is, I really shouldn't but (RGB will be a little confusing if you just came from a Color Theory class):



An RGB color space is any additive color space based on the RGB color model.
RGB-Cube
RGB-Cube

RGB is shorthand for Red, Green, Blue.

RGB is a convenient color model for computer graphics because the human visual system works in a way that is similar—though not quite identical—to an RGB color space. The most commonly used RGB color spaces are sRGB and Adobe RGB (which has a significantly larger gamut). Adobe has recently developed another color space called Adobe Wide Gamut RGB, which is even larger, in detriment to gamut density.

As of 2007, sRGB is by far the most commonly used RGB color space, particularly in consumer grade digital cameras, because it is considered adequate for most consumer applications, and its design simplifies previewing on the typical computer display. Adobe RGB is being built into more medium-grade digital cameras, and is favored by many professional graphic artists for its larger gamut.


of course, it could be explained like this...



RGB is the most popular way to display and/or reference colors. The consonants R, G, and B are representations of the intensity of the Red, Green, and Blue in that color.


What I've seen people trip up on, is that using RGB as a color spectrum is different from the real world RYB (Red yellow blue), as wavelengths of light mix differently from pigments... So don't think Red and blue make purple, they make a dark pink! (Lol? Who cares...).

So really, the only thing left would be to give you a picture...

http://i30.photobucket.com/albums/c350/r0b0t1/rgbcubes.jpg


Still don't get it? Hit me up on MSN (r0b0t1@hotmail.com) or PM me.



Now, most of you come here for autocoloring, yes? No interest in discussing how RGB works? Fine... But you first need to understand the principal used in autocoloring.

The Principal: When you get a color from Runescape, that color can be split up into the R, G, and B values of said color. How does this help? Well, we can check if we have the right color through trial and error, so creating an autocoloring procedure can be tiresome (I have yet to experiment with a custom version....), so the Devs' have made us some autocoloring procedures for us! Now, if you want to learn anything about making your own, you might as well listen to me.

Here are the steps (I will break down FindWaterColor).

1). First, know what you want to color.... (easiest on minimap)
2). Second, you must have a color similar to the one you want to auto color.
3). Now, we start to have fun. We must try to find that color and start comparing it.
4). *OPTINAL* if it is a color from the minimap, check if it is there.

EDIT: What Tarajunky told me he did was pick twenty colors and turn them to RGB, and pick one of those colors, and get the differenced bewtween those, and the "special" color you picked. Feel free to PM me (or post), as this may be confusing.

So, the breakdown...


function FindWaterColor: Integer;

You declare the function... Of course.


var
GC, a, l, TestColor, Red, Green, Blue : integer;
var
P:array of Tpoint;

And then the variables...


begin
GC := 12095356;
Flag;

Now, we start the function, set the color close to the one we want (The water color in this case), and wait until we stop moving (always a good idea).


FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 50);
l:=GetArrayLength(P);

Now, we search for the color like ours, with a high tolerance, and set a variable to be the length of the TpointArray P.


for a:= 0 to l-1 do
begin
if rs_OnMinimap(P[a].x,P[a].y) then
begin

Then we start a for loop, and for every iteration, we check if the point where one of the colors was found is on the minimap.


TestColor := GetColor(P[a].x,P[a].y);
if SimilarColors(TestColor,GC,50) then
begin

Now we get the color at the point on the MM where one of the colors was found... And then we check if that color is at least withing 50 tolerance of our main one.


red := (TestColor mod 256);
green := ((TestColor / 256) mod 256);
blue := ((TestColor / 256) / 256);

This is simply what ColorToRGB does.


if Green - Red <= 22 then if Green - Red >= 18 then
if Blue - Red >= 55 then if Blue - Red <= 72 then
if Blue - Green >= 35 then if Blue - Green <= 52 then
if GetColor(P[a].x + 2, P[a].y + 2) = TestColor then
if GetColor(P[a].x + 1, P[a].y + 1) = TestColor then
if GetColor(P[a].x, P[a].y + 2) = TestColor then
if GetColor(P[a].x + 2, P[a].y) = TestColor then
if GetColor(P[a].x, P[a].y + 1) = TestColor then
if GetColor(P[a].x + 1, P[a].y) = TestColor then
if GetColor(P[a].x + 2, P[a].y + 1) = TestColor then
if GetColor(P[a].x + 1, P[a].y + 2) = TestColor then
begin

This is the hardest part, the comparison. This just makes sure that the color it found is fairly close to the original one, by lots of if statements... I guess I'll go ask Tarajunky how he got those numbers...


Result := TestColor;
WaterColor := TestColor;
WriteLn('WaterColor = ' + IntToStr(TestColor));
Exit;
end;
end;
end;
end;

Now, should it pass all of those tests... Then it makes the global Var WaterColor equal to whatever it found, prints the watercolor, and returns the water color... Yay.


WriteLn('Could not find Water Color!');
Result := 0;
end;

Lest misfortune befall our mighty script, it will tell you so.


Another possible use for this would be to find colors, as you could and can change each different part of the color singly. Or, you could make an object finding, npc finding, and other finding thing with it. (Some things should be saved for HSL, of course)

Now... I trust you all will start thinking... Or else!

ShowerThoughts
09-09-2007, 05:35 PM
nice one i really understand 75% of it gratz

cathering_
09-09-2007, 06:02 PM
Confusion , confusion

Where did you get the '1' variable from, Ill learn TPoints then come back :p

R0b0t1
09-09-2007, 06:42 PM
I said if you didn't get part of the tutorial, to come see me.


Well, TPoints are just ... points. And are used as.


Var TPoint1: TPoint;

TPoint1.x:= SomeValue;
TPoint1.y:= SomeValue;


Tada?

stupedspam
09-09-2007, 09:54 PM
Color Master!

Three Tutorials all about color in under 24 hours! I would say the above is true!! :D

~Stupedspam

R0b0t1
09-09-2007, 11:05 PM
Lol, yep, I'm working for it... I want to annoy Fakawi enough to get him to give me that title. :p. (JK).


Well, I want to accomplish something. Color seemed the easiest way.

Santa_Clause
09-09-2007, 11:49 PM
Now, we start the function, set the color close to the one we want (The water color in this case), and wait until we stop moving (always a good idea).

I don't understand what you meant by this. Does it mean choose a colour that's close to the one we want?

R0b0t1
09-10-2007, 12:07 AM
Yes. I forgot to edit my post.

To answer you're question, I mean the Variable called "GC" in the function. Sorry :).

stampede10343
03-01-2008, 04:41 AM
sorry for the bump, but i have a question about how to get these numbers when using RGB if Green - Red <= {22} then if Green - Red >= {18} then
if Blue - Red >= {55} then if Blue - Red <= {72} then
if Blue - Green >= {35} then if Blue - Green <= {52} then
{ The commented values are the ones i dont know how to get}

Again sorry for the bump, i know its not a huge jump but yea. thanks for all your help

Cameron

Wizzup?
03-01-2008, 11:32 AM
If you pick the watercolor run it through ColorToRGB() you will have 3 vars, just print them out using writeln. ;)

stampede10343
03-01-2008, 01:59 PM
If you pick the watercolor run it through ColorToRGB() you will have 3 vars, just print them out using writeln. ;)

So once i do that should i pick another color, thats still the water color but when it has changed during a world switch or something? and subtracting the values of RGB and see if i get a kinda consistent result? thanks

Wizzup?
03-01-2008, 02:04 PM
So once i do that should i pick another color, thats still the water color but when it has changed during a world switch or something? and subtracting the values of RGB and see if i get a kinda consistent result? thanks

Thats right.

stampede10343
03-01-2008, 03:55 PM
ok sweet i might PM you if i need any more help thanks again

Jackrawl
07-02-2008, 04:38 AM
I guess I'll go ask Tarajunky how he got those numbers...
...? Why would you put that in if you don't plan on updating with what Tara said?