-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
This ticket outlines a plan for integrating bevy_color into the rest of Bevy. The plan consists of several phases.
Phase 1
In Phase 1, the public-facing Bevy APIs will not be changed, but the bevy_color crate will be integrated in ways that do not impact end users. During this phase, the following tasks will be performed:
- Refine and enhance the bevy_color crate with additional features, such as fluent builder methods.
- Do a mass renaming of the existing
Color
type toLegacyColor
, and then provide a type aliasColor = LegacyColor
. The purpose of this change is to allow measurement of the migration progress by searching for the symbolLegacyColor
. Because of the type alias, no end-user code will be broken. This step should be performed by an SME so that it can be done atomically, minimizing merge conflicts with any in-flight PRs that might be impacted. - Replace internal uses of
LegacyColor
that are not exposed to end users, especially constant color values (I counted 601 color constants in the current code base). - Color conversion functions in bevy_render will be moved to bevy_color. What we want to end up with is a one-way dependency such that render depends on color, and not the other way around.
- We may also want to move the
From
implementations forLegacyColor
into the same module asLegacyColor
.
Phase 2
In Phase 2, we will modify Bevy APIs, but only the ones that can be modified in a backwards-compatible way. For example, the Gizmo APIs which accept a LegacyColor
argument can be changed to accept impl Into<LinearRgba>
, allowing either the old or new color types to be passed in without needing to call .into()
.
Also during this phase, we'll add new APIs for bundle types such as Fog
or BackgroundColor
which currently accept a LegacyColor
as a property - the new APIs will have constructors that take an impl Into<LinearRgba>
. This means that users who want to use the new color types can do so in a forward-compatible way.
Phase 3
In Phase 3, the remaining APIs - the ones that cannot be made backwards compatible - will be migrated. This includes things like bundle properties. In most cases, low-level color attributes will use the LinearRgba
type.
Users will need to update their code, at minimum adding a call to .into()
when passing a legacy color into an API that accepts the new color types.
Timing
I'm assuming that these three phases will be spread out over several Bevy release cycles. The reason for this is that we'll want to give users plenty of warning that this breaking change is coming. However, this decision - whether to try and fit all of the migration into a single Bevy release cycle or not - is above my pay grade.