1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use crate::app::App;
use crate::colors::ColorScheme;
use crate::helpers::ID;
use crate::render::{DrawOptions, Renderable};
use ezgui::{Color, EventCtx, GeomBatch, GfxCtx, Line, Text};
use geom::Polygon;
use map_model::{Area, AreaID, AreaType, Map};
pub struct DrawArea {
pub id: AreaID,
}
impl DrawArea {
pub fn new(
ctx: &EventCtx,
area: &Area,
cs: &ColorScheme,
all_areas: &mut GeomBatch,
) -> DrawArea {
all_areas.push(DrawArea::color(area.area_type, cs), area.polygon.clone());
if false {
if let Some(name) = area.osm_tags.get("name") {
all_areas.append(
Text::from(Line(name).fg(Color::BLACK))
.render_to_batch(ctx.prerender)
.scale(1.0)
.centered_on(area.polygon.polylabel()),
);
}
}
DrawArea { id: area.id }
}
pub fn color(area_type: AreaType, cs: &ColorScheme) -> Color {
match area_type {
AreaType::Park => cs.grass,
AreaType::Water => cs.water,
AreaType::PedestrianIsland => Color::grey(0.3),
AreaType::Island => cs.map_background,
}
}
}
impl Renderable for DrawArea {
fn get_id(&self) -> ID {
ID::Area(self.id)
}
fn draw(&self, _: &mut GfxCtx, _: &App, _: &DrawOptions) {}
fn get_outline(&self, map: &Map) -> Polygon {
map.get_a(self.id).polygon.clone()
}
}