change the colorscheme method name to find more easily in parsing

This commit is contained in:
Dustin Carlino 2018-12-12 16:20:20 -08:00
parent 9d653b103d
commit 010a636ae6
27 changed files with 122 additions and 110 deletions

View File

@ -5,7 +5,7 @@ use std::collections::{BTreeMap, HashMap};
use std::io::Error;
pub struct ColorScheme {
// Filled out by lazy calls to get()
// Filled out by lazy calls to get_def()
map: HashMap<String, Color>,
// A subset of map
@ -32,7 +32,8 @@ impl ColorScheme {
abstutil::write_json("color_scheme", &self.modified).expect("Saving color_scheme failed");
}
pub fn get(&mut self, name: &str, default: Color) -> Color {
// Get, but specify the default inline
pub fn get_def(&mut self, name: &str, default: Color) -> Color {
if let Some(existing) = self.map.get(name) {
if default != *existing && !self.modified.map.contains_key(name) {
panic!(

View File

@ -7,7 +7,7 @@ def run():
for path, _, files in os.walk('.'):
for f in files:
if f.endswith('.rs') and f != 'colors.rs' and f != 'objects.rs':
if f.endswith('.rs') and f != 'colors.rs':
for k, v in read_file(os.path.join(path, f)):
# TODO Check for double-definitions
mapping[k] = v
@ -17,13 +17,12 @@ def run():
def read_file(filename):
print filename
entries = []
with open(filename, 'r') as f:
src = ''.join(f.readlines())
while src:
if src.startswith('get('):
src = src[len('get('):]
if src.startswith('get_def('):
src = src[len('get_def('):]
# Look for the opening "
while src[0] != '"':
@ -46,7 +45,7 @@ def read_file(filename):
while not src.startswith('Color'):
src = src[1:]
# Wait for the ()'s to be mismatched, meaning we found the ) of the get()
# Wait for the ()'s to be mismatched, meaning we found the ) of the get_def()
counter = 0
value = ''
while True:

View File

@ -39,7 +39,7 @@ impl Plugin for ChokepointsFinder {
}
fn color_for(&self, obj: ID, ctx: &mut Ctx) -> Option<Color> {
let color = ctx.cs.get("chokepoint", Color::RED);
let color = ctx.cs.get_def("chokepoint", Color::RED);
match obj {
ID::Lane(l) if self.lanes.contains(&l) => Some(color),
ID::Intersection(i) if self.intersections.contains(&i) => Some(color),

View File

@ -38,19 +38,19 @@ impl Plugin for OsmClassifier {
{
// From https://wiki.openstreetmap.org/wiki/Map_Features#Highway
Some("motorway") | Some("motorway_link") => {
Some(ctx.cs.get("OSM motorway", Color::rgb(231, 141, 159)))
Some(ctx.cs.get_def("OSM motorway", Color::rgb(231, 141, 159)))
}
Some("trunk") | Some("trunk_link") => {
Some(ctx.cs.get("OSM trunk", Color::rgb(249, 175, 152)))
Some(ctx.cs.get_def("OSM trunk", Color::rgb(249, 175, 152)))
}
Some("primary") | Some("primary_link") => {
Some(ctx.cs.get("OSM primary", Color::rgb(252, 213, 160)))
Some(ctx.cs.get_def("OSM primary", Color::rgb(252, 213, 160)))
}
Some("secondary") | Some("secondary_link") => {
Some(ctx.cs.get("OSM secondary", Color::rgb(252, 213, 160)))
Some(ctx.cs.get_def("OSM secondary", Color::rgb(252, 213, 160)))
}
Some("residential") => {
Some(ctx.cs.get("OSM residential", Color::rgb(254, 254, 254)))
Some(ctx.cs.get_def("OSM residential", Color::rgb(254, 254, 254)))
}
_ => None,
}
@ -60,7 +60,7 @@ impl Plugin for OsmClassifier {
}
ID::Building(b) => {
if ctx.map.get_b(b).osm_tags.contains_key("addr:housenumber") {
Some(ctx.cs.get("OSM house", Color::GREEN))
Some(ctx.cs.get_def("OSM house", Color::GREEN))
} else {
None
}

View File

@ -58,14 +58,14 @@ impl Plugin for Floodfiller {
fn color_for(&self, obj: ID, ctx: &mut Ctx) -> Option<Color> {
if let ID::Lane(l) = obj {
if self.visited.contains(&l) {
return Some(ctx.cs.get("visited in floodfill", Color::BLUE));
return Some(ctx.cs.get_def("visited in floodfill", Color::BLUE));
}
if !self.queue.is_empty() && *self.queue.front().unwrap() == l {
return Some(ctx.cs.get("next to visit in floodfill", Color::GREEN));
return Some(ctx.cs.get_def("next to visit in floodfill", Color::GREEN));
}
// TODO linear search shouldnt suck too much for interactive mode
if self.queue.contains(&l) {
return Some(ctx.cs.get("queued in floodfill", Color::RED));
return Some(ctx.cs.get_def("queued in floodfill", Color::RED));
}
}
None

View File

@ -112,7 +112,7 @@ impl Plugin for DrawNeighborhoodState {
if pts.len() == 2 {
g.draw_line(
ctx.cs.get("neighborhood point", Color::RED),
ctx.cs.get_def("neighborhood point", Color::RED),
POINT_RADIUS / 2.0,
&Line::new(pts[0], pts[1]),
);
@ -120,25 +120,26 @@ impl Plugin for DrawNeighborhoodState {
if pts.len() >= 3 {
g.draw_polygon(
ctx.cs
.get("neighborhood polygon", Color::rgba(0, 0, 255, 0.6)),
.get_def("neighborhood polygon", Color::rgba(0, 0, 255, 0.6)),
&Polygon::new(&pts),
);
}
for pt in &pts {
g.draw_circle(
ctx.cs.get("neighborhood point", Color::RED),
ctx.cs.get_def("neighborhood point", Color::RED),
&Circle::new(*pt, POINT_RADIUS),
);
}
if let Some(last) = pts.last() {
g.draw_circle(
ctx.cs.get("neighborhood last placed point", Color::GREEN),
ctx.cs
.get_def("neighborhood last placed point", Color::GREEN),
&Circle::new(*last, POINT_RADIUS),
);
}
if let Some(idx) = current_idx {
g.draw_circle(
ctx.cs.get("neighborhood point to move", Color::CYAN),
ctx.cs.get_def("neighborhood point to move", Color::CYAN),
&Circle::new(pts[idx], POINT_RADIUS),
);
}

View File

@ -80,7 +80,7 @@ impl Plugin for ScenarioManager {
if let Some(neighborhood) = wizard.current_menu_choice::<Neighborhood>() {
g.draw_polygon(
ctx.cs
.get("neighborhood polygon", Color::rgba(0, 0, 255, 0.6)),
.get_def("neighborhood polygon", Color::rgba(0, 0, 255, 0.6)),
&neighborhood.polygon,
);
}

View File

@ -73,10 +73,12 @@ impl Plugin for StopSignEditor {
return None;
}
match ctx.map.get_stop_sign(self.i).get_priority(t) {
TurnPriority::Priority => Some(ctx.cs.get("priority stop sign turn", Color::GREEN)),
TurnPriority::Yield => Some(ctx.cs.get("yield stop sign turn", Color::YELLOW)),
TurnPriority::Stop => Some(ctx.cs.get("stop turn", Color::RED)),
TurnPriority::Banned => Some(ctx.cs.get("banned turn", Color::BLACK)),
TurnPriority::Priority => {
Some(ctx.cs.get_def("priority stop sign turn", Color::GREEN))
}
TurnPriority::Yield => Some(ctx.cs.get_def("yield stop sign turn", Color::YELLOW)),
TurnPriority::Stop => Some(ctx.cs.get_def("stop turn", Color::RED)),
TurnPriority::Banned => Some(ctx.cs.get_def("banned turn", Color::BLACK)),
}
} else {
None

View File

@ -237,7 +237,8 @@ impl Plugin for TrafficSignalEditor {
let old_ctx = g.fork_screenspace();
g.draw_polygon(
ctx.cs.get("signal editor panel", Color::BLACK.alpha(0.95)),
ctx.cs
.get_def("signal editor panel", Color::BLACK.alpha(0.95)),
&Polygon::rectangle_topleft(
Pt2D::new(10.0, 10.0),
2.0 * width * zoom,
@ -247,7 +248,7 @@ impl Plugin for TrafficSignalEditor {
// TODO Padding and offsets all a bit off. Abstractions are a bit awkward. Want to
// center a map-space thing inside a screen-space box.
g.draw_polygon(
ctx.cs.get(
ctx.cs.get_def(
"current cycle in signal editor panel",
Color::BLUE.alpha(0.95),
),
@ -292,7 +293,7 @@ impl Plugin for TrafficSignalEditor {
DrawTurn::draw_full(
ctx.map.get_t(id),
g,
ctx.cs.get("selected turn icon", Color::BLUE.alpha(0.5)),
ctx.cs.get_def("selected turn icon", Color::BLUE.alpha(0.5)),
);
}
@ -311,13 +312,13 @@ impl Plugin for TrafficSignalEditor {
let cycle = &ctx.map.get_traffic_signal(self.i).cycles[self.current_cycle];
return Some(match cycle.get_priority(t) {
TurnPriority::Priority => {
ctx.cs.get("priority turn in current cycle", Color::GREEN)
}
TurnPriority::Priority => ctx
.cs
.get_def("priority turn in current cycle", Color::GREEN),
TurnPriority::Yield => ctx
.cs
.get("yield turn in current cycle", Color::rgb(255, 105, 180)),
TurnPriority::Banned => ctx.cs.get("turn not in current cycle", Color::BLACK),
.get_def("yield turn in current cycle", Color::rgb(255, 105, 180)),
TurnPriority::Banned => ctx.cs.get_def("turn not in current cycle", Color::BLACK),
TurnPriority::Stop => panic!("Can't have TurnPriority::Stop in a traffic signal"),
});
}

View File

@ -47,7 +47,7 @@ impl Plugin for DiffAllState {
fn draw(&self, g: &mut GfxCtx, ctx: &mut Ctx) {
for line in &self.lines {
g.draw_line(
ctx.cs.get("diff agents line", Color::YELLOW),
ctx.cs.get_def("diff agents line", Color::YELLOW),
LANE_THICKNESS,
line,
);

View File

@ -50,7 +50,7 @@ impl Plugin for DiffTripState {
fn draw(&self, g: &mut GfxCtx, ctx: &mut Ctx) {
if let Some(l) = &self.line {
g.draw_line(
ctx.cs.get("diff agents line", Color::YELLOW),
ctx.cs.get_def("diff agents line", Color::YELLOW),
LANE_THICKNESS,
l,
);
@ -58,14 +58,14 @@ impl Plugin for DiffTripState {
if let Some(t) = &self.primary_route {
g.draw_polygon(
ctx.cs
.get("primary agent route", Color::rgba(255, 0, 0, 0.5)),
.get_def("primary agent route", Color::rgba(255, 0, 0, 0.5)),
&t.make_polygons_blindly(LANE_THICKNESS),
);
}
if let Some(t) = &self.secondary_route {
g.draw_polygon(
ctx.cs
.get("secondary agent route", Color::rgba(0, 0, 255, 0.5)),
.get_def("secondary agent route", Color::rgba(0, 0, 255, 0.5)),
&t.make_polygons_blindly(LANE_THICKNESS),
);
}

View File

@ -71,7 +71,7 @@ impl Plugin for SearchState {
};
for (k, v) in osm_tags {
if format!("{}={}", k, v).contains(filter) {
return Some(ctx.cs.get("search result", Color::RED));
return Some(ctx.cs.get_def("search result", Color::RED));
}
}
}

View File

@ -65,7 +65,7 @@ impl Plugin for ShowOwnerState {
}
fn color_for(&self, obj: ID, ctx: &mut Ctx) -> Option<Color> {
let color = ctx.cs.get("car/building owner", Color::PURPLE);
let color = ctx.cs.get_def("car/building owner", Color::PURPLE);
match (self, obj) {
(ShowOwnerState::BuildingSelected(_, cars), ID::Car(id)) => {
if cars.contains(&id) {

View File

@ -73,14 +73,14 @@ impl Plugin for ShowRouteState {
match &self.state {
State::Active(_, _, Some(trace)) => {
g.draw_polygon(
ctx.cs.get("route", Color::rgba(255, 0, 0, 0.8)),
ctx.cs.get_def("route", Color::rgba(255, 0, 0, 0.8)),
&trace.make_polygons_blindly(LANE_THICKNESS),
);
}
State::DebugAllRoutes(_, traces) => {
for t in traces {
g.draw_polygon(
ctx.cs.get("route", Color::rgba(255, 0, 0, 0.8)),
ctx.cs.get_def("route", Color::rgba(255, 0, 0, 0.8)),
&t.make_polygons_blindly(LANE_THICKNESS),
);
}

View File

@ -77,12 +77,12 @@ impl Plugin for TurnCyclerState {
for turn in &ctx.map.get_turns_from_lane(l) {
let color = match turn.turn_type {
TurnType::SharedSidewalkCorner => {
ctx.cs.get("shared sidewalk corner turn", Color::BLACK)
ctx.cs.get_def("shared sidewalk corner turn", Color::BLACK)
}
TurnType::Crosswalk => ctx.cs.get("crosswalk turn", Color::WHITE),
TurnType::Straight => ctx.cs.get("straight turn", Color::BLUE),
TurnType::Right => ctx.cs.get("right turn", Color::GREEN),
TurnType::Left => ctx.cs.get("left turn", Color::RED),
TurnType::Crosswalk => ctx.cs.get_def("crosswalk turn", Color::WHITE),
TurnType::Straight => ctx.cs.get_def("straight turn", Color::BLUE),
TurnType::Right => ctx.cs.get_def("right turn", Color::GREEN),
TurnType::Left => ctx.cs.get_def("left turn", Color::RED),
}
.alpha(0.5);
DrawTurn::draw_full(turn, g, color);
@ -94,7 +94,7 @@ impl Plugin for TurnCyclerState {
DrawTurn::draw_full(
turns[idx % turns.len()],
g,
ctx.cs.get("current selected turn", Color::RED),
ctx.cs.get_def("current selected turn", Color::RED),
);
}
}
@ -119,11 +119,11 @@ impl Plugin for TurnCyclerState {
let width = 50.0;
let height = 100.0;
g.draw_polygon(
ctx.cs.get("timer foreground", Color::RED),
ctx.cs.get_def("timer foreground", Color::RED),
&Polygon::rectangle_topleft(Pt2D::new(10.0, 10.0), width, height),
);
g.draw_polygon(
ctx.cs.get("timer background", Color::BLACK),
ctx.cs.get_def("timer background", Color::BLACK),
&Polygon::rectangle_topleft(
Pt2D::new(10.0, 10.0),
width,

View File

@ -28,9 +28,9 @@ impl Renderable for DrawArea {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &mut Ctx) {
let color = match self.area_type {
AreaType::Park => ctx.cs.get("park area", Color::GREEN),
AreaType::Swamp => ctx.cs.get("swamp area", Color::rgb_f(0.0, 1.0, 0.6)),
AreaType::Water => ctx.cs.get("water area", Color::BLUE),
AreaType::Park => ctx.cs.get_def("park area", Color::GREEN),
AreaType::Swamp => ctx.cs.get_def("swamp area", Color::rgb_f(0.0, 1.0, 0.6)),
AreaType::Water => ctx.cs.get_def("water area", Color::BLUE),
};
g.draw_polygon(opts.color.unwrap_or(color), &self.fill_polygon);
}

View File

@ -46,11 +46,11 @@ impl Renderable for DrawBike {
match self.state {
CarState::Debug => ctx
.cs
.get("debug bike", Color::rgba(0, 0, 255, 0.8))
.get_def("debug bike", Color::rgba(0, 0, 255, 0.8))
.shift(self.id.0),
// TODO Hard to see on the greenish bike lanes? :P
CarState::Moving => ctx.cs.get("moving bike", Color::GREEN).shift(self.id.0),
CarState::Stuck => ctx.cs.get("stuck bike", Color::RED).shift(self.id.0),
CarState::Moving => ctx.cs.get_def("moving bike", Color::GREEN).shift(self.id.0),
CarState::Stuck => ctx.cs.get_def("stuck bike", Color::RED).shift(self.id.0),
CarState::Parked => panic!("Can't have a parked bike"),
}
});
@ -59,7 +59,7 @@ impl Renderable for DrawBike {
if let Some(ref t) = self.stopping_buffer {
g.draw_polygon(
ctx.cs
.get("bike stopping buffer", Color::rgba(255, 0, 0, 0.7)),
.get_def("bike stopping buffer", Color::rgba(255, 0, 0, 0.7)),
t,
);
}

View File

@ -39,15 +39,17 @@ impl Renderable for DrawBuilding {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &mut Ctx) {
// Buildings look better without boundaries, actually
//g.draw_polygon(ctx.cs.get("building boundary", Color::rgb(0, 100, 0)), &self.boundary_polygon);
//g.draw_polygon(ctx.cs.get_def("building boundary", Color::rgb(0, 100, 0)), &self.boundary_polygon);
g.draw_polygon(
opts.color
.unwrap_or_else(|| ctx.cs.get("building", Color::rgba_f(0.7, 0.7, 0.7, 0.8))),
opts.color.unwrap_or_else(|| {
ctx.cs
.get_def("building", Color::rgba_f(0.7, 0.7, 0.7, 0.8))
}),
&self.fill_polygon,
);
g.draw_line(
ctx.cs.get("building path", Color::grey(0.6)),
ctx.cs.get_def("building path", Color::grey(0.6)),
1.0,
&self.front_path,
);

View File

@ -44,7 +44,7 @@ impl Renderable for DrawBusStop {
g.draw_polygon(
opts.color.unwrap_or_else(|| {
ctx.cs
.get("bus stop marking", Color::rgba(220, 160, 220, 0.8))
.get_def("bus stop marking", Color::rgba(220, 160, 220, 0.8))
}),
&self.polygon,
);

View File

@ -95,30 +95,30 @@ impl Renderable for DrawCar {
match self.state {
CarState::Debug => ctx
.cs
.get("debug car", Color::rgba(0, 0, 255, 0.8))
.get_def("debug car", Color::rgba(0, 0, 255, 0.8))
.shift(self.id.0),
CarState::Moving => ctx.cs.get("moving car", Color::CYAN).shift(self.id.0),
CarState::Stuck => ctx.cs.get("stuck car", Color::RED).shift(self.id.0),
CarState::Moving => ctx.cs.get_def("moving car", Color::CYAN).shift(self.id.0),
CarState::Stuck => ctx.cs.get_def("stuck car", Color::RED).shift(self.id.0),
CarState::Parked => ctx
.cs
.get("parked car", Color::rgb(180, 233, 76))
.get_def("parked car", Color::rgb(180, 233, 76))
.shift(self.id.0),
}
});
g.draw_polygon(color, &self.body_polygon);
for p in &self.window_polygons {
g.draw_polygon(ctx.cs.get("car window", Color::BLACK), p);
g.draw_polygon(ctx.cs.get_def("car window", Color::BLACK), p);
}
// TODO tune color, sizes
if let Some(ref a) = self.turn_arrow {
g.draw_arrow(ctx.cs.get("car turn arrow", Color::CYAN), 0.25, 1.0, a);
g.draw_arrow(ctx.cs.get_def("car turn arrow", Color::CYAN), 0.25, 1.0, a);
}
if let Some(ref t) = self.stopping_buffer {
g.draw_polygon(
ctx.cs
.get("car stopping buffer", Color::rgba(255, 0, 0, 0.7)),
.get_def("car stopping buffer", Color::rgba(255, 0, 0, 0.7)),
t,
);
}

View File

@ -95,7 +95,7 @@ impl Renderable for DrawExtraShape {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &mut Ctx) {
let color = opts
.color
.unwrap_or_else(|| ctx.cs.get("extra shape", Color::CYAN));
.unwrap_or_else(|| ctx.cs.get_def("extra shape", Color::CYAN));
match self.shape {
Shape::Polygon(ref p) => g.draw_polygon(color, &p),
Shape::Circle(ref c) => g.draw_circle(color, c),

View File

@ -41,7 +41,7 @@ impl DrawIntersection {
fn draw_stop_sign(&self, g: &mut GfxCtx, ctx: &mut Ctx) {
g.draw_polygon(
ctx.cs.get("stop sign background", Color::RED),
ctx.cs.get_def("stop sign background", Color::RED),
&Polygon::regular_polygon(self.center, 8, 1.5, Angle::new_degs(360.0 / 16.0)),
);
// TODO draw "STOP"
@ -51,22 +51,22 @@ impl DrawIntersection {
let radius = 0.5;
g.draw_polygon(
ctx.cs.get("traffic signal box", Color::BLACK),
ctx.cs.get_def("traffic signal box", Color::BLACK),
&Polygon::rectangle(self.center, 4.0 * radius, 8.0 * radius),
);
g.draw_circle(
ctx.cs.get("traffic signal yellow", Color::YELLOW),
ctx.cs.get_def("traffic signal yellow", Color::YELLOW),
&Circle::new(self.center, radius),
);
g.draw_circle(
ctx.cs.get("traffic signal green", Color::GREEN),
ctx.cs.get_def("traffic signal green", Color::GREEN),
&Circle::new(self.center.offset(0.0, radius * 2.0), radius),
);
g.draw_circle(
ctx.cs.get("traffic signal red", Color::RED),
ctx.cs.get_def("traffic signal red", Color::RED),
&Circle::new(self.center.offset(0.0, radius * -2.0), radius),
);
}
@ -80,7 +80,9 @@ impl Renderable for DrawIntersection {
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &mut Ctx) {
let color = opts.color.unwrap_or_else(|| {
if self.intersection_type == IntersectionType::Border {
return ctx.cs.get("border intersection", Color::rgb(50, 205, 50));
return ctx
.cs
.get_def("border intersection", Color::rgb(50, 205, 50));
}
let _changed = if let Some(s) = ctx.map.maybe_get_traffic_signal(self.id) {
@ -91,7 +93,7 @@ impl Renderable for DrawIntersection {
false
};
// TODO Make some other way to view map edits. rgb_f(0.8, 0.6, 0.6) was distracting.
ctx.cs.get("unchanged intersection", Color::grey(0.6))
ctx.cs.get_def("unchanged intersection", Color::grey(0.6))
});
g.draw_polygon(color, &self.polygon);
@ -102,13 +104,13 @@ impl Renderable for DrawIntersection {
*ctx.hints
.color_crosswalks
.get(&crosswalk.id1)
.unwrap_or(&ctx.cs.get("crosswalk", Color::WHITE)),
.unwrap_or(&ctx.cs.get_def("crosswalk", Color::WHITE)),
);
}
}
for corner in &self.sidewalk_corners {
g.draw_polygon(ctx.cs.get("sidewalk corner", Color::grey(0.7)), corner);
g.draw_polygon(ctx.cs.get_def("sidewalk corner", Color::grey(0.7)), corner);
}
if ctx.hints.suppress_intersection_icon != Some(self.id) {
@ -173,15 +175,15 @@ pub fn draw_signal_cycle(
draw_map: &DrawMap,
hide_crosswalks: &HashSet<TurnID>,
) {
let priority_color = cs.get("turns protected by traffic signal right now", Color::GREEN);
let yield_color = cs.get(
let priority_color = cs.get_def("turns protected by traffic signal right now", Color::GREEN);
let yield_color = cs.get_def(
"turns allowed with yielding by traffic signal right now",
Color::rgba(255, 105, 180, 0.8),
);
for crosswalk in &draw_map.get_i(cycle.parent).crosswalks {
if !hide_crosswalks.contains(&crosswalk.id1) {
crosswalk.draw(g, cs.get("crosswalk", Color::WHITE));
crosswalk.draw(g, cs.get_def("crosswalk", Color::WHITE));
}
}
for t in &cycle.priority_turns {
@ -199,10 +201,10 @@ pub fn draw_signal_cycle(
}
pub fn draw_stop_sign(sign: &ControlStopSign, g: &mut GfxCtx, cs: &mut ColorScheme, map: &Map) {
let priority_color = cs.get("stop sign priority turns", Color::GREEN);
let priority_color = cs.get_def("stop sign priority turns", Color::GREEN);
// TODO pink yield color from traffic signals is nice, but it's too close to red for stop...
let yield_color = cs.get("stop sign yield turns", Color::YELLOW.alpha(0.8));
let stop_color = cs.get("stop sign stop turns", Color::RED.alpha(0.8));
let yield_color = cs.get_def("stop sign yield turns", Color::YELLOW.alpha(0.8));
let stop_color = cs.get_def("stop sign stop turns", Color::RED.alpha(0.8));
// TODO first crosswalks... actually, give rendering hints to override the color. dont do that
// here.
@ -251,12 +253,12 @@ pub fn stop_sign_rendering_hints(
TurnPriority::Yield => {
hints
.color_crosswalks
.insert(*t, cs.get("stop sign yield crosswalk", Color::YELLOW));
.insert(*t, cs.get_def("stop sign yield crosswalk", Color::YELLOW));
}
TurnPriority::Stop => {
hints
.color_crosswalks
.insert(*t, cs.get("stop sign stop crosswalk", Color::RED));
.insert(*t, cs.get_def("stop sign stop crosswalk", Color::RED));
}
TurnPriority::Banned => {
hints.hide_crosswalks.insert(*t);

View File

@ -35,7 +35,7 @@ impl DrawLane {
markings.push(Box::new(move |g, cs| {
for line in &lines {
g.draw_rounded_line(
cs.get("road center line", Color::YELLOW),
cs.get_def("road center line", Color::YELLOW),
BIG_ARROW_THICKNESS,
line,
);
@ -78,11 +78,11 @@ impl DrawLane {
fn draw_debug(&self, g: &mut GfxCtx, ctx: &mut Ctx) {
let circle_color = ctx
.cs
.get("debug line endpoint", Color::rgb_f(0.8, 0.1, 0.1));
.get_def("debug line endpoint", Color::rgb_f(0.8, 0.1, 0.1));
for l in ctx.map.get_l(self.id).lane_center_pts.lines() {
g.draw_line(
ctx.cs.get("debug line", Color::RED),
ctx.cs.get_def("debug line", Color::RED),
PARCEL_BOUNDARY_THICKNESS / 2.0,
&l,
);
@ -107,12 +107,14 @@ impl Renderable for DrawLane {
let color = opts.color.unwrap_or_else(|| {
let l = ctx.map.get_l(self.id);
match l.lane_type {
_ if l.probably_broken => ctx.cs.get("broken lane", Color::rgb_f(1.0, 0.0, 0.565)),
LaneType::Driving => ctx.cs.get("driving lane", Color::BLACK),
LaneType::Bus => ctx.cs.get("bus lane", Color::rgb(190, 74, 76)),
LaneType::Parking => ctx.cs.get("parking lane", Color::grey(0.2)),
LaneType::Sidewalk => ctx.cs.get("sidewalk", Color::grey(0.8)),
LaneType::Biking => ctx.cs.get("bike lane", Color::rgb(15, 125, 75)),
_ if l.probably_broken => {
ctx.cs.get_def("broken lane", Color::rgb_f(1.0, 0.0, 0.565))
}
LaneType::Driving => ctx.cs.get_def("driving lane", Color::BLACK),
LaneType::Bus => ctx.cs.get_def("bus lane", Color::rgb(190, 74, 76)),
LaneType::Parking => ctx.cs.get_def("parking lane", Color::grey(0.2)),
LaneType::Sidewalk => ctx.cs.get_def("sidewalk", Color::grey(0.8)),
LaneType::Biking => ctx.cs.get_def("bike lane", Color::rgb(15, 125, 75)),
}
});
g.draw_polygon(color, &self.polygon);
@ -162,7 +164,7 @@ fn calculate_sidewalk_lines(lane: &Lane) -> Marking {
Box::new(move |g, cs| {
for line in &lines {
g.draw_line(cs.get("sidewalk lines", Color::grey(0.7)), 0.25, line);
g.draw_line(cs.get_def("sidewalk lines", Color::grey(0.7)), 0.25, line);
}
})
}
@ -195,7 +197,7 @@ fn calculate_parking_lines(lane: &Lane) -> Marking {
Box::new(move |g, cs| {
for line in &lines {
g.draw_line(cs.get("parking line", Color::WHITE), 0.25, line);
g.draw_line(cs.get_def("parking line", Color::WHITE), 0.25, line);
}
})
}
@ -225,7 +227,7 @@ fn calculate_driving_lines(lane: &Lane, parent: &Road) -> Option<Marking> {
Some(Box::new(move |g, cs| {
for p in &polygons {
g.draw_polygon(cs.get("dashed lane line", Color::WHITE), p);
g.draw_polygon(cs.get_def("dashed lane line", Color::WHITE), p);
}
}))
}
@ -243,7 +245,7 @@ fn calculate_stop_sign_line(lane: &Lane, map: &Map) -> Option<Marking> {
let line = perp_line(Line::new(pt1, pt2), LANE_THICKNESS);
Some(Box::new(move |g, cs| {
g.draw_rounded_line(cs.get("stop line for lane", Color::RED), 0.45, &line);
g.draw_rounded_line(cs.get_def("stop line for lane", Color::RED), 0.45, &line);
}))
}
@ -296,7 +298,9 @@ fn turn_markings(turn: &Turn, map: &Map) -> Option<Marking> {
);
Some(Box::new(move |g, cs| {
let color = cs.get("turn restrictions on lane", Color::WHITE).alpha(0.8);
let color = cs
.get_def("turn restrictions on lane", Color::WHITE)
.alpha(0.8);
g.draw_polygon(color, &base_polygon);
g.draw_rounded_arrow(color, 0.05, 0.5, &turn_line);
}))

View File

@ -57,7 +57,7 @@ impl Renderable for DrawParcel {
g.draw_polygon(color, &self.fill_polygon);
g.draw_polygon(
ctx.cs.get("parcel boundary", Color::grey(0.3)),
ctx.cs.get_def("parcel boundary", Color::grey(0.3)),
&self.boundary_polygon,
);
}

View File

@ -43,11 +43,11 @@ impl Renderable for DrawPedestrian {
let color = opts.color.unwrap_or_else(|| {
if self.preparing_bike {
ctx.cs
.get("pedestrian preparing bike", Color::rgb(255, 0, 144))
.get_def("pedestrian preparing bike", Color::rgb(255, 0, 144))
.shift(self.id.0)
} else {
ctx.cs
.get("pedestrian", Color::rgb_f(0.2, 0.7, 0.7))
.get_def("pedestrian", Color::rgb_f(0.2, 0.7, 0.7))
.shift(self.id.0)
}
});
@ -56,7 +56,7 @@ impl Renderable for DrawPedestrian {
// TODO tune color, sizes
if let Some(ref a) = self.turn_arrow {
g.draw_rounded_arrow(
ctx.cs.get("pedestrian turn arrow", Color::CYAN),
ctx.cs.get_def("pedestrian turn arrow", Color::CYAN),
0.25,
0.3,
a,

View File

@ -96,13 +96,13 @@ impl Renderable for DrawTurn {
}
g.draw_circle(
ctx.cs.get("turn icon circle", Color::grey(0.3)),
ctx.cs.get_def("turn icon circle", Color::grey(0.3)),
&self.icon_circle,
);
g.draw_arrow(
opts.color
.unwrap_or_else(|| ctx.cs.get("inactive turn icon", Color::grey(0.7))),
.unwrap_or_else(|| ctx.cs.get_def("inactive turn icon", Color::grey(0.7))),
TURN_ICON_ARROW_THICKNESS,
TURN_ICON_ARROW_TIP_LENGTH,
&self.icon_arrow,

View File

@ -108,7 +108,7 @@ impl GUI<RenderingHints> for UI {
g.clear(
self.cs
.borrow_mut()
.get("map background", Color::rgb(242, 239, 233)),
.get_def("map background", Color::rgb(242, 239, 233)),
);
let mut ctx = Ctx {
@ -294,7 +294,7 @@ impl UI {
fn color_obj(&self, id: ID, ctx: &mut Ctx) -> Option<Color> {
if Some(id) == self.primary.current_selection {
return Some(ctx.cs.get("selected", Color::BLUE));
return Some(ctx.cs.get_def("selected", Color::BLUE));
}
if let Some(p) = self.get_active_plugin() {