Results 1 to 5 of 5

Thread: PixelShift

  1. #1
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default PixelShift

    How do you use it? I picked up M34tcode's new Pixelshift, cause it's more accurate, but I don't know how to use it.

    Here's what I got:
    Simba Code:
    function GetColArr (Box : TBox) : T2DIntegerArray;
    var
      x,y : Integer;
    begin
      SetArrayLength(Result,box.X2-box.X1);
      for x := 0 to box.X2-box.X1-1 do
      begin
        SetArrayLength(Result[x],box.Y2-box.Y1);
        for y := 0 to box.Y2-box.Y1-1 do
        begin
          Result[x][y] := GetColor(x+box.X1,y+box.Y1);
        end;
      end;
    end;

    function ValidatePixels(Box : TBox; OrigCols : T2DIntegerArray; BoolArr : array of TBoolArray; Tolerance : Integer):Boolean;
    var
      X,Y : Integer;
      NewCols : T2DIntegerArray;
    begin
      NewCols := GetColArr(Box);
      for X := 0 to Box.X2 - Box.X1-1 do
       for Y := 0 to Box.Y2 - Box.Y1-1 do
       begin
         if not BoolArr[x][y] then
           continue;
         boolArr[x][y] := SimilarColors(origCols[x][y],NewCols[x][y],Tolerance);
         Result := True
       end;
    end;

    function InitBoolArr(Width,Height : Integer) : array of TBoolArray;
    var x,y : Integer;
    begin
      SetArrayLength(Result,Width);
      for x := 0 to Width-1 do
      begin
        SetArrayLength(Result[x],Height);
        for Y := 0 to Height-1 do
        begin
          Result[x][y] := True;
        end;
      end;
    end;

    function countBools(BoolArr : Array of TBoolArray; CountTrues : Boolean) : Integer;
    var
      X,Y,W,H,C : Integer;
    begin
      W := GetArrayLength(BoolArr);
      H := GetArrayLength(BoolArr[0]);
      For X := 0 to W-1 do
        for Y := 0 to H-2 do
          if BoolArr[X][Y] = CountTrues then
            Inc(C);
      Result := C;
    end;

    function CalcNonStaticPixelCount(Box : TBox; ShiftInterval, Repetitions, Tolerance : Integer) : Integer;
    var
      I,X,Y : Integer;
      T,TT : LongInt;
      OrigColArr : T2DIntegerArray;
      BoolArr : array of TBoolArray;
    begin
      OrigColArr := GetColArr(Box);
      BoolArr := initBoolArr(Box.X2-Box.X1,Box.Y2-Box.Y1);
      MarkTime(T);
      MarkTime(TT);
      for I := 0 to Repetitions-1 do
      begin
        if (TimeFromMark(T) > (Repetitions*ShiftInterval)) then
        begin
          srl_Warn('CalcNonStaticPixelCount','Completed only ' + IntToStr(I) + ' of '
            + IntToStr(Repetitions) + '. Try increasing the interval',1);
          break;
        end;
        if (I > 0) then
          writeln('CalcNonStaticPixelCount: Iteration ' + IntToStr(I) + ' took '
            + FloatToStr(TimeFromMark(TT)/1000.0) + ' seconds to complete.');
        MarkTime(TT);
        wait(Max(0,ShiftInterval-TimeFromMark(TT)));
        validatePixels(Box,OrigColArr,BoolArr,Tolerance);
        SMART_ClearCanvas;
        for x := 0 to box.x2-box.x1-1 do
          for y := 0 to box.y2-box.y1-1 do
            if boolArr[x][y] then
              SMART_DrawDot(false,Point(x+box.x1,box.y1+y),clRed);
      end;
      Result := countBools(BoolArr,False);
    end;
    Last edited by NKN; 04-26-2012 at 01:12 AM.

  2. #2
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    From what is looks like you do

    Simba Code:
    //so basically like this:
    CalcNonStaticPixelCount(PlayerBox, 4000, 80, 250)

    So it runs for a maximum of 4 seconds and checks 80 times in that 4 seconds. And if I'm correct the tolerance is the tolerance for pixels.

    I think so anyway.

  3. #3
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    I picked up a little understanding browsing through the mime antirandoms include.
    Can't say enough to explain it, but I get the idea of how to use it. Or so I think.

  4. #4
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    All PixelShift does is count the number of pixels that change over a given time. SRL's one only checks it twice, once at the beginning and once at the end, comparing the two. While m34tc0de's one checks it several times during the time you specify.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  5. #5
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    All PixelShift does is count the number of pixels that change over a given time. SRL's one only checks it twice, once at the beginning and once at the end, comparing the two. While m34tc0de's one checks it several times during the time you specify.
    He wants to know how to use it. Good explanation though

    Anyway, after reading over it I think you just use it like a normal PixelShift function, filling it out the way I stated above.

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
  •