fifteen_min/
render.rs

1use map_model::{Building, LaneType};
2use widgetry::{Color, Drawable, EventCtx, GeomBatch, RewriteColor};
3
4use crate::isochrone::MovementOptions;
5use crate::App;
6
7pub fn draw_star(ctx: &mut EventCtx, b: &Building) -> GeomBatch {
8    GeomBatch::load_svg(ctx, "system/assets/tools/star.svg")
9        .centered_on(b.polygon.center())
10        .color(RewriteColor::ChangeAll(Color::BLACK))
11}
12
13pub fn draw_unwalkable_roads(ctx: &mut EventCtx, app: &App) -> Drawable {
14    let allow_shoulders = match app.session.movement {
15        MovementOptions::Walking(ref opts) => opts.allow_shoulders,
16        MovementOptions::Biking => {
17            return Drawable::empty(ctx);
18        }
19    };
20
21    let mut batch = GeomBatch::new();
22    'ROADS: for road in app.map.all_roads() {
23        if road.is_light_rail() {
24            continue;
25        }
26        for l in &road.lanes {
27            if l.lane_type == LaneType::Sidewalk
28                || l.lane_type == LaneType::Footway
29                || l.lane_type == LaneType::SharedUse
30                || (l.lane_type == LaneType::Shoulder && allow_shoulders)
31            {
32                continue 'ROADS;
33            }
34        }
35        // TODO Skip highways
36        batch.push(Color::BLUE.alpha(0.5), road.get_thick_polygon());
37    }
38    ctx.upload(batch)
39}