mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 11:44:25 +03:00
draw thick border around buildings
This commit is contained in:
parent
d47912e13c
commit
73eaf4818f
@ -120,6 +120,12 @@
|
||||
0.8,
|
||||
1.0
|
||||
],
|
||||
"BuildingBoundary": [
|
||||
0.0,
|
||||
0.395,
|
||||
0.0,
|
||||
1.0
|
||||
],
|
||||
"ParcelBoundary": [
|
||||
0.3,
|
||||
0.3,
|
||||
|
@ -32,6 +32,7 @@ pub enum Colors {
|
||||
ConflictingTurn,
|
||||
Building,
|
||||
BuildingPath,
|
||||
BuildingBoundary,
|
||||
ParcelBoundary,
|
||||
ParcelInterior,
|
||||
RoadOrientation,
|
||||
|
@ -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)]));
|
||||
|
@ -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));
|
||||
|
@ -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]]]);
|
||||
}
|
||||
|
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user