Results 1 to 5 of 5

Thread: Function AutoColorThisColor!

  1. #1
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default Function AutoColorThisColor!

    Should be able to use it for anything, but I want someone to test it along with me, so I can improve it .

    SCAR Code:
    program New;

    function AutoColorThisColor(ThisColor, PrefTol, Accry: Integer): Integer;
      Var
        DidFind: Boolean;
        I, x1, y1, Cnt, FirstCorr: Integer;
        X, Y, Z, Xc, Yc, Zc: Extended;
        AX, AY, AZ: Array [1..20] of Extended;
        ColorAr: Array [0..21] of Integer;
        SkipAr: Array [0..19] of TPoint;
      begin
        ColorAr[0]:= ThisColor;
        For I:= 1 to 20 do
          begin
            DidFind:= FindColorSkipCoordsTolerance(x1, y1, ThisColor, MSX1, MSY1, MSX2, MSY2, 50, SkipAr);
            If (DidFind) Then
              begin
                ColorAr[I]:= GetColor(x1, y1);
                SkipAr[I].x:= x1;
                SkipAr[I].y:= y1;
                ColorToXYZ(ColorAr[I], AX[I], AY[I], AZ[I])
              end;
          end;
        If (Accry > GetArrayLength(ColorAr)) Then
          Accry:= GetArrayLength(ColorAr);
        X:= AMaxE(AX);
        Y:= AMaxE(AY);
        Z:= AMaxE(AZ);
        Xc:= X - AMinE(AX);
        Yc:= Y - AMinE(AY);
        Zc:= Z - AMinE(AZ);
        FirstCorr:= 2;
        For I:= 0 to (GetArrayLength(ColorAr) - 1) do
          begin
            If (AX[I] > (Xc - StrToFloat(IntToStr(PrefTol)))) and
               (AX[I] < (X + StrToFloat(IntToStr(PrefTol)))) and
               (AY[I] > (Yc - StrToFloat(IntToStr(PrefTol)))) and
               (AY[I] < (Y + StrToFloat(IntToStr(PrefTol)))) and
               (AZ[I] > (Zc - StrToFloat(IntToStr(PrefTol)))) and
               (AZ[I] < (Z + StrToFloat(IntToStr(PrefTol)))) Then
              begin
                If (FirstCorr >= I) Then
                  FirstCorr:= I;
                inc(Cnt);
          end;
        If (Cnt >= Accry) Then
            Result:= XYZToColor(AX[FirstCorr], AY[FirstCorr], AZ[FirstCorr])
          else
            Result:= 0
      end;

    begin
    end.
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

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

    Default

    Have you ran this? I get all kinds of compiling errors... You are trying to boolean an integer result..
    Hup Holland Hup!

  3. #3
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Haha, good job robot, but yes except for that thing, you forgot making the autocoloring xD

  4. #4
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    Eh? WTF?

    Hmm... I must have had my mind elsewhere. When I change the result it will become autocoloring!

    But I sometimes put errors in there to see if people actually test it. And I see you did, but I didn't intend that .

    EDIT: GARGH! Stupid SCAR... Some of these errors don't even make sense!
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  5. #5
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    FIxed, it should compile now.
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  2. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  3. Any function that does this?
    By shadowpwner in forum OSR Help
    Replies: 2
    Last Post: 08-14-2007, 03:15 AM
  4. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 AM

Posting Permissions

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