pub struct ParticleEmitterConfig<'a> { /* private fields */ }Expand description
Helper for builder-style configuration.
Implementations§
Source§impl<'a> ParticleEmitterConfig<'a>
impl<'a> ParticleEmitterConfig<'a>
Sourcepub fn rate(&mut self, rate: f32) -> &mut Self
pub fn rate(&mut self, rate: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 17)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn shape(&mut self, shape: EmitterShape) -> &mut Self
pub fn shape(&mut self, shape: EmitterShape) -> &mut Self
Examples found in repository?
examples/particles.rs (line 18)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn speed(&mut self, min: f32, max: f32) -> &mut Self
pub fn speed(&mut self, min: f32, max: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 19)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn angle(&mut self, min: f32, max: f32) -> &mut Self
pub fn angle(&mut self, min: f32, max: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 20)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn size(&mut self, min: f32, max: f32) -> &mut Self
pub fn size(&mut self, min: f32, max: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 21)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn lifetime(&mut self, min: f32, max: f32) -> &mut Self
pub fn lifetime(&mut self, min: f32, max: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 22)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn gravity(&mut self, x: f32, y: f32) -> &mut Self
pub fn gravity(&mut self, x: f32, y: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 23)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn drag(&mut self, drag: f32) -> &mut Self
pub fn drag(&mut self, drag: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 27)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }pub fn max_particles(&mut self, max: usize) -> &mut Self
Sourcepub fn color_start(&mut self, color: Color) -> &mut Self
pub fn color_start(&mut self, color: Color) -> &mut Self
Examples found in repository?
examples/particles.rs (line 24)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn color_end(&mut self, color: Color) -> &mut Self
pub fn color_end(&mut self, color: Color) -> &mut Self
Examples found in repository?
examples/particles.rs (line 25)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }Sourcepub fn size_end(&mut self, size: f32) -> &mut Self
pub fn size_end(&mut self, size: f32) -> &mut Self
Examples found in repository?
examples/particles.rs (line 26)
12 fn on_enter(&mut self, _ctx: &mut Context) {
13 // Fire emitter at bottom center
14 let mut fire = ParticleEmitter::new(vec2(400.0, 500.0));
15 fire.configure(|cfg| {
16 cfg
17 .rate(80.0)
18 .shape(EmitterShape::Line { x1: 370.0, y1: 500.0, x2: 430.0, y2: 500.0 })
19 .speed(80.0, 200.0)
20 .angle(std::f32::consts::PI * 1.1, std::f32::consts::PI * 1.9)
21 .size(3.0, 10.0)
22 .lifetime(0.3, 1.0)
23 .gravity(0.0, -80.0)
24 .color_start(Color::from_hex("#FF6600").unwrap())
25 .color_end(Color::from_hex("#FFFF00").unwrap())
26 .size_end(0.0)
27 .drag(1.5);
28 });
29 self.emitters.push(fire);
30
31 // Sparkle emitter
32 let mut sparkles = ParticleEmitter::new(vec2(400.0, 300.0));
33 sparkles.configure(|cfg| {
34 cfg
35 .rate(30.0)
36 .shape(EmitterShape::Circle { cx: 400.0, cy: 300.0, radius: 150.0 })
37 .speed(10.0, 50.0)
38 .angle(0.0, std::f32::consts::TAU)
39 .size(2.0, 6.0)
40 .lifetime(0.5, 1.5)
41 .gravity(0.0, 20.0)
42 .color_start(Color::from_hex("#FFFFFF").unwrap())
43 .color_end(Color::TRANSPARENT)
44 .size_end(0.0);
45 });
46 self.emitters.push(sparkles);
47 }pub fn burst(&mut self, count: u32) -> &mut Self
pub fn looping(&mut self, looping: bool) -> &mut Self
pub fn rotation_speed(&mut self, min: f32, max: f32) -> &mut Self
Auto Trait Implementations§
impl<'a> !UnwindSafe for ParticleEmitterConfig<'a>
impl<'a> Freeze for ParticleEmitterConfig<'a>
impl<'a> RefUnwindSafe for ParticleEmitterConfig<'a>
impl<'a> Send for ParticleEmitterConfig<'a>
impl<'a> Sync for ParticleEmitterConfig<'a>
impl<'a> Unpin for ParticleEmitterConfig<'a>
impl<'a> UnsafeUnpin for ParticleEmitterConfig<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more