bevy_vector_shapes icon indicating copy to clipboard operation
bevy_vector_shapes copied to clipboard

Allow accessing `color` in system without specifying shape type

Open hungnd1475 opened this issue 1 year ago • 3 comments

Is there any chance we can move the color property into a common component shared between Disc, Rectangle, etc... to allow a system to access it without specifying the exact component type? I think ShapeMaterial might be a good candidate here as it is similar to StandardMaterial that the users are familiar with.

The reason why I ask for this is because I'm trying to animate the color property using bevy_tweening. With this, I can define a single lens to animate the color property of any shapes. I currently have to define one lens for each shape type. Also, it's not possible to update the color property from a system without adding the exact shape type to the query. Sometimes, I want to just query my own marker component and update the associated color property without worrying what type of shape my component is.

hungnd1475 avatar Nov 09 '23 08:11 hungnd1475

This is very reasonable and I was already considering doing something similar. If you feel comfortable opening a PR feel free to do so and I'll review it, otherwise I'll get around to it some time in the next cycle.

james-j-obrien avatar Nov 09 '23 08:11 james-j-obrien

I'm also facing the same problem. Additionally, I think thickness would also benefit from decoupling.

musjj avatar Feb 04 '24 17:02 musjj

I've abstracted out both color and thickness into ShapeFill which could potentially support more types of fills in future, for now it has Fill and Stroke representing the two currently supported rendering options, let me know if you find this suitable.

I could also split it into ShapeColor and ShapeStroke but that would mean making ShapeStroke optional and I'd run into more problems with bundles not supporting optional components which is already a footgun with RenderLayers.

james-j-obrien avatar Feb 17 '24 21:02 james-j-obrien