So I've been working on this color stuff today and here's what I came up with.
I found as canada said, you can convert a color into hex and get a 6 character hex string. The first 2 characters are the hex value of the blue component, last 2 red, middle green. So I made a script to demonstrate this. The script converted SCAR color to hex, split into 3, and converted back to decimal, and did the reverse. I went into paint, made a custom color, took note of the red, green, and blue values, and used the scar color picker to get the color. Armed with this infomation I was able to convert from RGB to SCAR and check if it was correct. Then I noticed a problem, when any of the RGB values were low, the hex string was less than 6 characters. This is how hex values work:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F
As you can see the first few are only 1 character, theres really a 0 before each one (0F etc) which would up hold the 6 character length, but these 0's get lost in the process. So the hex values were less than 6 chars, which meant that finding the red section gave an error, because strget was looking for the 6th, and even if there was no error, there others were inaccurate because you dont know if 5FFFB is 5 FF FB(yellow) or 5F FF B(green).
So I found a new way to convert that doesn't use hex, in fact it does almost the same thing that hex does but skips over the hex part. Here are the functions I wrote:
type rgbcolor =record
red,green,blue:integer;
end;
function color2rgb(color:integer):rgbcolor;
begin
result.red:=(color mod 256);
result.green:=((color/256) mod 256);
result.blue:=((color/256) / 256);
end;
function rgb2color(rgb:rgbcolor):integer;
begin
result:=(((rgb.blue*256)+rgb.green)*256)+rgb.red
end;
As you can see it works by using 256 because the rbg values are 0-255.
program New;
type rgbcolor =record
red,green,blue:integer;
end;
var
color:integer;
color2:rgbcolor;
//---------Setup--------
const
color=5200980;
function color2rgb(color:integer):rgbcolor;
begin
result.red:=(color mod 256);
result.green:=((color/256) mod 256);
result.blue:=((color/256) / 256);
end;
function rgb2color(rgb:rgbcolor):integer;
begin
result:=(((rgb.blue*256)+rgb.green)*256)+rgb.red
end;
begin
writeln('----------------');
writeln(inttostr(color));
writeln(' ');
color2:=color2rgb(color)
writeln(inttostr(color2.red));
writeln(inttostr(color2.green));
writeln(inttostr(color2.blue));
end.
I wrote this to try and find the pattern (or at least range) in the color changes of a certain rock after switching worlds. You put in a color, say 5200980 and it outputs
—————-
5200980
84
92
79
I did this a few times to get a range for the grey rocks RGB values. I then put these ranges into the following script that uses Yakman's color displaying code. Notice how the colors are similiar when you change the RGB values in this script, but range when you change the SCAR value, like in Yakman's.
program New;
type rgbcolor =record
red,green,blue:integer;
end;
var
color,x,y,z,{x1,y1,z1,x2,y2,z2,}square,buffer:integer;
{waitforme:boolean; }
color1:rgbcolor;
//---------SETUP------------
const
//should I wait for you to press ctrl
//after showing the number of colors
//before displaying them?
waitformetotal=true;
//Should I wait for you to press ctrl
//before displaying each color?
waitforme=false;
x1=63;{red min} x2=97;{red max}
y1=75;{green min} y2=92;{green max}
z1=61;{blue min} z2=83;{blue max}
function rgb2color(rgb:rgbcolor):integer;
begin
result:=(((rgb.blue*256)+rgb.green)*256)+rgb.red
end;
begin
{waitforme:=false;
x1:=63; //red start
y1:=75; //green start
z1:=61; //blue start
x2:=97; //red end
y2:=81; //green end
z2:=83; //blue end
}
x:=x1-1;
y:=y1-1;
z:=z1-1;
writeln('there will be '+inttostr((x2-x1)*(y2-y1)*(z2-z1))+' colors');
if waitformetotal then
begin
repeat
wait(10);
until isfunctionkeydown(1);
end;
cleardebug;
square:=bitmapfromstring(50,50,'');
displaydebugimgwindow(100,100);
buffer:=bitmapfromstring(100,100,'') ;
repeat
x:=x+1;
y:=y1;
repeat
y:=y+1;
z:=z1;
repeat
z:=z+1;
//writeln(inttostr(x)+' '+inttostr(y)+' '+inttostr(z));
color1.red:=x;
color1.green:=y;
color1.blue:=z;
color:=rgb2color(color1);
writeln(inttostr(color)+' '+inttostr(x)+' '+inttostr(y)+' '+inttostr(z));
fastdrawclear(square,color)
fastdrawclear(buffer,0)
fastdrawtransparent(25,25,square,buffer)
safedrawbitmap(buffer,getdebugcanvas,0,0)
status('Color = '+inttostr(color))
if waitforme then
begin
repeat
wait(10);
until isfunctionkeydown(1);
end;
until z=z2;
until y=y2;
until x=x2;
end.
So, if you want to find similar colors, you need to change the RGB values.
So far, my experiments with finding a pattern in the color of a certain rock (to see which rock go to srl member scripts>fighters> WT Fakawi's Guard fighter> look at his zoomed in screen shot) show that there is no pattern in the SCAR color nor the RGB colors (that I can see with my small sample size) but there is a range. It took the lowest and highest RGB values, found the RGB ranges, multiplied those 3, and found that the range of greys so far is over 12 thousand, and that's from only 4 colors. The range of SCAR colors for these 4 is about 1.2mil, and includes all sorts of colors.
I started this because I wanted to make a procedure to auto color the color of the rock, and shape recognition didn't work because it changed and there were similiar shapes, neither did find a color that appeared a certain number (or within a range) of times. So I thought what I knew the range of colors it could be, and have the script go through them til it found 1. However, that's looking less likely with 12 thousand creeping up. It's interesting to investigate anyway though.
Congrats for reading this far.