Results 1 to 4 of 4

Thread: Universal AutoColor function

  1. #1
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Universal AutoColor function

    My first function:
    SCAR Code:
    function FindMyColor(Color,Tol : Integer) : Integer;
    var
      x,y,YourColor,U,K : Integer;
    begin
      MarkTime(U);
      if FindColorTolerance(x, y, Color, MMX1, MMY1, MMX2, MMY2, Tol) then
      begin
        YourColor := GetColor(x,y);
        Writeln('Your Color = '+ IntToStr(YourColor));
        K := TimeFromMark(U);
        Writeln('Took '+ IntToStr(K)+' mscs');
        Result := YourColor;
      end else
      begin
        Writeln('Could not find your color!');
      end;
    end;

    Code:
    Your Color = 2130293
    Took 31 mscs
    Successfully executed


  2. #2
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    function FindMyColor(Var X, Y: Integer; Color, X1, Y1, X2, Y2, Tol: Integer) : Integer;
    begin
      if FindColorSpiralTolerance(x, y, Color, X1, Y1, X2, Y2, Tol) then
      begin
        Result := GetColor(X, Y);
        Writeln('Your Color = '+ IntToStr(Result));
      end else
        Writeln('Could not find your color!');
    end;

    A bit shorter. Now people can choose where to start searching for the color, and where. with alot less code

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

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

    Default

    That would get the color of any color it found within the tolerance, not as accurate as could be, - this is how we autocolor where I live:

    SCAR Code:
    Function Mean(Values: TExtendedArray): Extended;
    Var
      I: Integer;
    Begin
      For I := 0 To High(Values) Do
        Result := Result + Values[i];
      Result := Result / GetArrayLength(Values);
    End;


    Function UpdateColorFromArray(Ref: Integer; Colors: TIntegerArray): Integer;
    Var
      Dif: Array of Array [0..2] Of Extended;
      HSL, HSL2: Array [0..2] Of Extended;
      SortedDif: TExtendedArray;
      C, I, L, D: Integer;
      R: Extended;
    Begin
      ColorToHSL(Ref, HSL[0], HSL[1], HSL[2]);
      SetArrayLength(Dif, GetArrayLength(Colors));
      L := High(Colors);
      For I := 0 To L Do
      Begin
        ColorToHSL(Colors[i], HSL2[0], HSL2[1], HSL2[2]);
        For C := 0 To 2 Do
          Dif[i][c] := Abs(HSL[c] - HSL2[c]);
      End;
      L := High(Dif);
      SetArrayLength(SortedDif, L + 1);
      For D := 0 To L Do
        SortedDif[d] := Mean([Dif[d][0], Dif[d][1], Dif[d][2]]);
      R := AMinE(SortedDif);
      For C := 0 To L Do
        If SortedDif[c] = R Then
        Begin
          Result := Colors[c];
          Exit;
        End;
    End;


    Function AutoColorMMFlax: Boolean;
    Var
      Colors: TIntegerArray;
      Purple: TPointArray;
      tmp: Integer;
    Begin
      FindColorsPie(Purple, mmFR, 75, 0.0, 359.0, 1.0, 75.0, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY);
      Colors := GetColors(Purple);
      ClearSameIntegers(Colors);
      tmp := UpdateColorFromArray(mmFR, Colors);
      If tmp <> 0 Then
        Result := True;
      If Result Then
        mmFR := tmp;
    End;


    Use FindColorsSpiralTolerance to get all the coloured points within the tolerance, then do a GetColors so you have the colors of the points, then a ClearSameIntegers so you only have one instance of every color, and then, sort out the closest color to the ref

  4. #4
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    That would get the color of any color it found within the tolerance, not as accurate as could be, - this is how we autocolor where I live:

    SCAR Code:
    Function Mean(Values: TExtendedArray): Extended;
    Var
      I: Integer;
    Begin
      For I := 0 To High(Values) Do
        Result := Result + Values[i];
      Result := Result / GetArrayLength(Values);
    End;


    Function UpdateColorFromArray(Ref: Integer; Colors: TIntegerArray): Integer;
    Var
      Dif: Array of Array [0..2] Of Extended;
      HSL, HSL2: Array [0..2] Of Extended;
      SortedDif: TExtendedArray;
      C, I, L, D: Integer;
      R: Extended;
    Begin
      ColorToHSL(Ref, HSL[0], HSL[1], HSL[2]);
      SetArrayLength(Dif, GetArrayLength(Colors));
      L := High(Colors);
      For I := 0 To L Do
      Begin
        ColorToHSL(Colors[i], HSL2[0], HSL2[1], HSL2[2]);
        For C := 0 To 2 Do
          Dif[i][c] := Abs(HSL[c] - HSL2[c]);
      End;
      L := High(Dif);
      SetArrayLength(SortedDif, L + 1);
      For D := 0 To L Do
        SortedDif[d] := Mean([Dif[d][0], Dif[d][1], Dif[d][2]]);
      R := AMinE(SortedDif);
      For C := 0 To L Do
        If SortedDif[c] = R Then
        Begin
          Result := Colors[c];
          Exit;
        End;
    End;


    Function AutoColorMMFlax: Boolean;
    Var
      Colors: TIntegerArray;
      Purple: TPointArray;
      tmp: Integer;
    Begin
      FindColorsPie(Purple, mmFR, 75, 0.0, 359.0, 1.0, 75.0, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY);
      Colors := GetColors(Purple);
      ClearSameIntegers(Colors);
      tmp := UpdateColorFromArray(mmFR, Colors);
      If tmp <> 0 Then
        Result := True;
      If Result Then
        mmFR := tmp;
    End;


    Use FindColorsSpiralTolerance to get all the coloured points within the tolerance, then do a GetColors so you have the colors of the points, then a ClearSameIntegers so you only have one instance of every color, and then, sort out the closest color to the ref
    nice. thanks, i have to learn with this.


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. A Little New Autocolor Function By Me...
    By Pure1993 in forum Research & Development Lounge
    Replies: 21
    Last Post: 05-12-2008, 08:19 PM
  2. new autocolor function quite fast
    By Waddo in forum Research & Development Lounge
    Replies: 4
    Last Post: 05-11-2008, 09:13 PM

Posting Permissions

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