Struct plasma::Plasma

source ·
pub struct Plasma {
    pub pixel_width: u32,
    pub pixel_height: u32,
    /* private fields */
}
Expand description

The struct that holds the meta information about current plasma state

Fields§

§pixel_width: u32

The plasma pixel width

§pixel_height: u32

The plasma pixel height

Implementations§

source§

impl Plasma

source

pub fn new<R: Rng + ?Sized>( pixel_width: u32, pixel_height: u32, config: PhaseAmpCfg, rng: &mut R, ) -> Self

Creates new plasma instance.

Provide the initial pixel_width and pixel_height, initialized PhaseAmpCfg and an instance of Rng.

source

pub fn update<R: Rng + ?Sized>(&mut self, rng: &mut R)

Animates the plasma by modifying the internal PhaseAmp variables.

Provide an instance of initialized Rng instance.

source

pub fn render<'a, B, L, M>( &'a self, buffer: &mut [u8], pitch: usize, wrkspc: Option<&mut Vec<u8>>, )
where B: PixelBuffer, L: ICProducer<'a>, M: Mixer<f32>,

Renders the plasma into the provided buffer.

You must also provide a struct implementing PixelBuffer trait.

The pitch should contain the number of bytes of a single line in a buffer.

The wrkspc is an optional temporary memory scractchpad. If None is provided the new memory will be allocated.

source

pub fn render_part<'a, B, L, M>( &'a self, buffer: &mut [u8], pitch: usize, x: usize, y: usize, w: usize, h: usize, wrkspc: Option<&mut Vec<u8>>, )
where B: PixelBuffer, L: ICProducer<'a>, M: Mixer<f32>,

Renders the part of the plasma into the provided buffer.

You must also provide a struct implementing PixelBuffer trait.

The pitch should contain the number of bytes of a single line in a buffer.

The boundary of rendered part should be provided by x, y, w and h arguments in pixel coordinates starting from left/top corner.

The wrkspc is an optional temporary memory scractchpad. If None is provided the new memory will be allocated.

source

pub fn import_phase_amps(&mut self, source: &[f32])

Import the internal plasma state from a slice of 32bit floats.

source

pub fn export_phase_amps(&self, out: &mut Vec<f32>)

Exports the internal plasma state into the Vec of 32bit floats.

source

pub fn min_steps(&self) -> f32

source

pub fn max_steps(&self) -> f32

Trait Implementations§

source§

impl Clone for Plasma

source§

fn clone(&self) -> Plasma

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Plasma

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Plasma

source§

fn eq(&self, other: &Plasma) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Plasma

Auto Trait Implementations§

§

impl Freeze for Plasma

§

impl RefUnwindSafe for Plasma

§

impl Send for Plasma

§

impl Sync for Plasma

§

impl Unpin for Plasma

§

impl UnwindSafe for Plasma

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.