Repository: vispy/vispy

Issue:
Add ability to pass "fpos" as a parameter to the ColorFilter
Hi all,
I am currently trying to use the ```ColorFilter``` (https://github.com/vispy/vispy/blob/main/vispy/visuals/filters/color.py) in a project along with several other filters, which I need to be placed in a specific order. However, right now, ```fpos``` cannot be passed as a parameter to ```ColorFilter```, which is always using 8:
```
    def __init__(self, filter=(1., 1., 1., 1.)):
        super(ColorFilter, self).__init__(fcode=self.FRAG_SHADER, fpos=8)

        self.filter = filter
```

Is it possible to change this so the user can specify any position for this filter?

Thanks so much,
Clare


Discussion:
> Is it possible to change this so the user can specify any position for this filter?

Absolutely! I think this is something people never really needed to do and now that we've had more structure added to filters this should be much easier to standardize as a keyword argument. It seems like almost all the filters (at least the ones in `color.py`, if not more) either use the default position of the base class or have the position hard coded.

Would you mind taking a shot at a pull request to fix one or more of these? You could make the keyword arguments and keep the defaults as they are now.

Resolving patch:
diff --git a/vispy/visuals/filters/color.py b/vispy/visuals/filters/color.py
--- a/vispy/visuals/filters/color.py
+++ b/vispy/visuals/filters/color.py
@@ -60,8 +60,8 @@ class IsolineFilter(Filter):
         }
     """
 
-    def __init__(self, level=2., width=2.0, antialias=1.0, color='black'):
-        super(IsolineFilter, self).__init__(fcode=self.FRAG_SHADER)
+    def __init__(self, level=2., width=2.0, antialias=1.0, color='black', **kwargs):
+        super(IsolineFilter, self).__init__(fcode=self.FRAG_SHADER, **kwargs)
 
         self.level = level
         self.width = width
@@ -114,8 +114,8 @@ class Alpha(Filter):
         }
     """
 
-    def __init__(self, alpha=1.0):
-        super(Alpha, self).__init__(fcode=self.FRAG_SHADER)
+    def __init__(self, alpha=1.0, **kwargs):
+        super(Alpha, self).__init__(fcode=self.FRAG_SHADER, **kwargs)
 
         self.alpha = alpha
 
@@ -136,8 +136,8 @@ class ColorFilter(Filter):
         }
     """
 
-    def __init__(self, filter=(1., 1., 1., 1.)):
-        super(ColorFilter, self).__init__(fcode=self.FRAG_SHADER, fpos=8)
+    def __init__(self, filter=(1., 1., 1., 1.), fpos=8, **kwargs):
+        super(ColorFilter, self).__init__(fcode=self.FRAG_SHADER, fpos=fpos, **kwargs)
 
         self.filter = filter
 
@@ -164,9 +164,9 @@ class ZColormapFilter(Filter):
         }
     """
 
-    def __init__(self, cmap, zrange=(0., 1.)):
-        super(ZColormapFilter, self).__init__(fcode=self.FRAG_SHADER, fpos=3,
-                                              vcode=self.VERT_SHADER, vpos=9)
+    def __init__(self, cmap, zrange=(0., 1.), fpos=3, vpos=9, **kwargs):
+        super(ZColormapFilter, self).__init__(fcode=self.FRAG_SHADER, fpos=fpos,
+                                              vcode=self.VERT_SHADER, vpos=vpos, **kwargs)
 
         if isinstance(cmap, str):
             cmap = colormap.get_colormap(cmap)


Test patch: