def rgb_to_hsv(r, g=None, b=None):
if type(r) in [list,tuple]:<EOL><INDENT>r, g, b = r<EOL><DEDENT>v = float(max(r, g, b))<EOL>d = v - min(r, g, b)<EOL>if d==<NUM_LIT:0>: return (<NUM_LIT:0.0>, <NUM_LIT:0.0>, v)<EOL>s = d / v<EOL>dr, dg, db = [(v - val) / d for val in (r, g, b)]<EOL>if r==v:<EOL><INDENT>h = db - dg             <EOL><DEDENT>elif g==v:<EOL><INDENT>h = <NUM_LIT> + dr - db       <EOL><DEDENT>else: <EOL><INDENT>h = <NUM_LIT> + dg - dr       <EOL><DEDENT>h = (h*<NUM_LIT>) % <NUM_LIT><EOL>return (h, s, v)<EOL>
Convert the color from RGB coordinates to HSV.

    Parameters:
      :r:
        The Red component value [0...1]
      :g:
        The Green component value [0...1]
      :b:
        The Blue component value [0...1]

    Returns:
      The color as an (h, s, v) tuple in the range:
      h[0...360],
      s[0...1],
      v[0...1]

    >>> rgb_to_hsv(1, 0.5, 0)
    (30.0, 1.0, 1.0)