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
Ready-made configurations for common use cases.
impl Decay
Ready-made configurations for common use cases.
Sourcepub fn instant_redraw() -> Decay
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.
Sourcepub fn continuous_update(
time_since_last_trace: f32,
persistence: f32,
trace_length: usize,
) -> Decay
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 screenpersistence- 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.