Skip to main content

ParticleEmitterConfig

Struct ParticleEmitterConfig 

Source
pub struct ParticleEmitterConfig<'a> { /* private fields */ }
Expand description

Helper for builder-style configuration.

Implementations§

Source§

impl<'a> ParticleEmitterConfig<'a>

Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

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    }
Source

pub fn max_particles(&mut self, max: usize) -> &mut Self

Source

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    }
Source

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    }
Source

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    }
Source

pub fn burst(&mut self, count: u32) -> &mut Self

Source

pub fn looping(&mut self, looping: bool) -> &mut Self

Source

pub fn rotation_speed(&mut self, min: f32, max: f32) -> &mut Self

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.