if (max == min)
    h = 0;
  else if (r == max)
    h = (g - b) / delta;
  else if (g == max)