Fixed page-temperature not having consistent coloring.

This commit is contained in:
Filipe Rodrigues 2023-06-14 07:10:22 +01:00
parent 60d71c073b
commit 4ae37e3066

View File

@ -254,27 +254,27 @@ fn draw_page_location(cmd_args: args::PageLocation) -> Result<(), anyhow::Error>
.collect::<Vec<_>>();
(mem_idx, points)
})
.collect::<Vec<_>>();
.collect::<BTreeMap<_, _>>();
// Finally create and save the plot
let mut fg = gnuplot::Figure::new();
let axes_2d = fg.axes2d();
for (points_idx, &(mem_idx, ref points)) in all_points.iter().enumerate() {
for (&mem_idx, points) in &all_points {
let mem = config
.hemem
.memories
.get(mem_idx)
.context("Config had less memories than input file")?;
let color_progress = points_idx as f64 / (all_points.len() as f64 - 1.0);
let color = LinSrgb::new(1.0, 0.0, 0.0).mix(LinSrgb::new(0.0, 1.0, 0.0), color_progress);
let color_progress = mem_idx as f64 / (all_points.len() as f64 - 1.0);
let color = LinSrgb::new(0.0, 1.0, 0.0).mix(LinSrgb::new(1.0, 0.0, 0.0), color_progress);
let color = format!("#{:x}", color.into_format::<u8>());
// Note: Since we're drawing back-to-front, we need the first points
// to be larger than the last.
// We also never hit 0 here due to `points_idx` < `all_points.len()`.
let point_size_progress = 1.0 - points_idx as f64 / all_points.len() as f64;
// We also never hit 0 here due to `mem_idx` < `all_points.len()`.
let point_size_progress = 1.0 - mem_idx as f64 / all_points.len() as f64;
let point_size = point_size_progress * cmd_args.point_size;
axes_2d.points(points.iter().map(|p| p.x), points.iter().map(|p| p.y), &[