mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-26 07:52:05 +03:00
show signal yield turns as outlines, not dashes
This commit is contained in:
parent
bb2ce2c2f5
commit
113aa99b47
@ -229,7 +229,7 @@ pub fn draw_signal_cycle(
|
||||
&& turn.turn_type != TurnType::LaneChangeLeft
|
||||
&& turn.turn_type != TurnType::LaneChangeRight
|
||||
{
|
||||
DrawTurn::draw_dashed(turn, g, yield_color);
|
||||
DrawTurn::draw_outline(turn, g, yield_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,16 @@ impl DrawTurn {
|
||||
g.draw_arrow(color, BIG_ARROW_THICKNESS, &arrow_line);
|
||||
}
|
||||
|
||||
pub fn draw_outline(turn: &Turn, g: &mut GfxCtx, color: Color) {
|
||||
g.draw_polygons(
|
||||
color,
|
||||
&turn
|
||||
.geom
|
||||
.make_arrow_outline(BIG_ARROW_THICKNESS * 2.0, BIG_ARROW_THICKNESS / 2.0)
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn draw(&self, g: &mut GfxCtx, cs: &ColorScheme, arrow_color: Color) {
|
||||
g.draw_circle(
|
||||
cs.get_def("turn icon circle", Color::grey(0.6)),
|
||||
|
@ -421,6 +421,53 @@ impl PolyLine {
|
||||
])
|
||||
}
|
||||
|
||||
// TODO Refactor
|
||||
pub fn make_arrow_outline(
|
||||
&self,
|
||||
arrow_thickness: Distance,
|
||||
outline_thickness: Distance,
|
||||
) -> Warn<Vec<Polygon>> {
|
||||
let head_size = arrow_thickness * 2.0;
|
||||
let triangle_height = head_size / 2.0_f64.sqrt();
|
||||
|
||||
if self.length() < triangle_height {
|
||||
return Warn::warn(
|
||||
vec![self.make_polygons(arrow_thickness)],
|
||||
format!(
|
||||
"Can't make_arrow of thickness {} for {}",
|
||||
arrow_thickness, self
|
||||
),
|
||||
);
|
||||
}
|
||||
let slice = self.exact_slice(Distance::ZERO, self.length() - triangle_height);
|
||||
|
||||
if let Some(p) = slice.to_thick_boundary(arrow_thickness, outline_thickness) {
|
||||
let angle = slice.last_pt().angle_to(self.last_pt());
|
||||
Warn::ok(vec![
|
||||
p,
|
||||
PolyLine::make_polygons_for_boundary(
|
||||
vec![
|
||||
self.last_pt(),
|
||||
self.last_pt()
|
||||
.project_away(head_size, angle.rotate_degs(-135.0)),
|
||||
self.last_pt()
|
||||
.project_away(head_size, angle.rotate_degs(135.0)),
|
||||
self.last_pt(),
|
||||
],
|
||||
outline_thickness,
|
||||
),
|
||||
])
|
||||
} else {
|
||||
return Warn::warn(
|
||||
vec![self.make_polygons(arrow_thickness)],
|
||||
format!(
|
||||
"Can't make_arrow_outline of outline_thickness {} for {}",
|
||||
outline_thickness, self
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Also return the angle of the line where the hit was found
|
||||
// TODO Also return distance along self of the hit
|
||||
pub fn intersection(&self, other: &PolyLine) -> Option<(Pt2D, Angle)> {
|
||||
|
Loading…
Reference in New Issue
Block a user