Link paint and paintLayers in HasPaint mixin
What could be improved
In the HasPaint mixin, paint and paintLayers are mutually exclusive. When paintLayers contains paints, paint is ignored when rendering. Similarly, paints in paintLayer have no effect on the component's primary paint.
paint should be considered the first layer in paintLayers. Similarly get and set of paint should point to the first element of paintLayers.
Why should this be improved
It could be confusing to have the component's paint value be ignored after setting layers. paintLayers should not be empty if get, it should contain the current paint as this is a layer being painted. Adding a new paint layer should add onto the current paint, not override it.
Any risks?
No change to the API. No additional memory.
More information
I can submit a PR if the above is agreed. Only minor code changes required.
Adding a new paint layer should add onto the current paint, not override it.
So that the latest added layer is always the paint, that sounds a bit confusing too?
Adding a new paint layer should add onto the current paint, not override it.
So that the latest added layer is always the
paint, that sounds a bit confusing too?
No, the first layer (paintLayers[0]) is always paint. Adding more layers draws more layers on top, as it currently does.
I meant the first call of paintLayers.add(newPaint) doesn't replace the previous paint, it keeps consistency by becoming paintLayers = [paint, newPaint] rather than paintLayers = [newPaint].
Just saying paint should be treated as a valid layer, not ignored when paintLayers is used.
Sounds good, have a look at the old PR implementing this though, I think there was some discussion regarding this on there.
Sounds good, have a look at the old PR implementing this though, I think there was some discussion regarding this on there.
Yup, I think you mean this one: https://github.com/flame-engine/flame/pull/2073#discussion_r1001195575
It ended with @erickzanardo agreeing the paintLayer should include paint. Previously you'd suggested everything should be kept separate (paint, paintLayers, paint map) however. The paint map is still separate, but have your views on including paint as the first paintLayer changed?
Another argument for having paint in paintLayer is outside/legacy functions that only recognise a component's paint will still work as (mostly) expected when using paintLayers, whereas if paintLayers is independent then paint becomes meaningless.
I think any implementation can get confusing, and this isn't the perfect solution either. I just think it adds more end-user functionality that running two separate ideas of paint.