SRL Archive - Discussions and Debates

Colour Tolerance Aid?


The Claw

2007-08-11 23:36:50

Just wondering if this would be possible, cause it would be pretty cool. When you put tol on, you dont know what range of colours that it will cover, so its pretty much geusswork, trying to get it to work perfectly. But if you could graphically see what range of colours it would cover, it would make things much more easier and neater. Woudl it be possible for someone to make something which you can type the colour into, and the tol, and then it would show a gradient or whatever of the colour range that it is covering. This is what I mean:


between the min, no and max tol would be the range of colours that its covering. i think it be in a form or something

Special Ed

2007-08-12 00:01:27

Well I can make something that will give you a list of colors but I'm not so good with forms so you might need to ask some one who is to do that.

bullzeye95

2007-08-12 00:27:22

I don't think this would be possible without looping through tons of colors…

Special Ed

2007-08-12 00:34:52

Dude you made that for me… remember like a while back… lol, and yes it does loop through a ton of colors and it lags like a mofo but it works!

Santa_Clause

2007-08-12 01:01:59

I can do the form…

Special Ed

2007-08-12 01:04:56

Alright then, if you'd like some help on the coding just let me know and I could send it to you / explain it, maybe give you a hand making it into a form. Who knows, although I may not be very good with forms I could probably still help make one, I'm good at generating ideas. :D Normally…

Santa_Clause

2007-08-12 01:29:10

Lol…I'm not going to bother with coding it. If The Claw can't do it, then I can't. I was just suggesting if the person making the script didn't know how to make forms, I would make them…

bullzeye95

2007-08-12 01:30:49

Lol I did? I don't remember that at all :p

(Was that the day I was sniffing all those sharpies?)

rkroxpunk

2007-08-12 03:42:34

so basically it just finds the max tolerance that you could have for colour X before it starts picking up colour Y? If so i'm 100% sure it's been done

SKy Scripter

2007-08-12 05:04:39

ok.. the problem Scar's Sim Color finder has multi max colors the way it works.. its like the distance…



function SimColors(c1, c2, tol :Integer) : Boolean;
var
R, G, B : array [1..2] of integer;
begin
ColortoRGB(c1, R[1], G[1], B[1]);
ColortoRGB(c2, R[2], G[2], B[2]);
Result := (Abs(R[1] - R[2]) + Abs(G[1] - G[2]) + Abs(B[1] - B[2]) <= Tol);
end;

Bobarkinator

2007-08-12 20:54:38

I might take a crack at this. Sounds very useful.

the scar noob

2007-08-16 17:40:46

From: bobarkinator
I might take a crack at this. Sounds very useful.


sounds cool bob, tell em when it's done, lol
you guys are way better than i am.. so i don't think i can help :p

R0b0t1

2007-08-16 18:22:11

So… I think I know how to do it… But it might take a while


EDIT:

Function GetColorsInRange(Color, Range: Integer):Array of Integer;
Var I, B, D:Integer;
begin;
D:= Range*2+1;
SetArrayLength(Result, D);
B:= 0;
For I:= Color downto Color-Range do
begin;
Result[B]:= I
inc(B);
end;
inc(B);
Result[B]:= Color;
inc(B);
For I:=Color to Color+Range do
begin;
Result[B]:= I;
inc(B);
end;
end;

Haven't tried it, but it might work.

bullzeye95

2007-08-16 18:43:16

We want numbers in a TOLERANCE range, not a NUMBER range though.

I'll think.

tarajunky

2007-08-16 19:50:03

From: SKy Scripter
ok.. the problem Scar's Sim Color finder has multi max colors the way it works.. its like the distance…



function SimColors(c1, c2, tol :Integer) : Boolean;
var
R, G, B : array [1..2] of integer;
begin
ColortoRGB(c1, R[1], G[1], B[1]);
ColortoRGB(c2, R[2], G[2], B[2]);
Result := (Abs(R[1] - R[2]) + Abs(G[1] - G[2]) + Abs(B[1] - B[2]) <= Tol);
end;


Then you could make 3 lines of color, each of which have a min/max for one color component.

For one line, hold R/G constant and change B. Second line hold R/B constant and change G. Third line hold G/B constant and change R.

It may not give you EVERY color within the tolerance range, but it will show you the extremes and all the intermediate values in each color component.

Also, you will have the same number of colors in each plot, so it will match up nicely.

R0b0t1

2007-08-16 20:41:53

From: bullzeye95
We want numbers in a TOLERANCE range, not a NUMBER range though.

I'll think.



A tolerance range is like a number range… I think.

If I'm right, then tolerance is when it searches for all of the colors however many numbers away.

So with a tolerance of 20, it might go 20 below the number, and 20 above…

Maybe freddy could help?

SKy Scripter

2007-08-16 21:06:08

From: tarajunky
Then you could make 3 lines of color, each of which have a min/max for one color component.

For one line, hold R/G constant and change B. Second line hold R/B constant and change G. Third line hold G/B constant and change R.

It may not give you EVERY color within the tolerance range, but it will show you the extremes and all the intermediate values in each color component.

Also, you will have the same number of colors in each plot, so it will match up nicely.


yeah… i know that's why i said "multi max colors"…
but still theres just to many diffrent colors… but whatever lol..

Edit : It could be done just not the way everyone thought ;) ( that was what i was pointing out really)

TOB

2007-08-17 03:49:28

I showed Freddy this thread and he said he has already planned tolerance aids for the future… whenever that may be.

Wizzup?

2007-08-17 03:52:46

Why not use Nielsie's ACA, or look at my tut for color tolerances?

TOB

2007-08-17 05:27:21

{.Script Info:
# ScriptName = Color Tolerance Ranges
# Author = TOB (Tigiot)
# Description = Used to find the range of colors with a certain tolerance.
# Version =
# Date = August 17, 2007
# Comments = The thing is weird, with a tolerance of 50 it will return more results for gaps of 1000 than 100.
/Script Info}
program ColorToleranceRanges;

const Color1 = 555555;
const Tol = 255;
const ColorGaps = 10;

var Color2, ColorsFile, NumberOfColors: Integer;
var Colors: string;

begin
Color2:= Color1;
repeat
Color2:= Color2 - ColorGaps;
if(Color2 > 16777215) then Color2:= 16777215;
if(Color2 < 0) then Color2:= 0;
if(SimilarColors(Color1, Color2, Tol)) then
begin
Colors:= IntToStr(Color2) + Chr(13) + trim(Colors);
NumberOfColors:= NumberOfColors + 1;
//Writeln(IntToStr(NumberOfColors));
end else
Break;
until((Color2 = 16777215) or (Color2 = 0));
Colors:= Colors + '---------' + Chr(13) + IntToStr(Color1) + Chr(13) + '---------';
Color2:= Color1;
repeat
Color2:= Color2 + ColorGaps;
if(Color2 > 16777215) then Color2:= 16777215;
if(Color2 < 0) then Color2:= 0;
if(SimilarColors(Color1, Color2, Tol)) then
begin
Colors:= trim(Colors) + Chr(13) + IntToStr(Color2);
NumberOfColors:= NumberOfColors + 1;
//Writeln(IntToStr(NumberOfColors));
end else
Break;
until((Color2 = 16777215) or (Color2 = 0));
Writeln(Colors);

ColorsFile:= RewriteFile(AppPath + 'Colors.txt', False);
WriteFileString(ColorsFile, Colors);
CloseFile(ColorsFile);

Writeln(IntToStr(NumberOfColors) + ' color(s).');
Writeln('Filename: ' + AppPath + 'Colors.txt');
ColorsFile:= OpenFile(AppPath + 'Colors.txt', False);
Writeln('Filesize: ' + IntToStr(ColorsFile) + ' bytes.');
CloseFile(ColorsFile);
end.

Open the file in something other than Notepad (Notepad++ or Wordpad should do the trick).

With bigger amounts it will lag.

Please comment on the code here: http://www.villavu.com/forum/showthread.php?t=15450

Edit: Someone could have it do a bigger gap on top of my search gap and have it draw a 1x20 line of color in the canvas if they wanted so you could have a better visable range.

tarajunky

2007-08-17 09:30:54

Try this out.

bullzeye95

2007-08-17 18:31:39

I DID IT!
procedure RemoveDuplicates(var I: TIntegerArray);
var
C, CC, CCC: Integer;
Going: Boolean;
begin
repeat
Going:= False;
for C:= 0 to Length(I) - 1 do
for CC:= 0 to Length(I) - 1 do
begin
for CCC:= 0 to Length(I) - 1 do
begin
if(CC = CCC)then continue;
try
if(I[CC] = I[CCC])then
begin
Swap(I[CC], I[Length(I) - 1]);
SetLength(I, Length(I) - 1);
end;
except
Going:= True;
break;
end;
end;
if(Going)then break;
end;
until(not(Going))
end;

procedure FixArray(var I: TIntegerArray);
begin
RemoveDuplicates(I);
BubbleSort(I);
end;

function GetColorsTolRange(Col, Tol: Integer): TIntegerArray;
var
R, G, B, IR, IG, IB, TolC, Index: Integer;
begin
ColortoRGB(Col, IR, IG, IB);
ColortoRGB(Col, R, G, B);
for TolC:= Tol downto 0 do
for R:= Tol downto 0 do
for G:= (Tol - R) downto 0 do
for B:= Tol - (R + G) downto 0 do
begin
Index:= Index + 2;
SetLength(Result, Index);
Result[Index - 1]:= RGBtoColor(IR + R, IG + G, IB + B);
Result[Index - 2]:= RGBtoColor(IR - R, IG - G, IB - B);
end;
writeln('Fixing array...');
FixArray(Result); //TAKES A FEW MINUTES!!!!!!!!!!
end;
FixArray takes forever…
It loops through all the possible numbers and adds them to an array.
:D

Bobarkinator

2007-08-17 20:55:54

Lol bullzeye you have become obsessed with Bubble :p.

Anyways all of the ones you guys did look great.

bullzeye95

2007-08-17 20:59:03

Huh? Waddaya mean?

Bobarkinator

2007-08-17 21:13:42

I've seen you use bubble a lot lately. That one uses bubblesort.