prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Implement reusable GLSL functions for color space transformations
  At least RGB <-> HSV. Put them in `vispy.visuals.glsl`.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `vispy/visuals/glsl/color.py`
  Content:
  ```
  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 FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
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"}], "after_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\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\nHSV_TO_RGB = \"\"\"\nvec3 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\nRGB_TO_HSV = \"\"\"\nvec3 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", "path": "vispy/visuals/glsl/color.py"}]}