code: function inxsearch(b, g, r) {
      var a, p, dist;
  
      var bestd = 1000; // biggest possible dist is 256*3
      var best = -1;
  
      var i = netindex[g]; // index on g
      var j = i - 1; // start at netindex[g] and work outwards
  
      while ((i < netsize) || (j >= 0)) {
        if (i < netsize) {
          p = network[i];
          dist = p[1] - g; // inx key
          if (dist >= bestd) i = netsize; // stop iter
          else {
            i++;
            if (dist < 0) dist = -dist;
            a = p[0] - b; if (a < 0) a = -a;
            dist += a;
            if (dist < bestd) {
              a = p[2] - r; if (a < 0) a = -a;
              dist += a;
              if (dist < bestd) {
                bestd = dist;
                best = p[3];
              }
            }
          }
        }
        if (j >= 0) {
          p = network[j];
          dist = g - p[1]; // inx key - reverse dif
          if (dist >= bestd) j = -1; // stop iter
          else {
            j--;
            if (dist < 0) dist = -dist;
            a = p[0] - b; if (a < 0) a = -a;
            dist += a;
            if (dist < bestd) {
              a = p[2] - r; if (a < 0) a = -a;
              dist += a;
              if (dist < bestd) {
                bestd = dist;
                best = p[3];
              }
            }
          }
        }
      }
  
      return best;
    }
docs: /*
  Private Method: inxsearch
  
  searches for BGR values 0..255 and returns a color index