mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 16:36:02 +03:00
Improve the colors used for LTN cells as areas, and make that the
default again!
This commit is contained in:
parent
e51ebb970a
commit
ffa0781268
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Co
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(color) = available_colors.iter().position(|x| *x) {
|
||||
assigned_colors.push(color);
|
||||
} else {
|
||||
warn!("color_cells ran out of colors");
|
||||
assigned_colors.push(0);
|
||||
|
||||
// If there are multiple colors available, prefer one that hasn't been used anywhere yet.
|
||||
// Cells far apart shouldn't seem related to the user.
|
||||
let mut choice = None;
|
||||
let mut backup = None;
|
||||
for (idx, available) in available_colors.into_iter().enumerate() {
|
||||
if !available {
|
||||
continue;
|
||||
}
|
||||
if assigned_colors.iter().any(|x| *x == idx) {
|
||||
if backup.is_none() {
|
||||
backup = Some(idx);
|
||||
}
|
||||
} else {
|
||||
choice = Some(idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
assigned_colors.push(
|
||||
choice
|
||||
.or(backup)
|
||||
.unwrap_or_else(|| assigned_colors.len() % colors::CELLS.len()),
|
||||
);
|
||||
}
|
||||
assigned_colors
|
||||
.into_iter()
|
||||
.map(|idx| colors::CELLS[idx])
|
||||
.map(|idx| colors::CELLS[idx].alpha(0.8))
|
||||
.collect()
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ struct Args {
|
||||
|
||||
fn run(mut settings: Settings) {
|
||||
let mut opts = map_gui::options::Options::load_or_default();
|
||||
opts.color_scheme = map_gui::colors::ColorSchemeChoice::LTN;
|
||||
opts.color_scheme = map_gui::colors::ColorSchemeChoice::ClassicLTN;
|
||||
opts.show_building_driveways = false;
|
||||
// TODO Ideally we would have a better map model in the first place. The next best thing would
|
||||
// be to change these settings based on the map's country, but that's a bit tricky to do early
|
||||
@ -94,7 +94,7 @@ fn run(mut settings: Settings) {
|
||||
filter_type: FilterType::NoEntry,
|
||||
|
||||
draw_neighbourhood_style: browse::Style::Simple,
|
||||
draw_cells_as_areas: false,
|
||||
draw_cells_as_areas: true,
|
||||
heuristic: filters::auto::Heuristic::SplitCells,
|
||||
main_road_penalty: 1.0,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user