def rgb_to_hsl(red, green, blue)
      red = round_rgb_color(red)
      green = round_rgb_color(green)
      blue = round_rgb_color(blue)

      color_max = [red, green, blue].max
      color_min = [red, green, blue].min
      color_range = color_max - color_min
      if color_range == 0
        return [0, 0, (color_max * 100.0 / 255).to_i]
      end
      color_range = color_range.to_f
      hue = (case color_max
             when red then
               HUE_PER_6 * ((green - blue) / color_range)
             when green  then
               HUE_PER_6 * ((blue - red) / color_range) + HUE_PER_6 * 2
             else
               HUE_PER_6 * ((red - green) / color_range) + HUE_PER_6 * 4
             end)

      cnt = color_range / 2.0
      if cnt <= 127
        saturation = color_range / (color_max + color_min) * 100
      else
        saturation = color_range / (510 - color_max - color_min) * 100
      end
      lightness = (color_max + color_min) / 2.0 / 255.0 * 100

      [hue.round, saturation.round, lightness.round]
    end
def rgb_to_hsl(red, green, blue)
      red = round_rgb_color(red)
      green = round_rgb_color(green)
      blue = round_rgb_color(blue)

      color_max = [red, green, blue].max
      color_min = [red, green, blue].min
      color_range = color_max - color_min
      if color_range == 0
        return [0, 0, (color_max * 100.0 / 255).to_i]
      end
      color_range = color_range.to_f
      hue = (case color_max
             when red then
               HUE_PER_6 * ((green - blue) / color_range)
             when green  then
               HUE_PER_6 * ((blue - red) / color_range) + HUE_PER_6 * 2
             else
               HUE_PER_6 * ((red - green) / color_range) + HUE_PER_6 * 4
             end)

      cnt = color_range / 2.0
      if cnt <= 127
        saturation = color_range / (color_max + color_min) * 100
      else
        saturation = color_range / (510 - color_max - color_min) * 100
      end
      lightness = (color_max + color_min) / 2.0 / 255.0 * 100

      [hue.round, saturation.round, lightness.round]
    end
Convert RGB Color model to HSL Color model

 @param [Integer] red
 @param [Integer] green
 @param [Integer] blue
 @return [Array] hue, saturation, lightness
   hue in the range [0,200],
   saturation and lightness in the range [0, 100]