diff --git a/src/editor/plot.rs b/src/editor/plot.rs index de0924d..da3d5a3 100644 --- a/src/editor/plot.rs +++ b/src/editor/plot.rs @@ -167,18 +167,32 @@ pub(super) fn draw(ui: &mut egui::Ui, meters: &Meters, state: &mut PlotState) { let c = state.selected.min(NUM_CHANNELS - 1); let (write, len) = (state.history.write, state.history.len); if len >= 2 { - let draw_series = |series: &[f32; PLOT_N], to_db: &dyn Fn(f32) -> f32, color: Color32| { + let draw_series = |series: &[f32; PLOT_N], to_db: &dyn Fn(f32) -> f32, color: Color32, fill: bool| { let mut pts = Vec::with_capacity(len); for k in 0..len { let idx = (write + PLOT_N - len + k) % PLOT_N; let pos = (PLOT_N - len + k) as f32 / (PLOT_N - 1) as f32; // newest hugs the right pts.push(pos2(left + pos * width, y_for_db(to_db(series[idx])))); } + if fill { + // Translucent area from the line down to the bottom of the plot. + let mut area = Vec::with_capacity(pts.len() + 2); + area.push(pos2(pts[0].x, bottom)); + area.extend_from_slice(&pts); + area.push(pos2(pts[pts.len() - 1].x, bottom)); + let fill_col = Color32::from_rgba_unmultiplied(color.r(), color.g(), color.b(), 40); + p.add(egui::Shape::Path(egui::epaint::PathShape { + points: area, + closed: true, + fill: fill_col, + stroke: egui::epaint::PathStroke::NONE, + })); + } p.add(egui::Shape::line(pts, Stroke::new(1.5, color))); }; - draw_series(&state.history.in_db[c], &|db| db, COLOR_IN); - draw_series(&state.history.out_db[c], &|db| db, COLOR_OUT); + draw_series(&state.history.in_db[c], &|db| db, COLOR_IN, true); + draw_series(&state.history.out_db[c], &|db| db, COLOR_OUT, true); // GR hangs from the 0 dB line: a reduction of X dB is drawn at the -X gridline. - draw_series(&state.history.gr_db[c], &|gr| -gr, COLOR_GR); + draw_series(&state.history.gr_db[c], &|gr| -gr, COLOR_GR, false); } }