Skip to content

Commit fa8ad85

Browse files
author
Alice Cecile
committed
Merge remote-tracking branch 'origin/main' into color-externals
2 parents 138e26c + 9ae5ba2 commit fa8ad85

File tree

6 files changed

+194
-12
lines changed

6 files changed

+194
-12
lines changed

crates/bevy_color/src/color.rs

Lines changed: 181 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,191 @@ impl Color {
4040
pub fn linear(&self) -> LinearRgba {
4141
(*self).into()
4242
}
43+
44+
/// Creates a new [`Color`] object storing a [`Srgba`] color.
45+
pub const fn srgba(red: f32, green: f32, blue: f32, alpha: f32) -> Self {
46+
Self::Srgba(Srgba {
47+
red,
48+
green,
49+
blue,
50+
alpha,
51+
})
52+
}
53+
54+
/// Creates a new [`Color`] object storing a [`Srgba`] color with an alpha of 1.0.
55+
pub const fn srgb(red: f32, green: f32, blue: f32) -> Self {
56+
Self::Srgba(Srgba {
57+
red,
58+
green,
59+
blue,
60+
alpha: 1.0,
61+
})
62+
}
63+
64+
/// Createsa new [`Color`] object storing a [`LinearRgba`] color.
65+
pub const fn linear_rgba(red: f32, green: f32, blue: f32, alpha: f32) -> Self {
66+
Self::LinearRgba(LinearRgba {
67+
red,
68+
green,
69+
blue,
70+
alpha,
71+
})
72+
}
73+
74+
/// a new [`Color`] object storing a [`LinearRgba`] color with an alpha of 1.0.
75+
pub const fn linear_rgb(red: f32, green: f32, blue: f32) -> Self {
76+
Self::LinearRgba(LinearRgba {
77+
red,
78+
green,
79+
blue,
80+
alpha: 1.0,
81+
})
82+
}
83+
84+
/// Creates a new [`Color`] object storing a [`Hsla`] color.
85+
pub const fn hsla(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Self {
86+
Self::Hsla(Hsla {
87+
hue,
88+
saturation,
89+
lightness,
90+
alpha,
91+
})
92+
}
93+
94+
/// Creates a new [`Color`] object storing a [`Hsla`] color with an alpha of 1.0.
95+
pub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> Self {
96+
Self::Hsla(Hsla {
97+
hue,
98+
saturation,
99+
lightness,
100+
alpha: 1.0,
101+
})
102+
}
103+
104+
/// Creates a new [`Color`] object storing a [`Hsva`] color.
105+
pub const fn hsva(hue: f32, saturation: f32, value: f32, alpha: f32) -> Self {
106+
Self::Hsva(Hsva {
107+
hue,
108+
saturation,
109+
value,
110+
alpha,
111+
})
112+
}
113+
114+
/// Creates a new [`Color`] object storing a [`Hsva`] color with an alpha of 1.0.
115+
pub const fn hsv(hue: f32, saturation: f32, value: f32) -> Self {
116+
Self::Hsva(Hsva {
117+
hue,
118+
saturation,
119+
value,
120+
alpha: 1.0,
121+
})
122+
}
123+
124+
/// Creates a new [`Color`] object storing a [`Hwba`] color.
125+
pub const fn hwba(hue: f32, whiteness: f32, blackness: f32, alpha: f32) -> Self {
126+
Self::Hwba(Hwba {
127+
hue,
128+
whiteness,
129+
blackness,
130+
alpha,
131+
})
132+
}
133+
134+
/// Creates a new [`Color`] object storing a [`Hwba`] color with an alpha of 1.0.
135+
pub const fn hwb(hue: f32, whiteness: f32, blackness: f32) -> Self {
136+
Self::Hwba(Hwba {
137+
hue,
138+
whiteness,
139+
blackness,
140+
alpha: 1.0,
141+
})
142+
}
143+
144+
/// Creates a new [`Color`] object storing a [`Laba`] color.
145+
pub const fn laba(lightness: f32, a: f32, b: f32, alpha: f32) -> Self {
146+
Self::Laba(Laba {
147+
lightness,
148+
a,
149+
b,
150+
alpha,
151+
})
152+
}
153+
154+
/// Creates a new [`Color`] object storing a [`Laba`] color with an alpha of 1.0.
155+
pub const fn lab(lightness: f32, a: f32, b: f32) -> Self {
156+
Self::Laba(Laba {
157+
lightness,
158+
a,
159+
b,
160+
alpha: 1.0,
161+
})
162+
}
163+
164+
/// Creates a new [`Color`] object storing a [`Lcha`] color.
165+
pub const fn lcha(lightness: f32, chroma: f32, hue: f32, alpha: f32) -> Self {
166+
Self::Lcha(Lcha {
167+
lightness,
168+
chroma,
169+
hue,
170+
alpha,
171+
})
172+
}
173+
174+
/// Creates a new [`Color`] object storing a [`Lcha`] color with an alpha of 1.0.
175+
pub const fn lch(lightness: f32, chroma: f32, hue: f32) -> Self {
176+
Self::Lcha(Lcha {
177+
lightness,
178+
chroma,
179+
hue,
180+
alpha: 1.0,
181+
})
182+
}
183+
184+
/// Creates a new [`Color`] object storing a [`Oklaba`] color.
185+
pub const fn oklaba(l: f32, a: f32, b: f32, alpha: f32) -> Self {
186+
Self::Oklaba(Oklaba { l, a, b, alpha })
187+
}
188+
189+
/// Creates a new [`Color`] object storing a [`Oklaba`] color with an alpha of 1.0.
190+
pub const fn oklab(l: f32, a: f32, b: f32) -> Self {
191+
Self::Oklaba(Oklaba {
192+
l,
193+
a,
194+
b,
195+
alpha: 1.0,
196+
})
197+
}
198+
199+
/// Creates a new [`Color`] object storing a [`Xyza`] color.
200+
pub const fn xyza(x: f32, y: f32, z: f32, alpha: f32) -> Self {
201+
Self::Xyza(Xyza { x, y, z, alpha })
202+
}
203+
204+
/// Creates a new [`Color`] object storing a [`Xyza`] color with an alpha of 1.0.
205+
pub const fn xyz(x: f32, y: f32, z: f32) -> Self {
206+
Self::Xyza(Xyza {
207+
x,
208+
y,
209+
z,
210+
alpha: 1.0,
211+
})
212+
}
213+
214+
/// A fully white [`Color::LinearRgba`] color with an alpha of 1.0.
215+
pub const WHITE: Self = Self::linear_rgb(1.0, 1.0, 1.0);
216+
217+
/// A fully black [`Color::LinearRgba`] color with an alpha of 1.0.
218+
pub const BLACK: Self = Self::linear_rgb(0., 0., 0.);
219+
220+
/// A fully transparent [`Color::LinearRgba`] color.
221+
pub const TRANSPARENT: Self = Self::linear_rgba(0., 0., 0., 0.);
43222
}
44223

45224
impl Default for Color {
225+
/// A fully white [`Color::LinearRgba`] color with an alpha of 1.0.
46226
fn default() -> Self {
47-
Self::Srgba(Srgba::WHITE)
227+
Color::WHITE
48228
}
49229
}
50230

crates/bevy_ecs/src/reflect/entity_commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn insert_reflect(
194194
.expect("component should represent a type.");
195195
let type_path = type_info.type_path();
196196
let Some(mut entity) = world.get_entity_mut(entity) else {
197-
panic!("error[B0003]: Could not insert a reflected component (of type {type_path}) for entity {entity:?} because it doesn't exist in this World.");
197+
panic!("error[B0003]: Could not insert a reflected component (of type {type_path}) for entity {entity:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/#b0003");
198198
};
199199
let Some(type_registration) = type_registry.get_with_type_path(type_path) else {
200200
panic!("Could not get type registration (for component type {type_path}) because it doesn't exist in the TypeRegistry.");

crates/bevy_ecs/src/system/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ fn insert<T: Bundle>(bundle: T) -> impl EntityCommand {
10721072
if let Some(mut entity) = world.get_entity_mut(entity) {
10731073
entity.insert(bundle);
10741074
} else {
1075-
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {:?} because it doesn't exist in this World.", std::any::type_name::<T>(), entity);
1075+
panic!("error[B0003]: Could not insert a bundle (of type `{}`) for entity {:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/#b0003", std::any::type_name::<T>(), entity);
10761076
}
10771077
}
10781078
}

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn assert_component_access_compatibility(
249249
.map(|component_id| world.components.get_info(component_id).unwrap().name())
250250
.collect::<Vec<&str>>();
251251
let accesses = conflicting_components.join(", ");
252-
panic!("error[B0001]: Query<{query_type}, {filter_type}> in system {system_name} accesses component(s) {accesses} in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`.");
252+
panic!("error[B0001]: Query<{query_type}, {filter_type}> in system {system_name} accesses component(s) {accesses} in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`. See: https://bevyengine.org/learn/errors/#b0001");
253253
}
254254

255255
/// A collection of potentially conflicting [`SystemParam`]s allowed by disjoint access.
@@ -446,7 +446,7 @@ unsafe impl<'a, T: Resource> SystemParam for Res<'a, T> {
446446
let combined_access = system_meta.component_access_set.combined_access();
447447
assert!(
448448
!combined_access.has_write(component_id),
449-
"error[B0002]: Res<{}> in system {} conflicts with a previous ResMut<{0}> access. Consider removing the duplicate access.",
449+
"error[B0002]: Res<{}> in system {} conflicts with a previous ResMut<{0}> access. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/#b0002",
450450
std::any::type_name::<T>(),
451451
system_meta.name,
452452
);
@@ -536,11 +536,11 @@ unsafe impl<'a, T: Resource> SystemParam for ResMut<'a, T> {
536536
let combined_access = system_meta.component_access_set.combined_access();
537537
if combined_access.has_write(component_id) {
538538
panic!(
539-
"error[B0002]: ResMut<{}> in system {} conflicts with a previous ResMut<{0}> access. Consider removing the duplicate access.",
539+
"error[B0002]: ResMut<{}> in system {} conflicts with a previous ResMut<{0}> access. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/#b0002",
540540
std::any::type_name::<T>(), system_meta.name);
541541
} else if combined_access.has_read(component_id) {
542542
panic!(
543-
"error[B0002]: ResMut<{}> in system {} conflicts with a previous Res<{0}> access. Consider removing the duplicate access.",
543+
"error[B0002]: ResMut<{}> in system {} conflicts with a previous Res<{0}> access. Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/#b0002",
544544
std::any::type_name::<T>(), system_meta.name);
545545
}
546546
system_meta
@@ -1031,7 +1031,7 @@ unsafe impl<'a, T: 'static> SystemParam for NonSend<'a, T> {
10311031
let combined_access = system_meta.component_access_set.combined_access();
10321032
assert!(
10331033
!combined_access.has_write(component_id),
1034-
"error[B0002]: NonSend<{}> in system {} conflicts with a previous mutable resource access ({0}). Consider removing the duplicate access.",
1034+
"error[B0002]: NonSend<{}> in system {} conflicts with a previous mutable resource access ({0}). Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/#b0002",
10351035
std::any::type_name::<T>(),
10361036
system_meta.name,
10371037
);
@@ -1118,11 +1118,11 @@ unsafe impl<'a, T: 'static> SystemParam for NonSendMut<'a, T> {
11181118
let combined_access = system_meta.component_access_set.combined_access();
11191119
if combined_access.has_write(component_id) {
11201120
panic!(
1121-
"error[B0002]: NonSendMut<{}> in system {} conflicts with a previous mutable resource access ({0}). Consider removing the duplicate access.",
1121+
"error[B0002]: NonSendMut<{}> in system {} conflicts with a previous mutable resource access ({0}). Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/#b0002",
11221122
std::any::type_name::<T>(), system_meta.name);
11231123
} else if combined_access.has_read(component_id) {
11241124
panic!(
1125-
"error[B0002]: NonSendMut<{}> in system {} conflicts with a previous immutable resource access ({0}). Consider removing the duplicate access.",
1125+
"error[B0002]: NonSendMut<{}> in system {} conflicts with a previous immutable resource access ({0}). Consider removing the duplicate access. See: https://bevyengine.org/learn/errors/#b0002",
11261126
std::any::type_name::<T>(), system_meta.name);
11271127
}
11281128
system_meta

crates/bevy_ecs/src/world/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ impl World {
887887
entity.despawn();
888888
true
889889
} else {
890-
warn!("error[B0003]: Could not despawn entity {:?} because it doesn't exist in this World.", entity);
890+
warn!("error[B0003]: Could not despawn entity {:?} because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/#b0003", entity);
891891
false
892892
}
893893
}

crates/bevy_text/src/glyph_brush.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ impl GlyphBrush {
115115
if !text_settings.allow_dynamic_font_size
116116
&& font_atlas_set.len() > text_settings.soft_max_font_atlases.get()
117117
{
118-
warn_once!("warning[B0005]: Number of font atlases has exceeded the maximum of {}. Performance and memory usage may suffer.", text_settings.soft_max_font_atlases.get());
118+
warn_once!(
119+
"warning[B0005]: Number of font atlases has exceeded the maximum of {}. Performance and memory usage may suffer. See: https://bevyengine.org/learn/errors/#b0005",
120+
text_settings.soft_max_font_atlases.get());
119121
}
120122

121123
let texture_atlas = texture_atlases.get(&atlas_info.texture_atlas).unwrap();

0 commit comments

Comments
 (0)