Results 1 to 3 of 3

Thread: Listing colours

  1. #1
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default Listing colours

    I knocked up a script in about half an hour that is meant to display all the different colours in the area of the client that I hard code. Initially I left it to feed all the colours into the debug box, but that was a) quite inefficient and b) extremely useless as looking through all those colours would have taken forever. To counter this, I made it search through the array I created to make sure there was no repetitions in colours, but it only displays the very top left colour of the area selected. I'm guessing the problem lies in the TIA search. Code:
    SCAR Code:
    program ListColours;

    type
      TPixel = record
        Point: TPoint;
        Colour: Integer;
    end;

    Var
    Pixels: Array of TPixel;
    Colours: TIntegerArray;
    x, y, i, ii: integer;

    begin
      SetArrayLength(Pixels, 26*32 + 1)
      for x := 5 to 26 do                    //these are the parameters
        for y := 5 to 32 do                  //of the area that I'm searching
        begin
          With Pixels[x*y] do
          begin
            Point.x := x                     //ignore these for now
            Point.y := y                     //they'll have future use
            Colour := GetColor(x, y);
          end;
        end;
      SetArrayLength(Colours, 1);
      for i := 25 to High(Pixels) do
        for ii := 0 to High(Colours) do
          if Pixels[i].Colour <> Colours[ii] then
          begin
            SetArrayLength(Colours, High(colours) + 1);
            Colours[ii] := Pixels[i].Colour;
          end;
      for i := 0 to High(Colours) do
        WriteLN(IntToStr(Colours[i]));
    end.

  2. #2
    Join Date
    Sep 2008
    Location
    Chicago
    Posts
    224
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Change the last part to this:
    Simba Code:
    SetArrayLength(Colours, 1);
      for i := 25 to High(Pixels) do
        for ii := 0 to High(Colours) do
        begin
          if Pixels[i].Colour = Colours[ii] then
            break;

          if ii = High(Colours) then
          begin
            SetArrayLength(Colours, High(colours) + 1);
            Colours[ii] := Pixels[i].Colour;
          end;
        end;


    Also, theres some functions in wizzyPlugin that might help you
    Simba Code:
    function InIntArray(a: TIntegerArray; Number: Integer): Boolean;
    procedure ClearSameIntegers(var a: TIntegerArray);

  3. #3
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Quote Originally Posted by Heysus View Post
    Change the last part to this:
    Simba Code:
    SetArrayLength(Colours, 1);
      for i := 25 to High(Pixels) do
        for ii := 0 to High(Colours) do
        begin
          if Pixels[i].Colour = Colours[ii] then
            break;

          if ii = High(Colours) then
          begin
            SetArrayLength(Colours, High(colours) + 1);
            Colours[ii] := Pixels[i].Colour;
          end;
        end;


    Also, theres some functions in wizzyPlugin that might help you
    Simba Code:
    function InIntArray(a: TIntegerArray; Number: Integer): Boolean;
    procedure ClearSameIntegers(var a: TIntegerArray);
    Thank you.

    Sorry I didn't reply previously, I hadn't seen your post, and only just checked to see whether this had been seen to.

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
  •