1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! # linearpl
//!
//! Linear particle library for [macroquad](https://github.com/not-fl3/macroquad).
//!
//! ---
//!
//! # Usage
//!
//! An example of how to use this library is given in [main.rs](src/main.rs), I'd recommend
//! looking at that after for a more detailed example that puts everything together.
//!
//! ## Examples
//!
//! A linear particle instance starting at (0, 0, 0) and ending at (1, 1, 1):
//!
//! ```
//! use macroquad::prelude::*;
//! use linearpl::linear_particles::LinearParticles;
//!
//! ...
//!
//! let start = Vec3::new(0.0, 0.0, 0.0);
//! let end = Vec3::new(1.0, 1.0, 1.0);
//! let mut linear_instance = LinearParticles::new(start, end)
//! .with_decay(1.4)?
//! .with_locations(&[0.0, 1.0])?
//! .with_colors(&[RED, BLUE])?;
//!
//! if let Err(v) == linear_instance.start_loop() {
//! eprintln!("received error: {:?}", v);
//! }
//!
//! loop {
//! ...
//! linear_instance.run()?;
//! ...
//! }
//! ```
//!
//! ---
//!
//! # Parts
//!
//! ### ParticleSys
//!
//! The core api for this library resides in the `linearpl::particle_sys::ParticleSys`
//! trait's start and stop methods:
//!
//! * `start()` and `start_loop()` setup and prepare the particle system to be drawn
//! * `run()` displays particles with respect to the amount of elapsed time from "starting"
//! * `stop()` stops the particle system before termination in `run()` or while looping
//!
//! Along with these methods, all implementations of `ParticleSys` in the library implement
//! particle systems that span a set `period` held by the object, which is the number of seconds
//! the particle system should run.
//!
//! ### LinearParticles
//!
//! For the linear particle system `linearpl::linear_particles::LinearParticles`, the particles
//! fall along a linear path defined by the `start_location` and `end_location` Vec3 members of
//! the object. The user then has control over some other settings which are linearly interpolated
//! over throughout the entire `period` of the objects particle generation:
//!
//! * `densities` : chance that a particle will be drawn in the given frame (0 to 1)
//! * `locations` : location to generate particle on line from 0 (`start_location`) to 1 (`end_location`)
//! * `colors` : color of particle generated in the given frame (using `macroquad::color::Color`)
//!
//! Other than that, there is a `decay` control which sets the amount of time it a particle
//! is drawn for (i.e. defines the `period` of each individual particle).
//!
//! ### SyncGrp and SeqGrp
//!
//! These two objects are used to created synchronized groups of objects implementing `ParticleSys`
//! using a single clock, making it easier for the user to create more complex and interesting
//! graphics from the particle system implementation in the library. These objects hold any
//! type of `ParticleSys` implementation, including other SyncGrp and SeqGrp objects.