Skip to content

Commit 473840c

Browse files
committed
Use bevy::color::Color as an argument to lighting methods
1 parent 0783556 commit 473840c

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
@@ -780,19 +780,13 @@ pub fn light_create_directional(
780780
x: f32,
781781
y: f32,
782782
z: f32,
783-
r: f32,
784-
g: f32,
785-
b: f32,
786-
a: f32,
783+
color: Color,
787784
illuminance: f32,
788785
) -> error::Result<Entity> {
789786
app_mut(|app| {
790787
Ok(app
791788
.world_mut()
792-
.run_system_cached_with(
793-
light::create_directional,
794-
(x, y, z, r, g, b, a, illuminance),
795-
)
789+
.run_system_cached_with(light::create_directional, (x, y, z, color, illuminance))
796790
.unwrap())
797791
})
798792
}
@@ -801,10 +795,7 @@ pub fn light_create_point(
801795
x: f32,
802796
y: f32,
803797
z: f32,
804-
r: f32,
805-
g: f32,
806-
b: f32,
807-
a: f32,
798+
color: Color,
808799
intensity: f32,
809800
range: f32,
810801
radius: f32,
@@ -814,7 +805,7 @@ pub fn light_create_point(
814805
.world_mut()
815806
.run_system_cached_with(
816807
light::create_point,
817-
(x, y, z, r, g, b, a, intensity, range, radius),
808+
(x, y, z, color, intensity, range, radius),
818809
)
819810
.unwrap())
820811
})
@@ -824,10 +815,7 @@ pub fn light_create_spot(
824815
x: f32,
825816
y: f32,
826817
z: f32,
827-
r: f32,
828-
g: f32,
829-
b: f32,
830-
a: f32,
818+
color: Color,
831819
intensity: f32,
832820
range: f32,
833821
radius: f32,
@@ -843,10 +831,7 @@ pub fn light_create_spot(
843831
x,
844832
y,
845833
z,
846-
r,
847-
g,
848-
b,
849-
a,
834+
color,
850835
intensity,
851836
range,
852837
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)