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
60
use crate::app::App;
use crate::colors::ColorScheme;
use crate::helpers::ID;
use crate::render::{DrawOptions, Renderable};
use geom::Polygon;
use map_model::{Area, AreaID, AreaType, Map};
use widgetry::{Color, EventCtx, Fill, GeomBatch, GfxCtx, Line, Text};
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::fill(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 fill(area_type: AreaType, cs: &ColorScheme) -> Fill {
match area_type {
AreaType::Park => cs.grass.clone(),
AreaType::Water => cs.water.clone(),
AreaType::PedestrianIsland => Color::grey(0.3).into(),
AreaType::Island => cs.map_background.clone(),
}
}
}
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()
}
}