Skip to main content

Decay

Struct Decay 

Source
pub struct Decay { /* private fields */ }
Expand description

Natural decay behaviour of the simulated phosphor screen.

We provide two tuning knobs:

  • the decay between consecutive samples in the same trace
  • the decay between consecutive traces

The former models the finite time it takes for the scope to trace a single sweep across the screen. The latter models the time between two shots.

§screen_decay

The decay factor applied to the entire phosphor screen, applied the next time when Renderer::render_intermediate() is called. Each pixel is faded according to a factor of exp(-screen_decay). A value of either exactly 0.0 (no decay, waveforms are drawn on top of each other) or +INFINITY (new waveforms completely erase previous ones) bypass the blending logic and are slightly more efficient. A value below 0 is clamped.

§sample_decay

The decay factor applied between consecutive samples in the same trace. The very last sample is painted with full nominal intensity, and the N-th sample before the last has its intensity scaled by a factor (1 - sample_decay).pow(N). Setting sample_decay to 0.0 will render all samples at full intensity. A value outside the [0, 1] range is clamped.

Implementations§

Source§

impl Decay

Source

pub fn new(screen_decay: f32, sample_decay: f32) -> Decay

Source

pub fn with_sample_decay(self, sample_decay: f32) -> Decay

Source

pub fn with_screen_decay(self, screen_decay: f32) -> Decay

Source§

impl Decay

Ready-made configurations for common use cases.

Source

pub fn no_decay() -> Decay

No decay. All render commands draw on top of each other.

Source

pub fn instant_redraw() -> Decay

No sample-to-sample decay, and no persistence between traces.

Useful for ‘single-shot digital storage oscilloscope’ applications, where e.g. a full trace is acquired once, and then frozen. The user can pan and zoom the viewport for inspecting the waveform, without the trace fading.

This is what the Default::default() implementation returns.

Source

pub fn continuous_update( time_since_last_trace: f32, persistence: f32, trace_length: usize, ) -> Decay

Decay simulating a continuously updated waveform with no dead-time between shots.

Think of a free-running oscilloscope in XY mode.

§Arguments
  • time_since_last_frame - Time (e.g. in seconds) since the last frame was drawn to the screen
  • persistence - Time (same units) for the phosphor screen to decay to 37% (1/e) of its original brightness.
  • trace_length - The number of samples in the waveform about to be drawn.

Trait Implementations§

Source§

impl Clone for Decay

Source§

fn clone(&self) -> Decay

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Decay

Source§

impl Debug for Decay

Source§

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

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

impl Default for Decay

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Decay

§

impl RefUnwindSafe for Decay

§

impl Send for Decay

§

impl Sync for Decay

§

impl Unpin for Decay

§

impl UnsafeUnpin for Decay

§

impl UnwindSafe for Decay

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,