1
0
Fork 0

Clean up the GR overlay drawing

This commit is contained in:
Robbert van der Helm 2023-03-21 18:27:42 +01:00
parent 730757f8d7
commit 35864aa13c

View file

@ -254,9 +254,6 @@ fn draw_gain_reduction(
let bin_frequency = |bin_idx: f32| (bin_idx / analyzer_data.num_bins as f32) * nyquist_hz;
// TODO: This should be drawn as one mesh, or multiple meshes if there are empty gain reduction
// bars. The leftmost bin should be extended to the left of the analyzer, and the
// rightmost bin should be extended to the right.
let mut path = vg::Path::new();
for (bin_idx, gain_difference_db) in analyzer_data
.gain_difference_db
@ -264,11 +261,13 @@ fn draw_gain_reduction(
.enumerate()
.take(analyzer_data.num_bins)
{
// TODO: Draw this as a single mesh instead, this doesn't work.
// Avoid drawing tiny slivers for low gain reduction values
if gain_difference_db.abs() > 0.2 {
// The gain reduction bars are drawn width the width of the bin, centered on the
// bin's center frequency
if gain_difference_db.abs() < 0.2 {
continue;
}
// The gain reduction bars are drawn width the width of the bin, centered on the bin's
// center frequency
let gr_start_ln_frequency = bin_frequency(bin_idx as f32 - 0.5).ln();
let gr_end_ln_frequency = bin_frequency(bin_idx as f32 + 0.5).ln();
@ -295,7 +294,6 @@ fn draw_gain_reduction(
path.line_to(bounds.x + (bounds.w * t_start), bounds.y + (bounds.h * t_y));
path.close();
}
}
canvas
.global_composite_blend_func(vg::BlendFactor::DstAlpha, vg::BlendFactor::OneMinusDstColor);