public static class RGBto {
 public static void HSL(int R, int G, int B, out int H, out int S, out int L){
  int Max = Mathf.Max (R, G, B);
  int Min = Mathf.Min (R, G, B);
 if (Max == Min) {
  H = 360;
 } else if (G == Max) {
  H = 60 * (B - R) / (Max - Min) + 120;
 } else if (B == Max) {
  H = 60 * (R - G) / (Max - Min) + 240;
 } else {
  H = 60 * (G - B) / (Max - Min);
  if (H < 0) H = H + 360;
 }
 if (Max == 0 || Min == 255){
  S = 0;
 } else {
  S = 255 * (Max - Min) / (255 - Mathf.Abs(Max + Min - 255));
 }
  L = (Max + Min)/2;
 }