prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Implement reusable GLSL functions for color space transformations
  At least RGB <-> HSV. Put them in `vispy.visuals.glsl`.
  
  
  </issue>
  <code>
  [start of vispy/visuals/glsl/color.py]
  1 """Color-related GLSL functions."""
  2 
  3 
  4 # -----------------------------------------------------------------------------
  5 # Colormaps
  6 # -----------------------------------------------------------------------------
  7 
  8 """Texture lookup for a discrete color map stored in a 1*ncolors 2D texture.
  9 
  10 The `get_color()` function returns a RGB color from an index integer
  11 referring to the colormap.
  12 
  13 
  14 Inputs
  15 ------
  16 
  17 index (int): The color index.
  18 
  19 
  20 Template variables
  21 ------------------
  22 
  23 $ncolors (int): The number of colors in the colormap.
  24 
  25 $colormap (2D texture sampler): The sampler for the 2D 1*ncolors colormap
  26     texture.
  27 
  28 
  29 Outputs
  30 -------
  31 
  32 color (vec3): The color.
  33 
  34 """
  35 COLORMAP_TEXTURE = """
  36 vec3 get_color(int index) {
  37     float x = (float(index) + .5) / float($ncolors);
  38     return texture2D($colormap, vec2(x, .5)).rgb;
  39 }
  40 """
  41
  [end of vispy/visuals/glsl/color.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/vispy/visuals/glsl/color.py b/vispy/visuals/glsl/color.py
  --- a/vispy/visuals/glsl/color.py
  +++ b/vispy/visuals/glsl/color.py
  @@ -38,3 +38,33 @@
       return texture2D($colormap, vec2(x, .5)).rgb;
   }
   """
  +
  +
  +# -----------------------------------------------------------------------------
  +# Color space transformations
  +# -----------------------------------------------------------------------------
  +
  +# From http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
  +# TODO: unit tests
  +HSV_TO_RGB = """
  +vec3 hsv_to_rgb(vec3 c)
  +{
  +    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  +    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
  +    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
  +}
  +"""
  +
  +
  +RGB_TO_HSV = """
  +vec3 rgb_to_hsv(vec3 c)
  +{
  +    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
  +    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
  +    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
  +
  +    float d = q.x - min(q.w, q.y);
  +    float e = 1.0e-10;
  +    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
  +}
  +"""
  
verification_info: {"golden_diff": "diff --git a/vispy/visuals/glsl/color.py b/vispy/visuals/glsl/color.py\n--- a/vispy/visuals/glsl/color.py\n+++ b/vispy/visuals/glsl/color.py\n@@ -38,3 +38,33 @@\n     return texture2D($colormap, vec2(x, .5)).rgb;\n }\n \"\"\"\n+\n+\n+# -----------------------------------------------------------------------------\n+# Color space transformations\n+# -----------------------------------------------------------------------------\n+\n+# From http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl\n+# TODO: unit tests\n+HSV_TO_RGB = \"\"\"\n+vec3 hsv_to_rgb(vec3 c)\n+{\n+    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n+    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n+    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n+}\n+\"\"\"\n+\n+\n+RGB_TO_HSV = \"\"\"\n+vec3 rgb_to_hsv(vec3 c)\n+{\n+    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n+    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n+    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n+\n+    float d = q.x - min(q.w, q.y);\n+    float e = 1.0e-10;\n+    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n+}\n+\"\"\"\n", "issue": "Implement reusable GLSL functions for color space transformations\nAt least RGB <-> HSV. Put them in `vispy.visuals.glsl`.\n\n", "before_files": [{"content": "\"\"\"Color-related GLSL functions.\"\"\"\n\n\n# -----------------------------------------------------------------------------\n# Colormaps\n# -----------------------------------------------------------------------------\n\n\"\"\"Texture lookup for a discrete color map stored in a 1*ncolors 2D texture.\n\nThe `get_color()` function returns a RGB color from an index integer\nreferring to the colormap.\n\n\nInputs\n------\n\nindex (int): The color index.\n\n\nTemplate variables\n------------------\n\n$ncolors (int): The number of colors in the colormap.\n\n$colormap (2D texture sampler): The sampler for the 2D 1*ncolors colormap\n    texture.\n\n\nOutputs\n-------\n\ncolor (vec3): The color.\n\n\"\"\"\nCOLORMAP_TEXTURE = \"\"\"\nvec3 get_color(int index) {\n    float x = (float(index) + .5) / float($ncolors);\n    return texture2D($colormap, vec2(x, .5)).rgb;\n}\n\"\"\"\n", "path": "vispy/visuals/glsl/color.py"}]}