1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-01-07 03:38:06 -05:00

CTS cleanups.

This commit is contained in:
Merlijn Wajer 2011-06-16 12:52:10 +02:00
parent d9836a251c
commit 91d952d33a

View File

@ -328,6 +328,14 @@ begin
end;
end;
{
TODO: See if this is actually inlined. If it is, we can shorten the
subprocedures; if it is not, either:
- Paste a lot of code.
- Pass a record of the required data to prevent pushing arguments on the
stack.
}
function ColorSameCTS2(Tolerance: Integer; H1,S1,L1,H2,S2,L2, hueMod, satMod: extended):
boolean; inline;
begin
@ -1284,28 +1292,10 @@ var
c : integer;
RowData : TPRGB32Array;
dX, dY, clR, clG, clB, i,SpiralHi: Integer;
H1, S1, L1, H2, S2, L2, HueXTol, SatXTol: Extended;
procedure cts0;
var i: integer;
begin
Result := false;
DefaultOperations(xs,ys,xe,ye);
dX := xe - xs;
dY := ye - ys;
//next, convert the color to r,g,b
ColorToRGB(Color, clR, clG, clB);
ColorToHSL(Color, H1, S1, L1);
PtrData := TClient(Client).IOManager.ReturnData(xs, ys, dX + 1, dY + 1);
c := 0;
//Load rowdata
RowData:= CalculateRowPtrs(ptrdata,dy+1);
//Load the spiral path
LoadSpiralPath(x-xs,y-ys,0,0,dx,dy);
SpiralHi := (dx + 1) * (dy + 1) - 1;
case CTS of
0:
for i := 0 to SpiralHi do
if ((abs(clB-RowData[ClientTPA[i].y][ClientTPA[i].x].B) <= Tolerance) and
(abs(clG-RowData[ClientTPA[i].y][ClientTPA[i].x].G) <= Tolerance) and
@ -1315,9 +1305,11 @@ begin
ClientTPA[c].y := ClientTPA[i].y + ys;
inc(c);
end;
end;
1:
procedure cts1;
var i: integer;
begin
for i := 0 to SpiralHi do
if (Sqrt(sqr(clR - RowData[ClientTPA[i].y][ClientTPA[i].x].R) +
sqr(clG - RowData[ClientTPA[i].y][ClientTPA[i].x].G) +
@ -1327,9 +1319,13 @@ begin
ClientTPA[c].y := ClientTPA[i].y + ys;
inc(c);
end;
end;
2:
begin;
procedure cts2;
var i: integer;
H1, S1, L1, H2, S2, L2, HueXTol, SatXTol: Extended;
begin
ColorToHSL(Color, H1, S1, L1);
HueXTol := hueMod * Tolerance;
SatXTol := satMod * Tolerance;
for i := 0 to SpiralHi do
@ -1346,6 +1342,28 @@ begin
end;
end;
end;
begin
Result := false;
DefaultOperations(xs,ys,xe,ye);
dX := xe - xs;
dY := ye - ys;
//next, convert the color to r,g,b
ColorToRGB(Color, clR, clG, clB);
PtrData := TClient(Client).IOManager.ReturnData(xs, ys, dX + 1, dY + 1);
c := 0;
//Load rowdata
RowData:= CalculateRowPtrs(ptrdata,dy+1);
//Load the spiral path
LoadSpiralPath(x-xs,y-ys,0,0,dx,dy);
SpiralHi := (dx + 1) * (dy + 1) - 1;
case CTS of
0: cts0();
1: cts1();
2: cts2();
end;
SetLength(Points, C);
Move(ClientTPA[0], Points[0], C * SizeOf(TPoint));