mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 20:29:04 +03:00
better crosswalk rendering, and an overlay for finding bus lanes
This commit is contained in:
parent
965037ce77
commit
e6fcc50696
@ -1,21 +1,21 @@
|
||||
f3beb809b18a0212c447c77bde14fdb8 ../data/screenshots/pending_montlake/01x01_i19.png
|
||||
8a0c9c6df41226feb43624849fdc6741 ../data/screenshots/pending_montlake/02x01_i24.png
|
||||
d86d044c2c21ff07514cc11ec74dc882 ../data/screenshots/pending_montlake/03x01_i0.png
|
||||
292d9aa652779044d65980bc745fb305 ../data/screenshots/pending_montlake/01x02_i5.png
|
||||
32fe6088d0626aea9e2fdfddef6f4da5 ../data/screenshots/pending_montlake/01x01_i19.png
|
||||
13fd5fb8bf19120156418ac290d6ee4d ../data/screenshots/pending_montlake/02x01_i24.png
|
||||
99bdbb64f8f357eb9ecc49c0241efe67 ../data/screenshots/pending_montlake/03x01_i0.png
|
||||
abad174a1a96560ae30c2db15ab6c2cb ../data/screenshots/pending_montlake/01x02_i5.png
|
||||
a15c1c86d0b902b963abf828e5b63bd4 ../data/screenshots/pending_montlake/02x02_i9.png
|
||||
f6a9e460a3b5b0c92de62d224a42eb27 ../data/screenshots/pending_montlake/03x02_i8.png
|
||||
a7ba3f05074f0fcce44a9824eabcd2a5 ../data/screenshots/pending_montlake/01x03_i20.png
|
||||
17073779fee1db0091018f1fa3573d08 ../data/screenshots/pending_montlake/02x03_i71.png
|
||||
0c894a42fe55e6cbc11c49a2791fbcc5 ../data/screenshots/pending_montlake/03x03_i77.png
|
||||
b4e8ae13665cef5ce6fe57bc369856c0 ../data/screenshots/pending_montlake/01x04_i4.png
|
||||
530e570803b8b43f5a270abb610b3535 ../data/screenshots/pending_montlake/02x04_i1.png
|
||||
a20594d8ceb3f4514a7a39fee6c08cb4 ../data/screenshots/pending_montlake/03x04_i58.png
|
||||
59579782601879af6fe7d5ca9c6c3ca1 ../data/screenshots/pending_montlake/01x05_i31.png
|
||||
7c71292837ca8da42e74bc220ce72112 ../data/screenshots/pending_montlake/02x05_i25.png
|
||||
da515a2509fce1a87681f07e4261ac61 ../data/screenshots/pending_montlake/03x05_i65.png
|
||||
08511285b4662fca3aa16b0999c5af38 ../data/screenshots/pending_montlake/01x06_i40.png
|
||||
d58fd30efea902f77f0b24f3afdbe1af ../data/screenshots/pending_montlake/02x06_i124.png
|
||||
d76202bbaefddd15a3341e2cd66bef9e ../data/screenshots/pending_montlake/03x06_i2.png
|
||||
ba7a81928d5b5a15badab851b9202cde ../data/screenshots/pending_montlake/01x07_i26.png
|
||||
0762ca009fccaf3d30452c6d0e5571ac ../data/screenshots/pending_montlake/02x07_i85.png
|
||||
7bea327c422916af57b3b448fe9efeba ../data/screenshots/pending_montlake/03x07_i27.png
|
||||
8212df248d5a3cc957fb9f9ba3f0d615 ../data/screenshots/pending_montlake/03x02_i8.png
|
||||
e2347d5b9b240f14df5cb7a7b33a3fe3 ../data/screenshots/pending_montlake/01x03_i20.png
|
||||
5f64e71201de37ebd39d7e12a0f8dbfa ../data/screenshots/pending_montlake/02x03_i71.png
|
||||
6b7de9c100ca476a4aa2fe12830dd44a ../data/screenshots/pending_montlake/03x03_i77.png
|
||||
e62c06cbcc8b82714009fcc3360d5377 ../data/screenshots/pending_montlake/01x04_i4.png
|
||||
2d0ad4590f8ceeaf33f0d785bbcc4cd2 ../data/screenshots/pending_montlake/02x04_i1.png
|
||||
4a7d05e039eea28b7009d1e78203a3da ../data/screenshots/pending_montlake/03x04_i58.png
|
||||
a9eb423970fc9ec9029ce839b6d45913 ../data/screenshots/pending_montlake/01x05_i31.png
|
||||
bdc20ec3835d5ea97dfe876c7e91b409 ../data/screenshots/pending_montlake/02x05_i25.png
|
||||
765d355df2add3c3264c2c7a11c0c12d ../data/screenshots/pending_montlake/03x05_i65.png
|
||||
c74934011cc0a3edee1b0715a6c917b1 ../data/screenshots/pending_montlake/01x06_i40.png
|
||||
c4a802fcc9efb8a26652f3db55a89e62 ../data/screenshots/pending_montlake/02x06_i124.png
|
||||
0109c9ae20b1a1974d5bd4f8607634b2 ../data/screenshots/pending_montlake/03x06_i2.png
|
||||
a1af056db050da5fab430fc4758d611d ../data/screenshots/pending_montlake/01x07_i26.png
|
||||
052ee656b3064277306bce62239d9aa2 ../data/screenshots/pending_montlake/02x07_i85.png
|
||||
a9a97911411e5408655fb6301c859578 ../data/screenshots/pending_montlake/03x07_i27.png
|
||||
|
@ -294,7 +294,7 @@ fn make_octagon(center: Pt2D, radius: Distance, facing: Angle) -> Polygon {
|
||||
fn make_crosswalk(batch: &mut GeomBatch, turn: &Turn, cs: &ColorScheme) {
|
||||
// Start at least LANE_THICKNESS out to not hit sidewalk corners. Also account for the
|
||||
// thickness of the crosswalk line itself. Center the lines inside these two boundaries.
|
||||
let boundary = LANE_THICKNESS + CROSSWALK_LINE_THICKNESS;
|
||||
let boundary = LANE_THICKNESS;
|
||||
let tile_every = LANE_THICKNESS * 0.6;
|
||||
let line = {
|
||||
// The middle line in the crosswalk geometry is the main crossing line.
|
||||
@ -317,6 +317,16 @@ fn make_crosswalk(batch: &mut GeomBatch, turn: &Turn, cs: &ColorScheme) {
|
||||
perp_line(Line::new(pt1, pt2), LANE_THICKNESS)
|
||||
.make_polygons(CROSSWALK_LINE_THICKNESS),
|
||||
);
|
||||
|
||||
// Actually every line is a double
|
||||
let pt3 = line.dist_along(dist_along + 2.0 * CROSSWALK_LINE_THICKNESS);
|
||||
let pt4 = pt3.project_away(Distance::meters(1.0), turn.angle());
|
||||
batch.push(
|
||||
cs.get("crosswalk"),
|
||||
perp_line(Line::new(pt3, pt4), LANE_THICKNESS)
|
||||
.make_polygons(CROSSWALK_LINE_THICKNESS),
|
||||
);
|
||||
|
||||
dist_along += tile_every;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use crate::ui::{ShowEverything, UI};
|
||||
use abstutil::{prettyprint_usize, Counter};
|
||||
use ezgui::{Choice, Color, EventCtx, GfxCtx, Key, Line, MenuUnderButton, Text};
|
||||
use geom::Duration;
|
||||
use map_model::PathStep;
|
||||
use map_model::{LaneType, PathStep};
|
||||
use sim::{ParkingSpot, TripMode};
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
@ -22,6 +22,7 @@ pub enum Overlays {
|
||||
FinishedTrips(Duration, Plot<usize>),
|
||||
Chokepoints(Duration, ObjectColorer),
|
||||
BikeNetwork(RoadColorer),
|
||||
BusNetwork(RoadColorer),
|
||||
// Only set by certain gameplay modes
|
||||
BusRoute(ShowBusRoute),
|
||||
BusDelaysOverTime(Plot<Duration>),
|
||||
@ -48,6 +49,7 @@ impl Overlays {
|
||||
Choice::new("finished trips", ()).key(Key::F),
|
||||
Choice::new("chokepoints", ()).key(Key::C),
|
||||
Choice::new("bike network", ()).key(Key::B),
|
||||
Choice::new("bus network", ()).key(Key::U),
|
||||
]
|
||||
})?;
|
||||
Some(Transition::PopWithData(Box::new(move |state, ui, ctx| {
|
||||
@ -68,6 +70,7 @@ impl Overlays {
|
||||
Overlays::FinishedTrips(t, _) => ("finished trips", *t),
|
||||
Overlays::Chokepoints(t, _) => ("chokepoints", *t),
|
||||
Overlays::BikeNetwork(_) => ("bike network", ui.primary.sim.time()),
|
||||
Overlays::BusNetwork(_) => ("bus network", ui.primary.sim.time()),
|
||||
Overlays::BusRoute(_) | Overlays::BusDelaysOverTime(_) => {
|
||||
// The gameplay mode will update it.
|
||||
return None;
|
||||
@ -83,7 +86,9 @@ impl Overlays {
|
||||
pub fn draw(&self, g: &mut GfxCtx, ui: &UI) -> bool {
|
||||
match self {
|
||||
Overlays::Inactive => false,
|
||||
Overlays::ParkingAvailability(_, ref heatmap) | Overlays::BikeNetwork(ref heatmap) => {
|
||||
Overlays::ParkingAvailability(_, ref heatmap)
|
||||
| Overlays::BikeNetwork(ref heatmap)
|
||||
| Overlays::BusNetwork(ref heatmap) => {
|
||||
heatmap.draw(g, ui);
|
||||
true
|
||||
}
|
||||
@ -134,6 +139,7 @@ impl Overlays {
|
||||
"finished trips" => Overlays::FinishedTrips(time, trip_stats(ui, ctx)),
|
||||
"chokepoints" => Overlays::Chokepoints(time, calculate_chokepoints(ctx, ui)),
|
||||
"bike network" => Overlays::BikeNetwork(calculate_bike_network(ctx, ui)),
|
||||
"bus network" => Overlays::BusNetwork(calculate_bus_network(ctx, ui)),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@ -346,6 +352,19 @@ fn calculate_bike_network(ctx: &mut EventCtx, ui: &UI) -> RoadColorer {
|
||||
colorer.build(ctx, &ui.primary.map)
|
||||
}
|
||||
|
||||
fn calculate_bus_network(ctx: &mut EventCtx, ui: &UI) -> RoadColorer {
|
||||
let mut colorer = RoadColorerBuilder::new(
|
||||
Text::prompt("bus networks"),
|
||||
vec![("bike lanes", Color::GREEN)],
|
||||
);
|
||||
for l in ui.primary.map.all_lanes() {
|
||||
if l.lane_type == LaneType::Bus {
|
||||
colorer.add(l.id, Color::GREEN, &ui.primary.map);
|
||||
}
|
||||
}
|
||||
colorer.build(ctx, &ui.primary.map)
|
||||
}
|
||||
|
||||
fn trip_stats(ui: &UI, ctx: &mut EventCtx) -> Plot<usize> {
|
||||
let lines: Vec<(&str, Color, Option<TripMode>)> = vec![
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user