flame icon indicating copy to clipboard operation
flame copied to clipboard

Link paint and paintLayers in HasPaint mixin

Open mattmyne opened this issue 3 years ago • 4 comments

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.

mattmyne avatar Jan 15 '23 19:01 mattmyne

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?

spydon avatar Jan 15 '23 20:01 spydon

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.

mattmyne avatar Jan 15 '23 21:01 mattmyne

Sounds good, have a look at the old PR implementing this though, I think there was some discussion regarding this on there.

spydon avatar Jan 15 '23 23:01 spydon

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.

mattmyne avatar Jan 15 '23 23:01 mattmyne