Results 1 to 5 of 5

Thread: Finding Color Inside A TBox

  1. #1
    Join Date
    May 2018
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Question Finding Color Inside A TBox

    How do i find color inside a Tbox?

    Code:
    procedure findButton();
    var
      blueButton: TBox;
    begin
      blueButton:= intToBox(48, 247, 216, 260);
    
      blueButton.mainscreen([color, tolerance]); // <- How do i perform this part of the code?
    
      //rest of code
    end;
    I'm looking to do something like:

    Code:
    If (blueButton = color) then
    I think i'm on the right track.
    Last edited by matthew98; 08-13-2018 at 02:35 PM.

  2. #2
    Join Date
    Feb 2013
    Location
    The Boonies
    Posts
    203
    Mentioned
    9 Post(s)
    Quoted
    70 Post(s)

    Default

    Many of the color finding functions use a TBox as a parameter, for example in SRL-6: http://docs.villavu.com/srl-6/color....rance-overload

    So, to find a color within your defined TBox, it could be something like:

    Code:
    if (findColorsTolerance(TPA, color, blueButton, tol, colorSetting(2, Hue, Sat))) then 
        // do something
    It stores all points of said color within TPA that are within your TBox area, but it also returns as a boolean, so you can simply check to see if the color is there if you wish.
    Last edited by Lama; 08-13-2018 at 04:58 PM. Reason: simplified a lil

  3. #3
    Join Date
    May 2018
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Lama View Post
    Many of the color finding functions use a TBox as a parameter, for example in SRL-6: http://docs.villavu.com/srl-6/color....rance-overload

    So, to find a color within your defined TBox, it could be something like:

    Code:
    if (findColorsTolerance(TPA, color, blueButton, tol, colorSetting(2, Hue, Sat))) then 
        // do something
    It stores all points of said color within TPA that are within your TBox area, but it also returns as a boolean, so you can simply check to see if the color is there if you wish.
    Thank you so much! That is great. Really helpful.

  4. #4
    Join Date
    May 2018
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    For anybody wondering how to do this. The finished working code is below:

    Code:
    program new;
    {$I SRL-6/SRL.simba}
    
    var
    BlueBox := intToBox(48, 247, 216, 260);
    TPA: TPointArray;
    
    procedure findbox();
    begin
    
      if (FindColorsTolerance(TPA, 11165734, Bluebox, 1)) then
        writeln('Found color')
      else
        writeln('Didnt find color');
    
    end
    
    begin
      findbox();
    end.
    You can also do it by checking the length of the TPA:

    Code:
    program new;
    {$I SRL-6/SRL.simba}
    
    var
    BlueBox := intToBox(48, 247, 216, 260);
    TPA: TPointArray;
    
    procedure findbox();
    begin
    
      FindColorsTolerance(TPA, 11165734, Bluebox, 1);
    
      if length(TPA) < 1 then
        writeln('no')
      else
        writeln('yes');
    
    end
    
    begin
      findbox();
    end.
    I hope this helps somebody.

  5. #5
    Join Date
    Feb 2013
    Location
    The Boonies
    Posts
    203
    Mentioned
    9 Post(s)
    Quoted
    70 Post(s)

    Default

    You can also do it by checking the length of the TPA
    Alternatively, you can use countColorTolerance in this type fashion:

    Code:
    if (countColorTolerance(11165734, Bluebox, 1) > 1) then
      // color found
    - comb that include!

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
  •