Mix colours
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use eframe::egui;
|
||||
use egui::Vec2b;
|
||||
use egui::ecolor::Hsva;
|
||||
use egui::{Color32, Vec2b};
|
||||
use egui_plot::{AxisHints, Legend, Line, Plot, PlotPoints, VPlacement};
|
||||
|
||||
use crate::signal::{decimate, nearest_y, PlottedSignal};
|
||||
@@ -40,6 +41,12 @@ fn full_x_range(signals: &[PlottedSignal]) -> (f64, f64) {
|
||||
(min, max)
|
||||
}
|
||||
|
||||
fn color_for(id: u64) -> Color32 {
|
||||
let mixed = (id.wrapping_mul(2654435761)) as u32;
|
||||
let hue = mixed as f32 / u32::MAX as f32;
|
||||
Hsva::new(hue, 0.85, 0.9, 1.0).into()
|
||||
}
|
||||
|
||||
fn line_label(sig: &PlottedSignal, cursor_x: Option<f64>) -> String {
|
||||
let unit_suffix = if sig.unit.is_empty() {
|
||||
String::new()
|
||||
@@ -117,7 +124,7 @@ pub fn show_plot_panel(
|
||||
decimate(&sig.points, x_min, x_max, pixel_width.max(1), &mut buf);
|
||||
let plot_points = PlotPoints::Owned(std::mem::take(&mut buf));
|
||||
let name = line_label(sig, prev_cursor_x);
|
||||
plot_ui.line(Line::new(name, plot_points));
|
||||
plot_ui.line(Line::new(name, plot_points).color(color_for(sig.id)));
|
||||
}
|
||||
plot_ui.pointer_coordinate().map(|c| c.x)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user