Crate plasma

source ·
Expand description

A Plasma struct and tools for rendering animated eye-candy pixels.

Example

extern crate rand;
extern crate plasma;

use plasma::*;

fn main() {
    let min_steps = 80.0f32;
    let max_steps = 200.0f32;
    let plasma_width = 200u32;
    let plasma_height = 200u32;
    let mut rng = rand::thread_rng();
    let cfg = PhaseAmpCfg::new(min_steps, max_steps);
    let mixer = PlasmaMixer::new();

    let mut plasma = Plasma::new(plasma_width, plasma_height, cfg, &mut rng);

    let pitch = plasma_width as usize * PixelBufRGB24::PIXEL_BYTES;
    let mut buffer_rgb24 = vec![0u8; pitch * plasma_height as usize];
    plasma.render::<PixelBufRGB24, PlasmaICP, _>(&mixer, &mut buffer_rgb24, pitch, None);
    plasma.update(&mut rng);
}

Structs

Holds a phase and an amplitude along with their animation state.
Holds parameters of phase and amplitude changes for PhaseAmpConfig trait.
A PixelBuffer tool for a RGB24 buffer (3 bytes/pixel: red, green, blue).
A PixelBuffer tool for a RGBA8 buffer (4 bytes/pixel: red, green, blue, alpha).
A struct representing one or more pixels in the linear RGB color space.
The struct that holds the meta information about current plasma state
Provides a default implementation of a IntermediateCalculatorProducer.
Provides a default implementation of a IntermediateCalculator.
Provides a default implementation of an iterator of PlasmaLineCalc.
A default implementation of a Mixer is provided for this struct.
An iterator of PixelRgb color components.
An iterator of PixelRgb color components plus an alpha component.

Traits

A convenient trait alias for plasma render methods.
Implementations of this trait should compute the vertical and horizontal intermediate data for a Mixer.
Implementations of this trait should produce an iterator of an IntermediateCalculator tool.
Implementations of this trait should compute the color of each pixel based on an intermediate data created by a IntermediateCalculator.
A trait for querying and updating phase’n’amplitude
A trait for querying parameters of phase and amplitude changes.
A trait that allows importing and exporting of phase’n’amplitude data
A trait that allows selecting a subset of phase’n’amplitude and iterate over pairs of it.
The trait for putting pixels into byte buffers.
Provides a method of converting color part from a f32 type to a u8.

Functions

Renders the part of the plasma into the provided buffer without the Plasma instance.

Type Definitions