mirror of
https://github.com/a-b-street/abstreet.git
synced 2025-01-05 13:05:06 +03:00
new default color scheme to use different colors for cars
This commit is contained in:
parent
61ef9f0b33
commit
c4b0c12797
@ -184,3 +184,19 @@ pub fn rotating_color_map(idx: usize) -> Color {
|
|||||||
}
|
}
|
||||||
Color::BLACK
|
Color::BLACK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn rotating_color_agents(idx: usize) -> Color {
|
||||||
|
if idx % 5 == 0 {
|
||||||
|
return Color::CYAN;
|
||||||
|
}
|
||||||
|
if idx % 5 == 1 {
|
||||||
|
return Color::BLUE;
|
||||||
|
}
|
||||||
|
if idx % 5 == 2 {
|
||||||
|
return Color::GREEN;
|
||||||
|
}
|
||||||
|
if idx % 5 == 3 {
|
||||||
|
return Color::ORANGE;
|
||||||
|
}
|
||||||
|
Color::RED
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::common::ColorLegend;
|
use crate::common::ColorLegend;
|
||||||
use crate::helpers::{rotating_color, ColorScheme, ID};
|
use crate::helpers::{rotating_color, rotating_color_agents, ColorScheme, ID};
|
||||||
use crate::render::area::DrawArea;
|
use crate::render::area::DrawArea;
|
||||||
use crate::render::building::DrawBuilding;
|
use crate::render::building::DrawBuilding;
|
||||||
use crate::render::bus_stop::DrawBusStop;
|
use crate::render::bus_stop::DrawBusStop;
|
||||||
@ -385,6 +385,7 @@ fn osm_rank_to_color(cs: &ColorScheme, rank: usize) -> Color {
|
|||||||
// TODO ETA till goal...
|
// TODO ETA till goal...
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub enum AgentColorScheme {
|
pub enum AgentColorScheme {
|
||||||
|
ByID,
|
||||||
VehicleTypes,
|
VehicleTypes,
|
||||||
Delay,
|
Delay,
|
||||||
DistanceCrossedSoFar,
|
DistanceCrossedSoFar,
|
||||||
@ -396,7 +397,8 @@ impl Cloneable for AgentColorScheme {}
|
|||||||
impl AgentColorScheme {
|
impl AgentColorScheme {
|
||||||
pub fn unzoomed_color(self, agent: &UnzoomedAgent, cs: &ColorScheme) -> Color {
|
pub fn unzoomed_color(self, agent: &UnzoomedAgent, cs: &ColorScheme) -> Color {
|
||||||
match self {
|
match self {
|
||||||
AgentColorScheme::VehicleTypes => match agent.vehicle_type {
|
// ByID should just act like VehicleTypes unzoomed
|
||||||
|
AgentColorScheme::VehicleTypes | AgentColorScheme::ByID => match agent.vehicle_type {
|
||||||
Some(VehicleType::Car) => cs.get_def("unzoomed car", Color::RED.alpha(0.5)),
|
Some(VehicleType::Car) => cs.get_def("unzoomed car", Color::RED.alpha(0.5)),
|
||||||
Some(VehicleType::Bike) => cs.get_def("unzoomed bike", Color::GREEN.alpha(0.5)),
|
Some(VehicleType::Bike) => cs.get_def("unzoomed bike", Color::GREEN.alpha(0.5)),
|
||||||
Some(VehicleType::Bus) => cs.get_def("unzoomed bus", Color::BLUE.alpha(0.5)),
|
Some(VehicleType::Bus) => cs.get_def("unzoomed bus", Color::BLUE.alpha(0.5)),
|
||||||
@ -418,6 +420,7 @@ impl AgentColorScheme {
|
|||||||
|
|
||||||
pub fn zoomed_color_car(self, input: &DrawCarInput, cs: &ColorScheme) -> Color {
|
pub fn zoomed_color_car(self, input: &DrawCarInput, cs: &ColorScheme) -> Color {
|
||||||
match self {
|
match self {
|
||||||
|
AgentColorScheme::ByID => rotating_color_agents(input.id.0),
|
||||||
AgentColorScheme::VehicleTypes => {
|
AgentColorScheme::VehicleTypes => {
|
||||||
if input.id.1 == VehicleType::Bus {
|
if input.id.1 == VehicleType::Bus {
|
||||||
cs.get_def("bus", Color::rgb(50, 133, 117))
|
cs.get_def("bus", Color::rgb(50, 133, 117))
|
||||||
@ -434,6 +437,7 @@ impl AgentColorScheme {
|
|||||||
|
|
||||||
pub fn zoomed_color_bike(self, input: &DrawCarInput, cs: &ColorScheme) -> Color {
|
pub fn zoomed_color_bike(self, input: &DrawCarInput, cs: &ColorScheme) -> Color {
|
||||||
match self {
|
match self {
|
||||||
|
AgentColorScheme::ByID => rotating_color_agents(input.id.0),
|
||||||
AgentColorScheme::VehicleTypes => match input.status {
|
AgentColorScheme::VehicleTypes => match input.status {
|
||||||
// TODO Hard to see on the greenish bike lanes? :P
|
// TODO Hard to see on the greenish bike lanes? :P
|
||||||
CarStatus::Moving => cs.get_def("moving bike", Color::GREEN),
|
CarStatus::Moving => cs.get_def("moving bike", Color::GREEN),
|
||||||
@ -445,6 +449,7 @@ impl AgentColorScheme {
|
|||||||
|
|
||||||
pub fn zoomed_color_ped(self, input: &DrawPedestrianInput, cs: &ColorScheme) -> Color {
|
pub fn zoomed_color_ped(self, input: &DrawPedestrianInput, cs: &ColorScheme) -> Color {
|
||||||
match self {
|
match self {
|
||||||
|
AgentColorScheme::ByID => rotating_color_agents(input.id.0),
|
||||||
AgentColorScheme::VehicleTypes => {
|
AgentColorScheme::VehicleTypes => {
|
||||||
if input.preparing_bike {
|
if input.preparing_bike {
|
||||||
cs.get_def("pedestrian preparing bike", Color::rgb(255, 0, 144))
|
cs.get_def("pedestrian preparing bike", Color::rgb(255, 0, 144))
|
||||||
@ -458,7 +463,7 @@ impl AgentColorScheme {
|
|||||||
|
|
||||||
fn by_metadata(self, md: &AgentMetadata) -> Color {
|
fn by_metadata(self, md: &AgentMetadata) -> Color {
|
||||||
match self {
|
match self {
|
||||||
AgentColorScheme::VehicleTypes => unreachable!(),
|
AgentColorScheme::VehicleTypes | AgentColorScheme::ByID => unreachable!(),
|
||||||
AgentColorScheme::Delay => {
|
AgentColorScheme::Delay => {
|
||||||
if md.occupying_intersection && md.time_spent_blocked > Duration::minutes(1) {
|
if md.occupying_intersection && md.time_spent_blocked > Duration::minutes(1) {
|
||||||
Color::YELLOW
|
Color::YELLOW
|
||||||
@ -474,6 +479,9 @@ impl AgentColorScheme {
|
|||||||
// TODO Lots of duplicated values here. :\
|
// TODO Lots of duplicated values here. :\
|
||||||
pub fn make_color_legend(self, cs: &ColorScheme) -> ColorLegend {
|
pub fn make_color_legend(self, cs: &ColorScheme) -> ColorLegend {
|
||||||
match self {
|
match self {
|
||||||
|
AgentColorScheme::ByID => {
|
||||||
|
ColorLegend::new(Text::prompt("arbitrary colors by ID"), Vec::new())
|
||||||
|
}
|
||||||
AgentColorScheme::VehicleTypes => ColorLegend::new(
|
AgentColorScheme::VehicleTypes => ColorLegend::new(
|
||||||
Text::prompt("vehicle types"),
|
Text::prompt("vehicle types"),
|
||||||
vec![
|
vec![
|
||||||
|
@ -292,7 +292,7 @@ fn manage_acs(
|
|||||||
if !active_originally && menu.swap_action(show, hide, ctx) {
|
if !active_originally && menu.swap_action(show, hide, ctx) {
|
||||||
ui.agent_cs = acs;
|
ui.agent_cs = acs;
|
||||||
} else if active_originally && menu.swap_action(hide, show, ctx) {
|
} else if active_originally && menu.swap_action(hide, show, ctx) {
|
||||||
ui.agent_cs = AgentColorScheme::VehicleTypes;
|
ui.agent_cs = AgentColorScheme::ByID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ impl UI {
|
|||||||
primary,
|
primary,
|
||||||
secondary: None,
|
secondary: None,
|
||||||
cs,
|
cs,
|
||||||
agent_cs: AgentColorScheme::VehicleTypes,
|
agent_cs: AgentColorScheme::ByID,
|
||||||
opts,
|
opts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user