-
Notifications
You must be signed in to change notification settings - Fork 59
Description
An idea for simplifying and solidifying the graphic features API. All graphic features should be flat and have no user-changeable or user accessible attributes, except for .value for features that subclass BufferManager.
Reasoning: currently VertexCmap allows being set like this:
line.cmap = "viridis"`
line.cmap.transform = array_1d
line.cmap.alpha = 0.5I think this is confusing since it is inconsistent compared to all other graphic features, and it can also make events confusing. For example, what if you want an event for the transform or alpha but no the cmap?
Specific to cmaps for PositionsGraphics we can have an independent cmap_transform feature that only manages the cmap transform and doesn't touch the cmap or alpha. If an alpha is set on the graphic then it will read the alpha value set on the graphic to set that dimension in the final RGBA array to set the colors buffer. Similarly, if a user decides to set VertexColors it will read the alpha feature of that graphic. Perhaps we can allow alpha to be set to None or a float between [0.0, 1.0], can decide this detail later.
Anyways, basic idea is that from our experience I think we can make a formal structure that all GraphicFeatures should follow. Pretty much all of them already follow this except for VertexCmap:
GraphicFeaturesshould not have any user-end attributes or methods. Except forBufferManagerswhich have.value.- They must only have one type of event which corresponds to their single settable attribute value (ex. cmap, cmap_transform, alpha, hickness, etc.) and nothing else.
- A
GraphicFeatureis allowed to access the other features of a graphic when necessary, for exampleVertexCmapalready does this since it's basically a wrapper forVertexColors. But we can go further with this by for example addingVertexAlphato set the color alpha of a graphic. I think this makes it really easy to set things on the user-end in an independent way, and to also get precise events.
Implemeting this is trivial, I just have to split up VertexCmap. And we can have this is dev docs somewhere that this is the structure of graphic features.