Results 1 to 11 of 11

Thread: UpdateIn - For your autocolor needs

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

    Default UpdateIn - For your autocolor needs

    While my internet once again wasn't working, I whipped up a simple autocolor procedure.

    It finds all the colors Color in the box formed by x1, y1, x2, y2 within the tolerance MaxTol.

    After it has got the TPA, it goes through the points, and sorts out the color that had the smallest tolerance to Color and updates it.

    Now it works without user input tolerance!

    Enjoy

    SCAR Code:
    Procedure UpdateIn(Var Color: Integer; x1, y1, x2, y2: Integer);
    Var
      OldColor, tmpHandle, bmp, L, I, TempTol, NewC, T, W, H, MaxTol, CTS: Integer;
      TPA: TPointArray;
    Begin
      //If Not LoggedIn Then Exit;
      CTS := GetColorToleranceSpeed;
      If Not CTS = 2 Then ColorToleranceSpeed(2);
      MaxTol := Round(Distance(x1, y1, x2, y2) * 1.5);
      SetColorSpeed2Modifiers(0.3, Distance(x1, y1, x2, y2) * 0.02);
      OldColor := Color;
      tmpHandle := GetClientWindowHandle;
      bmp := BitmapFromString2(False, '');
      CopyClientToBitmap(bmp, x1, y1, x2, y2);
      SetTargetBitmap(bmp);
      GetBitmapSize(bmp, W, H);
      FindColorsTolerance(TPA, OldColor, 0, 0, W, H, MaxTol);
      Try
        TempTol := iAbs(Color - GetColor(TPA[High(TPA)].x, TPA[High(TPA)].y));
      Except
        Writeln('No instances of the color Color found.');
        SetClientWindowHandle(tmpHandle);
        ColorToleranceSpeed(CTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      End;
      L := High(TPA);
      For I := 0 To L Do
      Begin
        T := iAbs(Color - GetColor(TPA[i].x, TPA[i].y));
        If T < TempTol Then
        Begin
          TempTol := T;
          NewC := I;
        End;
      End;
      If NewC <> 0 Then
      Begin
        Color := GetColor(TPA[NewC].x, TPA[NewC].y);
        If FindColor(W, H, Color, x1, y1, x2, y2) Then
        MoveMouse(W, H);
        Writeln('---<UpdateIn>---');
        Writeln('Old: '+IntToStr(OldColor));
        Writeln('New: '+IntToStr(Color));
        Writeln('----------------');
      End Else
      Begin
        Writeln('Color could not be updated.');
      End;
      ColorToleranceSpeed(CTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      SetClientWindowHandle(tmpHandle);
    End;

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

    Default

    N3ss3s are u addicted?

    Anyways GJ!

    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

    N3ss3s are u addicted?
    Was that a question?

    Just wait till I get the 128*128 so I can steal the Hopelessly Addicted from Rik

    (Hopelessly Addicted is one of those big avys - the guy with a laptop in bath )

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

    Default

    Nice.


    And: OMG! It contains TPA's... What a surprise...
    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
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Yeah, now Im making a DoorOpen: Boolean with TPA:s included

  6. #6
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    nice and simple, i like it, should solve most outocoling issues.

    however... why bother having a max tolerance? you could make ure tpa have all the points in the box... and then sort.

    oh, but that could take a while...

    hmm, so why not have a set default max tolerance? (trying to get rid of a variable here to make it simpler)

    hmm, well, in a small box, you basically could take in all the points witout much of a issue.. but a larger box would cause problems, and you would need to limit the tolerance.

    so why not remove the tolerance variable and dynamically create it based upon the box size?

    you could easily whip up a calulcation for the area of the box, and then use that to determine a nice tolerance.

    tolerance = 250 - (area * scalarConstant);

    (assuming that max tolerance is 255, i forgot) but this would generate a linera function to inversly corelate your area and tolerance.

    depending on how it all plays out in real time, you may want to make it quadratic, somethign like tolerance = 250 - (area * area * scalarConstant);
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

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

    Default

    O.o

    *silence*

    Doesn't sound bad at all, I'll try to do that after I get DoorOpen: Boolean done...

    EDIT: Okay, DoorOpen works now in MS Paint, ---> Rs

  8. #8
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    O.o

    *silence*

    Doesn't sound bad at all, I'll try to do that after I get DoorOpen: Boolean done...

    EDIT: Okay, DoorOpen works now in MS Paint, ---> Rs
    good good

    and yeah, its really a decent bit of work and a bit of testing really just to make one varable "smart", but i figured that this thing is really a "simplifing" method. Obviously, if you have special cases that wont work with this, you woudl make you own customized method, this one will probably be used by peopel who may not really want to even understand it, and therefore, removing one of the varables not only makes it simpler to use (and type, lol) but also prevents them from screwing it up.

    anyhows, i dont know how much free time you have, lol, but it could be cool
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  9. #9
    Join Date
    Mar 2007
    Posts
    3,681
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    woah your making tonnes of stuff these days n3ss3s thanks =D

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

    Default

    No prob hugo.

    Greg, I got time more than enough

    Released DoorOpen, its in the SRL New Functions.

    Now, I'll start working on that tol shit

    EDIT: I think I'll use HSL and find how much does Luminance change every 5 pixels...

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

    Default

    *BUMP*

    WOAH, Already ready!

    Now it works without user input tolerance!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Doesn't AutoColor
    By BKNYKavkaz in forum OSR Help
    Replies: 5
    Last Post: 04-26-2008, 10:31 AM
  2. Help AUTOCOLOR???
    By papenco in forum OSR Help
    Replies: 0
    Last Post: 12-06-2007, 06:27 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
  •