SRL Archive - Test corner

R0b0t1 "InAreas"!


R0b0t1

2007-09-09 22:00:14

Lots 'o logic in these folks… More to come.


function InCave(GreyCave: Boolean): Boolean;
Var
BCol, Cnt, I, CurY, WCnt, B, TruCnt: Integer;
MSPoints: Array [0..29] of TPointArray;
CheckArr: Array [0..29] of Boolean;
CaveColArr: Array [0..5] of Integer;
ColPArr: Array [0..29] of Integer;
begin;
If (GreyCave) Then
begin;
CaveColArr[0]:= 2501162;
CaveColArr[1]:= 3095614;
CaveColArr[2]:= 1382167;
CaveColArr[3]:= 3818567;
CaveColArr[4]:= 3816000;
CaveColArr[5]:= 4543832;
end else
begin;
CaveColArr[0]:= 2971749;
CaveColArr[1]:= 4088688;
CaveColArr[2]:= 538965;
CaveColArr[3]:= 2175803;
CaveColArr[4]:= 872051;
CaveColArr[5]:= 2901327;
end;
Cnt:= 0;
CurY:= 0;
WCnt:= 0;
MSPoints[0].x:= MSX1;
MSPoints[0].y:= MSY1;
For I:= 1 to 29 do
begin;
MSPoints[I].x:= 75 * Cnt;
MSPoints[I].y:= 75 * WCnt;
If (I = 1) Then
MsPoints[I].x= 75;
If (I mod 2 = 0) Then
inc(Cnt);
If (Cnt = 5) Then
begin;
Cnt:= 0;
inc(WCnt);
incex(CurY, 75);
end;
end;
For I:= 0 to 29 do
ColPArr[I]:= GetColor(MSPoint[I].x, MSPoint[I].y);
For I:= 0 to 29 do
begin;
For B:= 0 to 5 do
begin;
CheckArr[I]:= SimilarColors(ColPArr, CaveColArr[B]);
If CheckArr[I] Then Break;
end;
end;
For I:= 0 to 29 do
begin;
If (CheckArr[I]) Then
inc(TruCnt);
end;
If (TruCnt >= 5) Then
Result:= True;
else
Result:= False;
end;

function InFally: Boolean;
Var
BCol, Cnt, I, CurY, WCnt, B, TruCnt: Integer;
MSPoints: Array [0..29] of TPointArray;
CheckArr: Array [0..29] of Boolean;
FallyColArr: Array [0..5] of Integer;
ColPArr: Array [0..29] of Integer;
begin;
FallyColArr[0]:= 2501162;
FallyColArr[1]:= 3095614;
FallyColArr[2]:= 1382167;
FallyColArr[3]:= 3818567;
FallyColArr[4]:= 3816000;
FallyColArr[5]:= 4543832;
Cnt:= 0;
CurY:= 0;
WCnt:= 0;
MSPoints[0].x:= MSX1;
MSPoints[0].y:= MSY1;
For I:= 1 to 29 do
begin;
MSPoints[I].x:= 75 * Cnt;
MSPoints[I].y:= 75 * WCnt;
If (I = 1) Then
MsPoints[I].x= 75;
If (I mod 2 = 0) Then
inc(Cnt);
If (Cnt = 5) Then
begin;
Cnt:= 0;
inc(WCnt);
incex(CurY, 75);
end;
end;
For I:= 0 to 29 do
ColPArr[I]:= GetColor(MSPoint[I].x, MSPoint[I].y);
For I:= 0 to 29 do
begin;
For B:= 0 to 5 do
begin;
CheckArr[I]:= SimilarColors(ColPArr, FallyColArr[B]);
If CheckArr[I] Then Break;
end;
end;
For I:= 0 to 29 do
begin;
If (CheckArr[I]) Then
inc(TruCnt);
end;
If (TruCnt >= 5) Then
Result:= True;
else
Result:= False;
end;

function InGreenArea(PercentCorr: Extended): Boolean;
Var
I: Integer;
X, Z: Extended;
YA: Array [0..29] of Extended;
MSPoints: Array [0..29] of TPointArray;
ColPArr: Array [0..29] of Integer;
begin;
MSPoints[0].x:= MSX1;
MSPoints[0].y:= MSY1;
For I:= 1 to 29 do
begin;
MSPoints[I].x:= 75 * Cnt;
MSPoints[I].y:= 75 * WCnt;
If (I = 1) Then
MsPoints[I].x= 75;
If (I mod 2 = 0) Then
inc(Cnt);
If (Cnt = 5) Then
begin;
Cnt:= 0;
inc(WCnt);
incex(CurY, 75);
end;
end;
For I:= 0 to 29 do
begin;
ColPArr[I]:= GetColor(MSPoint[I].x, MSPoint[I].y);
ColorToXYZ(ColPArr[I], X, YA[I], Z);
If (YA[I] > PercentCorr) Then
inc(TruCnt);
end;
Result:= (TruCnt >= 5);
end;

function InRedArea(PercentCorr: Extended): Boolean;
Var
I: Integer;
Y, Z: Extended;
XA: Array [0..29] of Extended;
MSPoints: Array [0..29] of TPointArray;
ColPArr: Array [0..29] of Integer;
begin;
MSPoints[0].x:= MSX1;
MSPoints[0].y:= MSY1;
For I:= 1 to 29 do
begin;
MSPoints[I].x:= 75 * Cnt;
MSPoints[I].y:= 75 * WCnt;
If (I = 1) Then
MsPoints[I].x= 75;
If (I mod 2 = 0) Then
inc(Cnt);
If (Cnt = 5) Then
begin;
Cnt:= 0;
inc(WCnt);
incex(CurY, 75);
end;
end;
For I:= 0 to 29 do
begin;
ColPArr[I]:= GetColor(MSPoint[I].x, MSPoint[I].y);
ColorToXYZ(ColPArr[I], XA[I], Y, Z);
If (XA[I] > PercentCorr) Then
inc(TruCnt);
end;
Result:= (TruCnt >= 5);
end;

function InBlueArea(PercentCorr: Extended): Boolean;
Var
I: Integer;
X, Y: Extended;
ZA: Array [0..29] of Extended;
MSPoints: Array [0..29] of TPointArray;
ColPArr: Array [0..29] of Integer;
begin;
If (PercentCorr <= 0.5) Then
WriteLn('PercentCorr Should be above 0.5, still checking');
MSPoints[0].x:= MSX1;
MSPoints[0].y:= MSY1;
For I:= 1 to 29 do
begin;
MSPoints[I].x:= 75 * Cnt;
MSPoints[I].y:= 75 * WCnt;
If (I = 1) Then
MsPoints[I].x= 75;
If (I mod 2 = 0) Then
inc(Cnt);
If (Cnt = 5) Then
begin;
Cnt:= 0;
inc(WCnt);
incex(CurY, 75);
end;
end;
For I:= 0 to 29 do
begin;
ColPArr[I]:= GetColor(MSPoint[I].x, MSPoint[I].y);
ColorToXYZ(ColPArr[I], X, Y, ZA[I]);
If (ZA[I] > PercentCorr) Then
inc(TruCnt);
end;
Result:= (TruCnt >= 5);
end;

function InYellowArea(PercentCorr: Extended): Boolean;
Var
I: Integer;
X, Y: Extended;
ZA: Array [0..29] of Extended;
MSPoints: Array [0..29] of TPointArray;
ColPArr: Array [0..29] of Integer;
begin;
If (PercentCorr >= 0.5) Then
WriteLn('PercentCorr Should be below 0.5, still checking');
MSPoints[0].x:= MSX1;
MSPoints[0].y:= MSY1;
For I:= 1 to 29 do
begin;
MSPoints[I].x:= 75 * Cnt;
MSPoints[I].y:= 75 * WCnt;
If (I = 1) Then
MsPoints[I].x= 75;
If (I mod 2 = 0) Then
inc(Cnt);
If (Cnt = 5) Then
begin;
Cnt:= 0;
inc(WCnt);
incex(CurY, 75);
end;
end;
For I:= 0 to 29 do
begin;
ColPArr[I]:= GetColor(MSPoint[I].x, MSPoint[I].y);
ColorToXYZ(ColPArr[I], X, Y, ZA[I]);
If (ZA[I] < PercentCorr) Then
inc(TruCnt);
end;
Result:= (TruCnt >= 5);
end;

Wizzup?

2007-09-10 02:23:05

Result := FindColoredAreaTolerance(greycolor)?

n3ss3s

2007-09-10 08:33:24

Wizzup do you know how much that breaks scripters heart when admin comes and cuts your function down to 3 lines?

Wizzup?

2007-09-10 09:19:41

From: n3ss3s
Wizzup do you know how much that breaks scripters heart when admin comes and cuts your function down to 3 lines?


No, I don't…. :cartman:

n3ss3s

2007-09-10 13:50:15

To bad no one can experiment on ya xD You'd shorten his shortening to 1 line :D

(not obfuscated 1000000000000000 chars long line)

R0b0t1

2007-09-10 17:32:11

God DAMNIT!

Oh well. Wait! Mine was an option to find if your in a grey cave, or a normal one. Hah!

I also found a way to use XYZ color… And In my opinion its application is better suited to it that to RGB or HSL.

Tim0suprem0

2007-09-10 17:44:35

From: r0b0t1

I also found a way to use XYZ color… And In my opinion its application is better suited to it that to RGB or HSL.


There we go… I was waiting for the HSL :p

R0b0t1

2007-09-10 18:01:02

EDIT: Wizzup? is wrong! Mine works differently from FindColoredArea! Mine takes points from the scre…. Just read them.



Well guess what? I just added my supa XYZ functions.

Wizzup?

2007-09-11 09:23:24

From: r0b0t1
EDIT: Wizzup? is wrong! Mine works differently from FindColoredArea! Mine takes points from the scre…. Just read them.



Well guess what? I just added my supa XYZ functions.


I'm not wrong…
FindColoredAreaTolerance does work a bit differently, yes, but the effect is the same…

R0b0t1

2007-09-11 16:47:09

No its not, in my opinion.

FindColoredArea just searches right to left, but mine takes samples from all over the screen. Much more accurate.