Skip to content

Commit e49df42

Browse files
committed
Use bevy::color::Color as an argument to lighting methods
1 parent 0fbbaae commit e49df42

File tree

3 files changed

+20
-43
lines changed

3 files changed

+20
-43
lines changed

crates/processing_render/src/lib.rs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -708,19 +708,13 @@ pub fn light_create_directional(
708708
x: f32,
709709
y: f32,
710710
z: f32,
711-
r: f32,
712-
g: f32,
713-
b: f32,
714-
a: f32,
711+
color: Color,
715712
illuminance: f32,
716713
) -> error::Result<Entity> {
717714
app_mut(|app| {
718715
Ok(app
719716
.world_mut()
720-
.run_system_cached_with(
721-
light::create_directional,
722-
(x, y, z, r, g, b, a, illuminance),
723-
)
717+
.run_system_cached_with(light::create_directional, (x, y, z, color, illuminance))
724718
.unwrap())
725719
})
726720
}
@@ -729,10 +723,7 @@ pub fn light_create_point(
729723
x: f32,
730724
y: f32,
731725
z: f32,
732-
r: f32,
733-
g: f32,
734-
b: f32,
735-
a: f32,
726+
color: Color,
736727
intensity: f32,
737728
range: f32,
738729
radius: f32,
@@ -742,7 +733,7 @@ pub fn light_create_point(
742733
.world_mut()
743734
.run_system_cached_with(
744735
light::create_point,
745-
(x, y, z, r, g, b, a, intensity, range, radius),
736+
(x, y, z, color, intensity, range, radius),
746737
)
747738
.unwrap())
748739
})
@@ -752,10 +743,7 @@ pub fn light_create_spot(
752743
x: f32,
753744
y: f32,
754745
z: f32,
755-
r: f32,
756-
g: f32,
757-
b: f32,
758-
a: f32,
746+
color: Color,
759747
intensity: f32,
760748
range: f32,
761749
radius: f32,
@@ -771,10 +759,7 @@ pub fn light_create_spot(
771759
x,
772760
y,
773761
z,
774-
r,
775-
g,
776-
b,
777-
a,
762+
color,
778763
intensity,
779764
range,
780765
radius,

crates/processing_render/src/light.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ impl Plugin for LightPlugin {
1010
}
1111

1212
pub fn create_directional(
13-
In((px, py, pz, r, g, b, a, illuminance)): In<(f32, f32, f32, f32, f32, f32, f32, f32)>,
13+
In((px, py, pz, color, illuminance)): In<(f32, f32, f32, Color, f32)>,
1414
mut commands: Commands,
1515
) -> Entity {
1616
commands
1717
.spawn((
1818
DirectionalLight {
1919
illuminance,
20-
color: Color::srgba(r, g, b, a),
20+
color,
2121
..default()
2222
},
2323
Transform::from_xyz(px, py, pz),
@@ -26,25 +26,14 @@ pub fn create_directional(
2626
}
2727

2828
pub fn create_point(
29-
In((px, py, pz, r, g, b, a, intensity, range, radius)): In<(
30-
f32,
31-
f32,
32-
f32,
33-
f32,
34-
f32,
35-
f32,
36-
f32,
37-
f32,
38-
f32,
39-
f32,
40-
)>,
29+
In((px, py, pz, color, intensity, range, radius)): In<(f32, f32, f32, Color, f32, f32, f32)>,
4130
mut commands: Commands,
4231
) -> Entity {
4332
commands
4433
.spawn((
4534
PointLight {
4635
intensity,
47-
color: Color::srgba(r, g, b, a),
36+
color,
4837
range,
4938
radius,
5039
..default()
@@ -55,14 +44,11 @@ pub fn create_point(
5544
}
5645

5746
pub fn create_spot(
58-
In((px, py, pz, r, g, b, a, intensity, range, radius, inner_angle, outer_angle)): In<(
59-
f32,
60-
f32,
61-
f32,
62-
f32,
47+
In((px, py, pz, color, intensity, range, radius, inner_angle, outer_angle)): In<(
6348
f32,
6449
f32,
6550
f32,
51+
Color,
6652
f32,
6753
f32,
6854
f32,
@@ -74,7 +60,7 @@ pub fn create_spot(
7460
commands
7561
.spawn((
7662
SpotLight {
77-
color: Color::srgba(r, g, b, a),
63+
color,
7864
intensity,
7965
range,
8066
radius,

examples/lights.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ fn sketch() -> error::Result<()> {
3131

3232
// We will only declare lights in `setup`
3333
// rather than calling some sort of `light()` method inside of `draw`
34-
let _dir_light = light_create_directional(0.0, 0.0, 0.0, 0.5, 0.43, 1.0, 1.0, 1000.0);
34+
let _dir_light = light_create_directional(
35+
0.0,
36+
0.0,
37+
0.0,
38+
bevy::color::Color::srgb(1.0, 0.0, 0.0),
39+
1000.0,
40+
);
3541

3642
graphics_mode_3d(graphics)?;
3743
graphics_camera_position(graphics, 100.0, 100.0, 300.0)?;

0 commit comments

Comments
 (0)