Results 1 to 5 of 5

Thread: FindColorToleranceInc

  1. #1
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default FindColorToleranceInc

    Very basic function, searchs for a color without having to worry about finding the right tolerance for it. Just enter the same as the normal FindColorTolerance, just put what you want the maximum tolerance to be instead of the static tolerance.

    SCAR Code:
    {*******************************************************************************
    Function FindColorToleranceInc(Color: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; MaxTolerance: Integer): Boolean;
    By: Richard
    Description: Searches for the color in the set area and increases the
    tolerance until it finds the color or the maximum tolerance is reached.
    *******************************************************************************}


    Function FindColorToleranceInc(Color: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; MaxTolerance: Integer): Boolean;
    Var
    tol : Integer;
    Begin
      tol := 0;
      If (MaxTolerance <= -1) then
        srl_Warn('FindColorToleranceInc', 'Tolerance cannot be below 0', warn_AllVersions);
      For tol := 0 to (MaxTolerance - 1) do
      Begin
        If FindColorTolerance(x, y, Color, xs, ys, xe, ye, tol) then
        Begin
          Result := FindColorTolerance(x, y, Color, xs, ys, xe, ye, tol);
          WriteLN('FindColorToleranceInc: '+IntToStr(tol)+' was the final tolerance');
          Break;
        end;
        tol := tol + 1;
        If (tol >= MaxTolerance) then
        Begin
          srl_Warn('FindColorToleranceInc', 'couldn'#39't find the color', warn_AllVersions);
          Exit;
        end;
      end;
    end;
    Last edited by Richard; 03-21-2009 at 11:09 AM.

  2. #2
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    well, in this case tol = i, so no need to have both variables.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  3. #3
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Didn't think of that when scripting it, I'll edit it now.

  4. #4
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Scar Code:
    If FindColorTolerance(x, y, Color, xs, ys, xe, ye, tol) then
        Begin
          Result := FindColorTolerance(x, y, Color, xs, ys, xe, ye, tol); //Why a second search?
          WriteLN('FindColorToleranceInc: '+IntToStr(tol)+' was the final tolerance');
          Break;
        end;
        tol := tol + 1; //Why in a for-loop?
        If (tol >= MaxTolerance) then //Why is this in the loop?
        Begin
          srl_Warn('FindColorToleranceInc', 'couldn'#39't find the color', warn_AllVersions);
          Exit;
        end;
    Hup Holland Hup!

  5. #5
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    pascal Code:
    function FindColorToleranceIncEx(var x, y: Integer; Color: Integer; xs, ys, xe, ye: Integer; MaxTolerance: Integer; var TheTol: Integer): Boolean;
    var
      tol: Integer;
    begin
      if (MaxTolerance < 0) then
        srl_Warn('FindColorToleranceInc', 'Tolerance cannot be below 0', warn_AllVersions);
      for tol := 0 to (MaxTolerance) do
      begin
        Result := FindColorTolerance(x, y, Color, xs, ys, xe, ye, tol);
        if Result then
        begin
          TheTol := Tol;
          WriteLn('FindColorToleranceInc: ' + IntToStr(tol) + ' was the final tolerance');
          Exit;
        end;
      end;
      WriteLn('Could not find the Color.');
    end;

    function FindColorToleranceInc(var x, y: Integer; Color: Integer; xs, ys, xe, ye: Integer; MaxTol: Integer): Boolean;
    begin
      Result := FindColorToleranceIncEx(x, y, Color, xs, ys, xe, ye, MaxTol, xs);
    end;
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •