Results 1 to 5 of 5

Thread: Counting the colored pixels in a box, tpas + atpas

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default Counting the colored pixels in a box, tpas + atpas

    i'm trying to determine what maze i'm in, in the MTA Maze thingy..

    I'v tried DTM's, and currently trying out making a TBox of the maze, and counting the pixels inside, but i'm having trouble with that, its not accurate enough , well, thats when it worked -.- i somehow deleted the function without saving it, so i made this here up out of memory, and i forgot exactly what it was

    SCAR Code:
    function loadlengths(color, mlength: integer): integer;
    var tpa, tpa2 : tpointarray; atpa, atpa2: t2dpointarray; i: integer; b: tbox;
    begin
      colortolerancespeed(3);
      if not FindColorsTolerance(tpa, color, mmx1, mmy1, mmx2, mmy2, 7) then
        exit;
      atpa:= splittpa(tpa, 50);
      for i:= 0 to high(atpa) do
      begin
        b:= gettpabounds(atpa[i]);
        if not distance(b.x1, b.y1, b.x2, b.y2) <= 55 then exit;
        begin
          FindColorsTolerance(tpa2, color, b.x1, b.y1, b.x2, b.y2, 7);
          debugtpa(tpa2, '');
        end;
        if length(tpa2) <= mlength then result:= length(tpa2);
      end;
    end;

    honestly, i cant really word my problem correctly, or how i think it should sound, other than it always returns 0, so, if you have any ideas, post pl0x since im a nub

    i also cant upload a pic of all the mazes, because it's to big
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If I understand it right, you're trying to count the amount of pixels with a certain color in a certain area.

    If I'm right, try using CountColors.

    ~Sandstorm

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    hmm, i forgot about countcolors testing now

    edit: still returns 0,
    SCAR Code:
    function loadlengths(color, mlength: integer): integer;
    var tpa, tpa2 : tpointarray; atpa, atpa2: t2dpointarray; i, c: integer; b: tbox;
    begin
      colortolerancespeed(3);
      if not FindColorsTolerance(tpa, color, mmx1, mmy1, mmx2, mmy2, 7) then
        exit;
      atpa:= splittpa(tpa, 50);
      for i:= 0 to high(atpa) do
      begin
        b:= gettpabounds(atpa[i]);
        if distance(b.x1, b.y1, b.x2, b.y2) <= 50 then
        begin
          c:= CountColor(color, b.x1, b.y1, b.x2, b.y2);
          if c <= mlength then
          begin
            result:= c;
            exit;
          end;
        end;
      end;
    end;

    i must phail at scripting
    Last edited by Awkwardsaw; 08-23-2009 at 10:29 AM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    or
    Amount := Length(TPA);

    can you link to the site please. I cantt quite visulize what you're saying :<
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  5. #5
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by noidea View Post
    or
    Amount := Length(TPA);

    can you link to the site please. I cantt quite visulize what you're saying :<
    the MTA Maze minigame, in RS
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

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
  •