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 {
|
let (yellow_light, percent) = if let Some(t) = time_left {
|
||||||
(t / phase.duration) as f32
|
(t <= Duration::seconds(5.0), (t / phase.duration) as f32)
|
||||||
} else {
|
} else {
|
||||||
1.0
|
(false, 1.0)
|
||||||
};
|
};
|
||||||
|
let yellow = Color::YELLOW;
|
||||||
for g in &phase.protected_groups {
|
for g in &phase.protected_groups {
|
||||||
if !g.crosswalk {
|
if !g.crosswalk {
|
||||||
let slice_start = if crossed_roads.contains(&(g.from.id, g.parent)) {
|
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;
|
let pl = &signal.turn_groups[g].geom;
|
||||||
batch.push(
|
batch.push(
|
||||||
protected_color.alpha(percent),
|
if yellow_light {
|
||||||
|
yellow
|
||||||
|
} else {
|
||||||
|
protected_color.alpha(percent)
|
||||||
|
},
|
||||||
pl.exact_slice(slice_start, pl.length() - slice_end)
|
pl.exact_slice(slice_start, pl.length() - slice_end)
|
||||||
.make_arrow(BIG_ARROW_THICKNESS, ArrowCap::Triangle)
|
.make_arrow(BIG_ARROW_THICKNESS, ArrowCap::Triangle)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
@ -87,7 +92,7 @@ pub fn draw_signal_phase(
|
|||||||
center,
|
center,
|
||||||
0.07,
|
0.07,
|
||||||
angle,
|
angle,
|
||||||
RewriteColor::ChangeAlpha(percent),
|
RewriteColor::NoOp,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -95,7 +100,7 @@ pub fn draw_signal_phase(
|
|||||||
assert!(!g.crosswalk);
|
assert!(!g.crosswalk);
|
||||||
let pl = &signal.turn_groups[g].geom;
|
let pl = &signal.turn_groups[g].geom;
|
||||||
batch.extend(
|
batch.extend(
|
||||||
Color::BLACK.alpha(percent),
|
Color::BLACK,
|
||||||
pl.exact_slice(
|
pl.exact_slice(
|
||||||
SIDEWALK_THICKNESS - Distance::meters(0.1),
|
SIDEWALK_THICKNESS - Distance::meters(0.1),
|
||||||
pl.length() - 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(
|
batch.extend(
|
||||||
protected_color.alpha(percent),
|
if yellow_light {
|
||||||
|
yellow
|
||||||
|
} else {
|
||||||
|
protected_color.alpha(percent)
|
||||||
|
},
|
||||||
pl.exact_slice(SIDEWALK_THICKNESS, pl.length() - SIDEWALK_THICKNESS)
|
pl.exact_slice(SIDEWALK_THICKNESS, pl.length() - SIDEWALK_THICKNESS)
|
||||||
.dashed_arrow(
|
.dashed_arrow(
|
||||||
BIG_ARROW_THICKNESS / 2.0,
|
BIG_ARROW_THICKNESS / 2.0,
|
||||||
|
Loading…
Reference in New Issue
Block a user