draw thick border around buildings

This commit is contained in:
Dustin Carlino 2018-08-02 12:35:58 -07:00
parent d47912e13c
commit 73eaf4818f
6 changed files with 32 additions and 10 deletions

View File

@ -120,6 +120,12 @@
0.8,
1.0
],
"BuildingBoundary": [
0.0,
0.395,
0.0,
1.0
],
"ParcelBoundary": [
0.3,
0.3,

View File

@ -32,6 +32,7 @@ pub enum Colors {
ConflictingTurn,
Building,
BuildingPath,
BuildingBoundary,
ParcelBoundary,
ParcelInterior,
RoadOrientation,

View File

@ -45,7 +45,7 @@ impl Validator {
objects.push((ID::Intersection(i.id), vec![make_poly(&i.polygon)]));
}
for b in &draw_map.buildings {
objects.push((ID::Building(b.id), vec![make_poly(&b.polygon)]));
objects.push((ID::Building(b.id), vec![make_poly(&b.fill_polygon)]));
}
for p in &draw_map.parcels {
objects.push((ID::Parcel(p.id), vec![make_poly(&p.fill_polygon)]));

View File

@ -159,8 +159,7 @@ impl SelectionState {
},
}
}
// TODO tmp
draw_map.get_l(id).draw_debug(g, cs, map.get_l(id));
//draw_map.get_l(id).draw_debug(g, cs, map.get_l(id));
}
SelectionState::TooltipLane(id) => {
canvas.draw_mouse_tooltip(g, &draw_map.get_l(id).tooltip_lines(map));

View File

@ -2,18 +2,22 @@
use aabb_quadtree::geom::Rect;
use ezgui::GfxCtx;
use geom::PolyLine;
use graphics;
use graphics::math::Vec2d;
use graphics::types::Color;
use map_model;
use map_model::geometry;
use map_model::{BuildingID, Map};
use render::PARCEL_BOUNDARY_THICKNESS;
use std::f64;
#[derive(Debug)]
pub struct DrawBuilding {
pub id: BuildingID,
pub polygon: Vec<Vec2d>,
// TODO should just have one. use graphics::Line for now.
boundary_polygons: Vec<Vec<Vec2d>>,
pub fill_polygon: Vec<Vec2d>,
front_path: Option<[f64; 4]>,
}
@ -26,22 +30,33 @@ impl DrawBuilding {
front_path: bldg.front_path
.as_ref()
.map(|l| [l.pt1().x(), l.pt1().y(), l.pt2().x(), l.pt2().y()]),
polygon: pts,
fill_polygon: pts,
boundary_polygons: PolyLine::new(bldg.points.clone())
.make_polygons_blindly(PARCEL_BOUNDARY_THICKNESS),
}
}
// TODO it'd be cool to draw a thick border. how to expand a polygon?
pub fn draw(&self, g: &mut GfxCtx, fill_color: Color, path_color: Color) {
pub fn draw(
&self,
g: &mut GfxCtx,
fill_color: Color,
path_color: Color,
boundary_color: Color,
) {
if let Some(line) = self.front_path {
// TODO tune width
g.draw_line(&graphics::Line::new_round(path_color, 1.0), line);
}
g.draw_polygon(fill_color, &self.polygon);
for p in &self.boundary_polygons {
g.draw_polygon(boundary_color, p);
}
// TODO the triangulation seems messed up. ><
g.draw_polygon(fill_color, &self.fill_polygon);
}
pub fn contains_pt(&self, x: f64, y: f64) -> bool {
geometry::point_in_polygon(x, y, &self.polygon)
geometry::point_in_polygon(x, y, &self.fill_polygon)
}
pub fn tooltip_lines(&self, map: &Map) -> Vec<String> {
@ -57,7 +72,7 @@ impl DrawBuilding {
}
pub fn get_bbox(&self) -> Rect {
let mut polygons = vec![self.polygon.clone()];
let mut polygons = vec![self.fill_polygon.clone()];
if let Some(line) = self.front_path {
polygons.push(vec![[line[0], line[1]], [line[2], line[3]]]);
}

View File

@ -578,6 +578,7 @@ impl gui::GUI for UI {
g,
self.color_building(b.id),
self.cs.get(Colors::BuildingPath),
self.cs.get(Colors::BuildingBoundary),
);
}
}