All pastes #373681 Raw Edit

Unnamed

public text v1 · immutable
#373681 ·published 2007-02-26 22:58 UTC
rendered paste body
Function ControlledColorSearch(x,y,Color,x1,y1,x2,y2,Tol,xc,yc:integer;flip:boolean;Wind:Longint):boolean; stdcall;
var
Windc:HDC;
color11:Tcolor;
varint:Tpoint;
begin
Windc:=GetDc(Wind);
if x1 > x2 then
    VarInt.x := 1
  else if y1 = y2 then
    varint.y := 0
  else
    VarInt.x := -1;
  if y1 > y2 then
    VarInt.y := 1
  else if y1 = y2 then
    varint.y := 0
  else
    VarInt.y := -1;
if (xc=0) and (yc=0) then
begin
  X:=x1 + VarInt.x;
  y:=y1 + VarInt.y;
end
else
begin
  if xc > -1 then
    if (flip=true) and (x=x2) then
      x := x1 + varint.x
    else x := xc;
  if yc > -1 then
  if (flip = False) and (y = y2) then
   y := y1 + VarInt.Y
  else y := yc;
end;
if (flip = False) then
begin
  repeat
    if not(y = y2) and not(x = x2) then
    begin
    if x1 < x2 then
      x :=x + 1
    else if x1 > x2 then
      x := x - 1;
      Color11:=GetPixel(windc,x,y);
      if (SimilarColors(color,color11,Tol) = true) then
      begin
        result:=True;
        xc:=x;
        yc:=y;
        exit;
      end;
    end;
    repeat
      if not(y = y2) then
      begin
      if y1 < y2 then
        Y := y + 1
      else
        Y := y - 1;
      Color11 := GetPixel(windc,x,y);
      if (SimilarColors(color,color11,Tol) = true) then
      begin
        result:=True;
        xc:=x;
        yc:=y;
        exit;
      end;
      end
      else
      begin
        y:=y1;
        break;
      end;
    until (y = y2) or (result = true);
  until (x = x2) or (result = true);
end;

if (flip = True) then
begin
  repeat
    if not(y = y2) and not(x = x2) then
    begin
    if y1 < y2 then
      y :=y + 1
    else if y1 > y2 then
      y := y - 1;
      Color11:=GetPixel(windc,x,y);
      if (SimilarColors(color,color11,Tol) = true) then
      begin
        result:=True;
        xc:=x;
        yc:=y;
        exit;
      end;
    end;
    repeat
      if not(x = y2) then
      begin
      if x1 < x2 then
        x := x + 1
      else
        x := x - 1;
      Color11 := GetPixel(windc,x,y);
      if (SimilarColors(color,color11,Tol) = true) then
      begin
        result:=True;
        xc:=x;
        yc:=y;
        exit;
      end;
      end
      else
      begin
        x:=x1;
        break;
      end;
    until (x = y2) or(result = true);
  until (y = x2) or (result = true);
end;
end;