# Thread: Finding Color Inside A TBox

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

## 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. 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. Registered User
Join Date
May 2018
Posts
17
Mentioned
0 Post(s)
Quoted
3 Post(s)
Originally Posted by Lama
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. Registered User
Join Date
May 2018
Posts
17
Mentioned
0 Post(s)
Quoted
3 Post(s)
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. 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!