Skip to content

Commit

Permalink
smooth zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Nov 15, 2024
1 parent 3085369 commit 1e49b7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,23 @@ impl View for DelayGraph {
let outline_width = draw_context.outline_width();

// Compute the time scaling factor
let time_scaling_factor = Self::compute_time_scaling_factor(
let target_time_scaling_factor = Self::compute_time_scaling_factor(
self.params.clone(),
bounds.w,
border_width,
outline_width,
);

let factor = 0.9;
let time_scaling_factor = (self
.params
.previous_time_scaling_factor
.load(Ordering::SeqCst)
* factor)
+ (target_time_scaling_factor * (1.0 - factor));
self.params
.previous_time_scaling_factor
.store(time_scaling_factor, Ordering::SeqCst);
// Draw components
Self::draw_background(canvas, bounds, background_color);
Self::draw_delay_times_as_lines(
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub struct Del2Params {
max_tap_samples: Arc<AtomicU32>,
#[persist = "first-note"]
first_note: Arc<AtomicU8>,
previous_time_scaling_factor: Arc<AtomicF32>,

/// A voice's gain. This can be polyphonically modulated.
#[id = "gain"]
Expand Down Expand Up @@ -523,6 +524,7 @@ impl Del2Params {
current_time: Arc::new(AtomicU32::new(0)),
max_tap_samples: Arc::new(AtomicU32::new(0)),
first_note: Arc::new(AtomicU8::new(NO_LEARNED_NOTE)),
previous_time_scaling_factor: Arc::new(AtomicF32::new(0.0)),

gain: FloatParam::new(
"Gain",
Expand Down

0 comments on commit 1e49b7a

Please sign in to comment.