2020-04-05 04:13:45 +03:00
|
|
|
use ezgui::{Choice, Color};
|
2020-04-04 20:16:18 +03:00
|
|
|
|
|
|
|
// I've gone back and forth how to organize color scheme code. I was previously against having one
|
|
|
|
// centralized place with all definitions, because careful naming or comments are needed to explain
|
|
|
|
// the context of a definition. That's unnecessary when the color is defined in the one place it's
|
|
|
|
// used. But that was before we started consolidating the color palette in designs, and before we
|
|
|
|
// started rapidly iterating on totally different schemes.
|
|
|
|
//
|
|
|
|
// For the record, the compiler catches typos with this approach, but I don't think I had a single
|
|
|
|
// bug that took more than 30s to catch and fix in ~1.5 years of the untyped string key. ;)
|
2020-04-05 00:29:45 +03:00
|
|
|
//
|
|
|
|
// TODO There are plenty of colors left that aren't captured here. :(
|
2020-04-04 20:16:18 +03:00
|
|
|
|
2020-04-05 00:29:45 +03:00
|
|
|
#[derive(Clone, Copy, PartialEq)]
|
|
|
|
pub enum ColorSchemeChoice {
|
|
|
|
Standard,
|
|
|
|
NightMode,
|
2020-04-05 04:13:45 +03:00
|
|
|
SAMGreenDay,
|
|
|
|
SAMDesertDay,
|
|
|
|
BAP,
|
|
|
|
OSM,
|
2020-04-05 04:28:30 +03:00
|
|
|
Starcat,
|
2020-04-05 04:13:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ColorSchemeChoice {
|
|
|
|
pub fn choices() -> Vec<Choice<ColorSchemeChoice>> {
|
|
|
|
vec![
|
|
|
|
Choice::new("default", ColorSchemeChoice::Standard),
|
|
|
|
Choice::new("night mode", ColorSchemeChoice::NightMode),
|
|
|
|
Choice::new("sam green day", ColorSchemeChoice::SAMGreenDay),
|
|
|
|
Choice::new("sam desert day", ColorSchemeChoice::SAMDesertDay),
|
|
|
|
Choice::new("bap", ColorSchemeChoice::BAP),
|
|
|
|
Choice::new("osm", ColorSchemeChoice::OSM),
|
2020-04-05 04:28:30 +03:00
|
|
|
Choice::new("starcat", ColorSchemeChoice::Starcat),
|
2020-04-05 04:13:45 +03:00
|
|
|
]
|
|
|
|
}
|
2020-04-05 00:29:45 +03:00
|
|
|
}
|
2020-04-04 20:16:18 +03:00
|
|
|
|
2020-04-05 00:29:45 +03:00
|
|
|
pub struct ColorScheme {
|
2020-04-04 20:16:18 +03:00
|
|
|
// UI. TODO Share with ezgui.
|
|
|
|
pub hovering: Color,
|
|
|
|
pub panel_bg: Color,
|
|
|
|
pub section_bg: Color,
|
|
|
|
pub inner_panel: Color,
|
2020-04-05 00:15:34 +03:00
|
|
|
pub day_time_slider: Color,
|
|
|
|
pub night_time_slider: Color,
|
|
|
|
pub selected: Color,
|
|
|
|
pub current_object: Color,
|
|
|
|
pub perma_selected_object: Color,
|
|
|
|
pub bottom_bar_id: Color,
|
|
|
|
pub bottom_bar_name: Color,
|
2020-04-05 03:03:26 +03:00
|
|
|
pub fade_map_dark: Color,
|
2020-04-04 20:59:51 +03:00
|
|
|
|
|
|
|
// Roads
|
|
|
|
pub driving_lane: Color,
|
|
|
|
pub bus_lane: Color,
|
|
|
|
pub parking_lane: Color,
|
|
|
|
pub bike_lane: Color,
|
|
|
|
pub under_construction: Color,
|
|
|
|
pub sidewalk: Color,
|
|
|
|
pub sidewalk_lines: Color,
|
|
|
|
pub general_road_marking: Color,
|
|
|
|
pub road_center_line: Color,
|
2020-04-05 00:29:45 +03:00
|
|
|
pub unzoomed_highway: Color,
|
|
|
|
pub unzoomed_arterial: Color,
|
|
|
|
pub unzoomed_residential: Color,
|
2020-04-04 20:59:51 +03:00
|
|
|
|
|
|
|
// Intersections
|
|
|
|
pub border_intersection: Color,
|
|
|
|
pub border_arrow: Color,
|
|
|
|
pub normal_intersection: Color,
|
|
|
|
pub stop_sign: Color,
|
|
|
|
pub stop_sign_pole: Color,
|
2020-04-05 00:15:34 +03:00
|
|
|
pub signal_protected_turn: Color,
|
|
|
|
pub signal_permitted_turn: Color,
|
|
|
|
pub signal_permitted_turn_outline: Color,
|
|
|
|
pub signal_banned_turn: Color,
|
|
|
|
pub signal_box: Color,
|
|
|
|
pub signal_spinner: Color,
|
|
|
|
pub signal_turn_block_bg: Color,
|
|
|
|
|
|
|
|
// Other static elements
|
|
|
|
pub void_background: Color,
|
2020-04-04 20:59:51 +03:00
|
|
|
pub map_background: Color,
|
|
|
|
pub unzoomed_interesting_intersection: Color,
|
2020-04-05 00:15:34 +03:00
|
|
|
pub building: Color,
|
|
|
|
pub grass: Color,
|
|
|
|
pub water: Color,
|
|
|
|
pub bus_stop: Color,
|
|
|
|
pub extra_gis_shape: Color,
|
2020-04-04 20:59:51 +03:00
|
|
|
|
|
|
|
// Unzoomed dynamic elements
|
|
|
|
pub unzoomed_car: Color,
|
|
|
|
pub unzoomed_bike: Color,
|
|
|
|
pub unzoomed_bus: Color,
|
|
|
|
pub unzoomed_pedestrian: Color,
|
|
|
|
|
2020-04-05 00:15:34 +03:00
|
|
|
// Agents
|
2020-04-05 04:13:45 +03:00
|
|
|
agent_colors: Vec<Color>,
|
2020-04-04 20:59:51 +03:00
|
|
|
pub route: Color,
|
|
|
|
pub turn_arrow: Color,
|
|
|
|
pub brake_light: Color,
|
|
|
|
pub bus_body: Color,
|
|
|
|
pub bus_label: Color,
|
2020-04-05 00:15:34 +03:00
|
|
|
pub ped_head: Color,
|
|
|
|
pub ped_foot: Color,
|
|
|
|
pub ped_preparing_bike_body: Color,
|
|
|
|
pub ped_crowd: Color,
|
|
|
|
pub bike_frame: Color,
|
|
|
|
|
|
|
|
// Misc
|
|
|
|
pub associated_object: Color,
|
|
|
|
pub parking_trip: Color,
|
2020-04-04 20:16:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ColorScheme {
|
2020-04-05 00:29:45 +03:00
|
|
|
pub fn new(scheme: ColorSchemeChoice) -> ColorScheme {
|
|
|
|
match scheme {
|
|
|
|
ColorSchemeChoice::Standard => ColorScheme::standard(),
|
|
|
|
ColorSchemeChoice::NightMode => ColorScheme::night_mode(),
|
2020-04-05 04:13:45 +03:00
|
|
|
ColorSchemeChoice::SAMGreenDay => ColorScheme::sam_green_day(),
|
|
|
|
ColorSchemeChoice::SAMDesertDay => ColorScheme::sam_desert_day(),
|
|
|
|
ColorSchemeChoice::BAP => ColorScheme::bap(),
|
|
|
|
ColorSchemeChoice::OSM => ColorScheme::osm(),
|
2020-04-05 04:28:30 +03:00
|
|
|
ColorSchemeChoice::Starcat => ColorScheme::starcat(),
|
2020-04-05 00:29:45 +03:00
|
|
|
}
|
|
|
|
}
|
2020-04-04 20:16:18 +03:00
|
|
|
|
2020-04-05 00:29:45 +03:00
|
|
|
fn standard() -> ColorScheme {
|
|
|
|
ColorScheme {
|
2020-04-04 20:59:51 +03:00
|
|
|
// UI
|
2020-04-04 20:16:18 +03:00
|
|
|
hovering: Color::ORANGE,
|
|
|
|
panel_bg: Color::grey(0.4),
|
|
|
|
section_bg: Color::grey(0.5),
|
2020-04-05 04:13:45 +03:00
|
|
|
inner_panel: hex("#4C4C4C"),
|
|
|
|
day_time_slider: hex("#F4DA22"),
|
|
|
|
night_time_slider: hex("#12409D"),
|
2020-04-05 00:15:34 +03:00
|
|
|
selected: Color::RED.alpha(0.7),
|
|
|
|
current_object: Color::WHITE,
|
|
|
|
perma_selected_object: Color::BLUE,
|
|
|
|
bottom_bar_id: Color::RED,
|
|
|
|
bottom_bar_name: Color::CYAN,
|
2020-04-05 03:03:26 +03:00
|
|
|
fade_map_dark: Color::BLACK.alpha(0.6),
|
2020-04-04 20:59:51 +03:00
|
|
|
|
|
|
|
// Roads
|
|
|
|
driving_lane: Color::BLACK,
|
|
|
|
bus_lane: Color::rgb(190, 74, 76),
|
|
|
|
parking_lane: Color::grey(0.2),
|
|
|
|
bike_lane: Color::rgb(15, 125, 75),
|
|
|
|
under_construction: Color::rgb(255, 109, 0),
|
|
|
|
sidewalk: Color::grey(0.8),
|
|
|
|
sidewalk_lines: Color::grey(0.7),
|
|
|
|
general_road_marking: Color::WHITE,
|
|
|
|
road_center_line: Color::YELLOW,
|
2020-04-05 00:29:45 +03:00
|
|
|
unzoomed_highway: Color::rgb(232, 146, 162),
|
|
|
|
unzoomed_arterial: Color::rgb(255, 199, 62),
|
|
|
|
unzoomed_residential: Color::WHITE,
|
2020-04-04 20:59:51 +03:00
|
|
|
|
|
|
|
// Intersections
|
|
|
|
border_intersection: Color::rgb(50, 205, 50),
|
|
|
|
border_arrow: Color::PURPLE,
|
|
|
|
normal_intersection: Color::grey(0.2),
|
|
|
|
stop_sign: Color::RED,
|
|
|
|
stop_sign_pole: Color::grey(0.5),
|
2020-04-05 04:13:45 +03:00
|
|
|
signal_protected_turn: hex("#72CE36"),
|
2020-04-05 00:15:34 +03:00
|
|
|
signal_permitted_turn: Color::rgba(76, 167, 233, 0.3),
|
2020-04-05 04:13:45 +03:00
|
|
|
signal_permitted_turn_outline: hex("#4CA7E9"),
|
2020-04-05 00:15:34 +03:00
|
|
|
signal_banned_turn: Color::BLACK,
|
|
|
|
signal_box: Color::grey(0.5),
|
2020-04-05 04:13:45 +03:00
|
|
|
signal_spinner: hex("#F2994A"),
|
2020-04-05 00:15:34 +03:00
|
|
|
signal_turn_block_bg: Color::grey(0.6),
|
|
|
|
|
|
|
|
// Other static elements
|
|
|
|
void_background: Color::BLACK,
|
2020-04-04 20:59:51 +03:00
|
|
|
map_background: Color::grey(0.87),
|
|
|
|
unzoomed_interesting_intersection: Color::BLACK,
|
2020-04-05 00:15:34 +03:00
|
|
|
building: Color::rgb(196, 193, 188),
|
2020-04-05 04:13:45 +03:00
|
|
|
grass: hex("#94C84A"),
|
2020-04-05 00:15:34 +03:00
|
|
|
water: Color::rgb(164, 200, 234),
|
|
|
|
bus_stop: Color::CYAN,
|
|
|
|
extra_gis_shape: Color::RED.alpha(0.5),
|
2020-04-04 20:59:51 +03:00
|
|
|
|
|
|
|
// Unzoomed dynamic elements
|
2020-04-05 04:13:45 +03:00
|
|
|
unzoomed_car: hex("#A32015"),
|
|
|
|
unzoomed_bike: hex("#5D9630"),
|
|
|
|
unzoomed_bus: hex("#12409D"),
|
|
|
|
unzoomed_pedestrian: hex("#DF8C3D"),
|
2020-04-04 20:59:51 +03:00
|
|
|
|
|
|
|
// Agents
|
2020-04-05 04:13:45 +03:00
|
|
|
agent_colors: vec![
|
|
|
|
hex("#5C45A0"),
|
|
|
|
hex("#3E8BC3"),
|
|
|
|
hex("#E1BA13"),
|
|
|
|
hex("#96322F"),
|
|
|
|
hex("#00A27B"),
|
|
|
|
],
|
2020-04-04 20:59:51 +03:00
|
|
|
route: Color::ORANGE.alpha(0.5),
|
2020-04-05 04:13:45 +03:00
|
|
|
turn_arrow: hex("#DF8C3D"),
|
|
|
|
brake_light: hex("#FF1300"),
|
2020-04-04 20:59:51 +03:00
|
|
|
bus_body: Color::rgb(50, 133, 117),
|
|
|
|
bus_label: Color::rgb(249, 206, 24),
|
2020-04-05 00:15:34 +03:00
|
|
|
ped_head: Color::rgb(139, 69, 19),
|
|
|
|
ped_foot: Color::BLACK,
|
|
|
|
ped_preparing_bike_body: Color::rgb(255, 0, 144),
|
|
|
|
ped_crowd: Color::rgb_f(0.2, 0.7, 0.7),
|
|
|
|
bike_frame: Color::rgb(0, 128, 128),
|
|
|
|
|
|
|
|
// Misc
|
|
|
|
associated_object: Color::PURPLE,
|
2020-04-05 04:13:45 +03:00
|
|
|
parking_trip: hex("#4E30A6"),
|
2020-04-04 20:16:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-05 04:28:30 +03:00
|
|
|
pub fn rotating_color_plot(&self, idx: usize) -> Color {
|
2020-04-04 20:16:18 +03:00
|
|
|
modulo_color(
|
2020-04-05 04:13:45 +03:00
|
|
|
&vec![
|
2020-04-04 20:16:18 +03:00
|
|
|
Color::RED,
|
|
|
|
Color::BLUE,
|
|
|
|
Color::GREEN,
|
|
|
|
Color::PURPLE,
|
|
|
|
Color::BLACK,
|
|
|
|
],
|
|
|
|
idx,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn rotating_color_agents(&self, idx: usize) -> Color {
|
2020-04-05 04:13:45 +03:00
|
|
|
modulo_color(&self.agent_colors, idx)
|
2020-04-04 20:16:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-05 04:13:45 +03:00
|
|
|
fn modulo_color(colors: &Vec<Color>, idx: usize) -> Color {
|
2020-04-04 20:16:18 +03:00
|
|
|
colors[idx % colors.len()]
|
|
|
|
}
|
2020-04-05 04:13:45 +03:00
|
|
|
|
|
|
|
// Convenience
|
|
|
|
fn hex(x: &str) -> Color {
|
|
|
|
Color::hex(x)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Alternate, in-progress schemes
|
|
|
|
impl ColorScheme {
|
|
|
|
fn night_mode() -> ColorScheme {
|
|
|
|
let mut cs = ColorScheme::standard();
|
|
|
|
cs.building = hex("#42208B");
|
|
|
|
cs.sidewalk = hex("#7C55C8");
|
|
|
|
cs.grass = hex("#063D88");
|
|
|
|
cs.map_background = hex("#070747");
|
|
|
|
cs.unzoomed_arterial = hex("#54247A");
|
|
|
|
cs.unzoomed_highway = hex("#DD1F7F");
|
|
|
|
cs.unzoomed_residential = hex("#4D51AC");
|
|
|
|
cs.water = hex("#2A43AA");
|
|
|
|
cs
|
|
|
|
}
|
|
|
|
|
|
|
|
fn sam_green_day() -> ColorScheme {
|
|
|
|
let mut cs = ColorScheme::standard();
|
|
|
|
cs.map_background = hex("#CFE2C4");
|
|
|
|
cs.water = hex("#B4D3E5");
|
|
|
|
cs.driving_lane = hex("#C6CDD5");
|
|
|
|
cs.building = hex("#CCD4BD");
|
|
|
|
cs.sidewalk = hex("#98A1AA");
|
|
|
|
cs
|
|
|
|
}
|
|
|
|
|
|
|
|
fn sam_desert_day() -> ColorScheme {
|
|
|
|
let mut cs = ColorScheme::standard();
|
|
|
|
cs.map_background = hex("#FEE4D7");
|
|
|
|
cs.grass = hex("#F6C6AF");
|
|
|
|
cs.driving_lane = hex("#BECBD3");
|
|
|
|
cs.building = hex("#DEAA95");
|
|
|
|
cs.sidewalk = hex("#8B9EA8");
|
|
|
|
cs
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bap() -> ColorScheme {
|
|
|
|
let mut cs = ColorScheme::standard();
|
|
|
|
cs.agent_colors = vec![
|
|
|
|
/*hex("#DD5444"),
|
|
|
|
hex("#C23E46"),
|
|
|
|
hex("#821B38"),
|
|
|
|
hex("#BC3101"),*/
|
|
|
|
hex("#F44273"),
|
|
|
|
hex("#B53A7E"),
|
|
|
|
hex("#FF616E"),
|
|
|
|
hex("#FA8D37"),
|
|
|
|
];
|
|
|
|
cs.grass = hex("#84BA3B"); // #2F8C2C
|
|
|
|
cs.building = hex("#367335"); // #194C18
|
|
|
|
cs.normal_intersection = hex("#4B5485");
|
|
|
|
cs.driving_lane = hex("#384173");
|
|
|
|
cs.parking_lane = hex("#4B5485");
|
|
|
|
cs.sidewalk = hex("#89ABD9");
|
|
|
|
cs.sidewalk_lines = hex("#4B5485");
|
|
|
|
cs.general_road_marking = hex("#89ABD9");
|
|
|
|
cs.map_background = hex("#589D54"); // #153F14
|
|
|
|
cs.ped_crowd = hex("#DD5444");
|
|
|
|
cs.road_center_line = hex("#BCFF00");
|
|
|
|
cs
|
|
|
|
}
|
|
|
|
|
|
|
|
fn osm() -> ColorScheme {
|
|
|
|
let mut cs = ColorScheme::standard();
|
|
|
|
// TODO normal_intersection, driving_lane, parking_lane depends on osm rank
|
|
|
|
cs.general_road_marking = Color::BLACK;
|
|
|
|
cs.road_center_line = Color::rgb(202, 177, 39);
|
|
|
|
cs
|
|
|
|
}
|
2020-04-05 04:28:30 +03:00
|
|
|
|
|
|
|
fn starcat() -> ColorScheme {
|
|
|
|
let mut cs = ColorScheme::standard();
|
|
|
|
cs.grass = hex("#3F8C0C");
|
|
|
|
cs.building = hex("#8099A8"); // #5E7486
|
|
|
|
cs.map_background = hex("#737373");
|
|
|
|
cs.driving_lane = hex("#2A2A2A"); // TODO for arterial
|
|
|
|
cs.road_center_line = hex("#DB952E");
|
|
|
|
cs.general_road_marking = hex("#D6D6D6");
|
|
|
|
cs.sidewalk = cs.general_road_marking;
|
|
|
|
cs.sidewalk_lines = hex("#707070");
|
|
|
|
cs.bike_lane = hex("#72CE36");
|
|
|
|
cs.bus_lane = hex("#AD302D");
|
|
|
|
cs
|
|
|
|
}
|
2020-04-05 04:13:45 +03:00
|
|
|
}
|