diff --git a/apps/ltn/src/colors.rs b/apps/ltn/src/colors.rs index f48431280b..fad77cb159 100644 --- a/apps/ltn/src/colors.rs +++ b/apps/ltn/src/colors.rs @@ -1,13 +1,19 @@ use widgetry::Color; lazy_static::lazy_static! { - pub static ref CELLS: [Color; 6] = [ - Color::BLUE.alpha(0.5), - Color::YELLOW.alpha(0.5), - Color::hex("#3CAEA3").alpha(0.5), - Color::PURPLE.alpha(0.5), - Color::PINK.alpha(0.5), - Color::ORANGE.alpha(0.5), + // A qualitative palette from colorbrewer2.org, skipping the red hue (used for levels of + // shortcutting) and grey (too close to the basemap) + pub static ref CELLS: [Color; 10] = [ + Color::hex("#8dd3c7"), + Color::hex("#ffffb3"), + Color::hex("#bebada"), + Color::hex("#80b1d3"), + Color::hex("#fdb462"), + Color::hex("#b3de69"), + Color::hex("#fccde5"), + Color::hex("#bc80bd"), + Color::hex("#ccebc5"), + Color::hex("#ffed6f"), ]; pub static ref PLAN_ROUTE_BEFORE: Color = Color::RED; diff --git a/apps/ltn/src/connectivity.rs b/apps/ltn/src/connectivity.rs index e9c5d03012..75bcc54f6a 100644 --- a/apps/ltn/src/connectivity.rs +++ b/apps/ltn/src/connectivity.rs @@ -309,10 +309,33 @@ fn setup_editing( let render_cells = RenderCells::new(map, neighbourhood); if app.session.draw_cells_as_areas { draw_under_roads_layer = render_cells.draw_colored_areas(); - } else { - draw_top_layer.append(render_cells.draw_island_outlines()); + draw_top_layer.append(render_cells.draw_island_outlines(true)); - // Highlight cell areas and their border areas when hovered + // Highlight border arrows when hovered + for (idx, polygons) in render_cells.polygons_per_cell.iter().enumerate() { + // Edge case happening near https://www.openstreetmap.org/way/106879596 + if polygons.is_empty() { + continue; + } + + let color = render_cells.colors[idx].alpha(1.0); + let mut batch = GeomBatch::new(); + for arrow in neighbourhood.cells[idx].border_arrows(app) { + batch.push(color, arrow); + } + + highlight_cell + .add_unnamed() + .hitbox(Polygon::union_all(polygons.clone())) + // Don't draw cells by default + .drawn_in_master_batch() + .draw_hovered(batch) + .build(ctx); + } + } else { + draw_top_layer.append(render_cells.draw_island_outlines(false)); + + // Highlight cell areas and their border arrows when hovered for (idx, polygons) in render_cells.polygons_per_cell.iter().enumerate() { // Edge case happening near https://www.openstreetmap.org/way/106879596 if polygons.is_empty() { @@ -347,7 +370,10 @@ fn setup_editing( Color::BLACK }; for arrow in cell.border_arrows(app) { - draw_top_layer.push(color, arrow); + draw_top_layer.push(color, arrow.clone()); + if let Ok(outline) = arrow.to_outline(Distance::meters(1.0)) { + draw_top_layer.push(Color::BLACK, outline); + } } } diff --git a/apps/ltn/src/draw_cells.rs b/apps/ltn/src/draw_cells.rs index 5c2f668b11..03f0a433cd 100644 --- a/apps/ltn/src/draw_cells.rs +++ b/apps/ltn/src/draw_cells.rs @@ -51,7 +51,7 @@ impl RenderCells { /// Draw the boundary between cells as a thick outline. It's meant to look like the /// neighbourhood is split into disconnected islands. - pub fn draw_island_outlines(&self) -> GeomBatch { + pub fn draw_island_outlines(&self, use_color: bool) -> GeomBatch { let neighbourhood_boundary = self .boundary_polygon .to_outline(Distance::meters(25.0)) @@ -68,13 +68,18 @@ impl RenderCells { } let boundary = PolyLine::unchecked_new(poly.clone().into_points()) - .make_polygons(Distance::meters(10.0)); + .make_polygons(Distance::meters(5.0)); + let color = if use_color { + cell_color.alpha(1.0).shade(0.2) + } else { + Color::BLACK + }; // If possible, try to erase where the cell boundary touches the perimeter road. if let Some(ref neighbourhood_boundary) = neighbourhood_boundary { - batch.extend(Color::BLACK, boundary.difference(neighbourhood_boundary)); + batch.extend(color, boundary.difference(neighbourhood_boundary)); } else { - batch.push(Color::BLACK, boundary); + batch.push(color, boundary); } } } @@ -320,15 +325,32 @@ fn color_cells(num_cells: usize, adjacencies: HashSet<(usize, usize)>) -> Vec