mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-27 00:12:55 +03:00
switch traffic lights to a yellow light for the last 5s
This commit is contained in:
parent
6ae43fb038
commit
81ff8e7686
@ -40,11 +40,12 @@ pub fn draw_signal_phase(
|
||||
}
|
||||
}
|
||||
|
||||
let percent = if let Some(t) = time_left {
|
||||
(t / phase.duration) as f32
|
||||
let (yellow_light, percent) = if let Some(t) = time_left {
|
||||
(t <= Duration::seconds(5.0), (t / phase.duration) as f32)
|
||||
} else {
|
||||
1.0
|
||||
(false, 1.0)
|
||||
};
|
||||
let yellow = Color::YELLOW;
|
||||
for g in &phase.protected_groups {
|
||||
if !g.crosswalk {
|
||||
let slice_start = if crossed_roads.contains(&(g.from.id, g.parent)) {
|
||||
@ -60,7 +61,11 @@ pub fn draw_signal_phase(
|
||||
|
||||
let pl = &signal.turn_groups[g].geom;
|
||||
batch.push(
|
||||
protected_color.alpha(percent),
|
||||
if yellow_light {
|
||||
yellow
|
||||
} else {
|
||||
protected_color.alpha(percent)
|
||||
},
|
||||
pl.exact_slice(slice_start, pl.length() - slice_end)
|
||||
.make_arrow(BIG_ARROW_THICKNESS, ArrowCap::Triangle)
|
||||
.unwrap(),
|
||||
@ -87,7 +92,7 @@ pub fn draw_signal_phase(
|
||||
center,
|
||||
0.07,
|
||||
angle,
|
||||
RewriteColor::ChangeAlpha(percent),
|
||||
RewriteColor::NoOp,
|
||||
true,
|
||||
);
|
||||
}
|
||||
@ -95,7 +100,7 @@ pub fn draw_signal_phase(
|
||||
assert!(!g.crosswalk);
|
||||
let pl = &signal.turn_groups[g].geom;
|
||||
batch.extend(
|
||||
Color::BLACK.alpha(percent),
|
||||
Color::BLACK,
|
||||
pl.exact_slice(
|
||||
SIDEWALK_THICKNESS - Distance::meters(0.1),
|
||||
pl.length() - SIDEWALK_THICKNESS + Distance::meters(0.1),
|
||||
@ -108,7 +113,11 @@ pub fn draw_signal_phase(
|
||||
),
|
||||
);
|
||||
batch.extend(
|
||||
protected_color.alpha(percent),
|
||||
if yellow_light {
|
||||
yellow
|
||||
} else {
|
||||
protected_color.alpha(percent)
|
||||
},
|
||||
pl.exact_slice(SIDEWALK_THICKNESS, pl.length() - SIDEWALK_THICKNESS)
|
||||
.dashed_arrow(
|
||||
BIG_ARROW_THICKNESS / 2.0,
|
||||
|
Loading…
Reference in New Issue
Block a user