Skip to content

struct

ParticleSystem

pub struct ParticleSystem {
    pub particles: Vec<Particle>,
    /* private fields */
}

A running particle background.

Fields

particles

pub particles: Vec<Particle>

The particles, as they are now.

Methods

new

pub fn new(options: ParticleOptions, width: f32, height: f32) -> ParticleSystem

A particle system with options, on a surface width by height.

options

pub fn options(&self) -> &ParticleOptions

Its options.

size

pub fn size(&self) -> (f32, f32)

Its surface's size: width, height.

resize

pub fn resize(&mut self, width: f32, height: f32)

A new size; with a density, particles are added or removed to suit.

set_pointer

pub fn set_pointer(&mut self, at: Option<(f32, f32)>)

The pointer's position relative to the area, or None when it has left (the window, or the area when following it there).

click

pub fn click(&mut self, x: f32, y: f32)

A click at (x, y), relative to the area.

step

pub fn step(&mut self, dt: f32)

Advance by dt seconds (long gaps, such as a hidden tab, count as a tenth of a second).

draw

pub fn draw(&self) -> Vec<DrawCommand>

Canvas 2D commands for the current frame: links, then pointer lines, then the particles.

Trait implementations