Here is a small include I made that is used for taking two colors, and comparing how close they are to each other, then returns an atpa where the colors are found.
I've found it useful in some of my scripting. It's pretty basic, but it does the job well enough, at least for me

This is my first release of any code on here so all feedback is appreciated.

twoColors:
Simba Code:
(*
    By: HKbotz
    Version: 1

    Stuff involving two colors

    Feel free to do whatever the hell you want with it, just give credit where
    it's due please :)
*)

{$include_once srl-6/srl.simba}


(*
  type T2ColorsData

    Description: type to use for T2ColorsData functions

    Example:
    var
      colors: T2ColorsData;
*)

type
  T2ColorsData = record
                  col: array[0..1] of TColorData;
                  width, height, minCount: array[0..1] of integer;
                end;

(*
  procedure T2ColorsData.setColors(colors, tols: array[0..1] of integer; dim0, dim1: array[0..2] of integer; colSettings: array[0..1] of TColorSettings);

    Description: Sets colors

    Usage:                   (the Colors)  (the tolerance for each color)   (width/height used to make a atpa, min amount color appears in atpa[i])  (settings for each color)
      T2ColorsData.setColors([col1, col2], [col1Tolerance, col2Tolerance], [col1Width, col1Heigth, col1Count], [col2Width, col2Height, col2Count], [col1Settings, col2Settings])

    Example:
      colors.setColors([4137263, 1315351], [3, 1], [15, 15, 75], [2, 4, 6], [colorSetting(2, 0.42, 1.13), colorSetting(2, 3.34, 2.20)]);
*)

procedure T2ColorsData.setColors(colors, tols: array[0..1] of integer; dim0, dim1: array[0..2] of integer; colSettings: array[0..1] of TColorSettings);
var
  i: integer;
begin
    with self do
    begin
      for (i := 0) to (1) do
      begin
        col[i].color := colors[i];
        col[i].tolerance := tols[i];
        col[i].settings := colSettings[i];
      end;
      width[0] := dim0[0];
      height[0] := dim0[0];
      minCount[0] := dim0[0];
      width[1] := dim1[1];
      height[1] := dim1[1];
      minCount[1] := dim1[1];
    end;
end;

(*
  function T2ColorsData.findColors(var returnATPA: T2DPointArray; tol: integer; searchBox: TBox; sort: boolean = false; sortPoint: TPoint = mainscreen.playerPoint): boolean;

    Description: Finds two colors within given distance and returns true if found. Also returns atpa where colors where found.

    Usage:                                                                        (sorting info, not required)
      T2ColorsData.findColors(atpaToReturn, distanceBetweenColors, TBoxToLookIn, shouldWeSort, pointToSortFrom);

    Example:
      colors.findColors(atpa, 15, mainscreen.getBounds());
*)

function T2ColorsData.findColors(var returnATPA: T2DPointArray; dist: integer; searchBox: TBox; sort: boolean = false; sortPoint: TPoint = mainscreen.playerPoint): boolean;
var
  tpa: array[0..1] of TPointArray;
  atpa: array[0..1] of T2DPointArray;
  tmpTpa: TPointArray;
  c, i, j, m, n, o, p: integer;
  found: boolean;
begin
  result := false;

  //find the colors we want, or exit false if one of them isn't found.
  if (not findColorsTolerance(tpa[0], self.col[0].color, searchBox, self.col[0].tolerance, self.col[0].settings)) then
  begin
    print('Didn''t find first color.', TDebug.ERROR);
    exit(false);
  end else if (not findColorsTolerance(tpa[1], self.col[1].color, searchBox, self.col[1].tolerance, self.col[1].settings)) then
  begin
    print('Didn''t find second color.', TDebug.ERROR);
    exit(false);
  end;

  //make sure tpa isn't empty
  m := length(tpa[0]);
  n := length(tpa[1]);
  if (m < 1 or n < 1) then
    exit(false);

  //make atpas for each color, ignore ones that don't have enough colors in them
  for (i := 0) to (1) do
  begin
    atpa[i] := tpa[i].toATPA(self.width[i], self.height[i]);
    atpa[i].filterBetween(0, self.minCount[i]);
    //smartImage.debugATPA(atpa[i]);
  end;

  //set smallest atpa to o
  if (m < n) then
  begin
    o := 0;
    p := 1;
  end else
  begin
    o := 1;
    p := 0;
  end;

  c := 0;
  //check if the two colors are close enough to each other, and add them to returnATPA if they are
  for (i := 0) to (high(atpa[o])) do
    for (j := 0) to (high(atpa[p])) do
    begin
      if ((abs(atpa[o][i].getMiddle().x - atpa[p][j].getMiddle().x) <= dist) and
          (abs(atpa[o][i].getMiddle().y - atpa[p][j].getMiddle().y) <= dist)) then
      begin
        tmpTPA := atpa[o][i];
        tmpTPA.combine(atpa[p][j]);
        setLength(returnATPA, c + 1);
        returnATPA[c] := tmpTPA;
        inc(c);
        result := true;
        break;
      end;
    end;

  //sort atpa if set to
  if (sort) then
    returnATPA.sortFromMidPoint(sortPoint);
  //smartImage.clear();
  //smartImage.debugATPA(returnATPA);
end;

Downloads: