mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-18 11:51:42 +03:00
Steps towards the new color-scheme. #715
- Stop using different colors in the city picker. Just using a uniform color, different between day/night, that looks fine in all themes. - Simplify the methods for road markings; not going to change them based on rank
This commit is contained in:
parent
c71c1b91dc
commit
c2f8f177ea
@ -74,8 +74,8 @@ pub struct ColorScheme {
|
|||||||
bike_lane: Color,
|
bike_lane: Color,
|
||||||
sidewalk: Color,
|
sidewalk: Color,
|
||||||
pub sidewalk_lines: Color,
|
pub sidewalk_lines: Color,
|
||||||
general_road_marking: Color,
|
pub general_road_marking: Color,
|
||||||
road_center_line: Color,
|
pub road_center_line: Color,
|
||||||
pub light_rail_track: Color,
|
pub light_rail_track: Color,
|
||||||
pub private_road: Color,
|
pub private_road: Color,
|
||||||
unzoomed_highway: Color,
|
unzoomed_highway: Color,
|
||||||
@ -353,16 +353,6 @@ impl ColorScheme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Maybe this'll be the same everywhere
|
|
||||||
pub fn road_center_line(&self, _: RoadRank) -> Color {
|
|
||||||
self.road_center_line
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Maybe this'll be the same everywhere
|
|
||||||
pub fn general_road_marking(&self, _: RoadRank) -> Color {
|
|
||||||
self.general_road_marking
|
|
||||||
}
|
|
||||||
|
|
||||||
// These two could try to use serde, but... Color serializes with a separate RGB by default,
|
// These two could try to use serde, but... Color serializes with a separate RGB by default,
|
||||||
// and changing it to use a nice hex string is way too hard.
|
// and changing it to use a nice hex string is way too hard.
|
||||||
pub fn export(&self, path: &str) -> Result<()> {
|
pub fn export(&self, path: &str) -> Result<()> {
|
||||||
|
@ -71,7 +71,7 @@ impl DrawIntersection {
|
|||||||
IntersectionType::Border => {
|
IntersectionType::Border => {
|
||||||
let r = map.get_r(*i.roads.iter().next().unwrap());
|
let r = map.get_r(*i.roads.iter().next().unwrap());
|
||||||
default_geom.extend(
|
default_geom.extend(
|
||||||
app.cs().road_center_line(r.get_rank()),
|
app.cs().road_center_line,
|
||||||
calculate_border_arrows(i, r, map),
|
calculate_border_arrows(i, r, map),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -495,10 +495,8 @@ pub fn make_crosswalk(batch: &mut GeomBatch, turn: &Turn, map: &Map, cs: &ColorS
|
|||||||
let pt1 = line.dist_along(dist_along).expect(&err);
|
let pt1 = line.dist_along(dist_along).expect(&err);
|
||||||
// Reuse perp_line. Project away an arbitrary amount
|
// Reuse perp_line. Project away an arbitrary amount
|
||||||
let pt2 = pt1.project_away(Distance::meters(1.0), line.angle());
|
let pt2 = pt1.project_away(Distance::meters(1.0), line.angle());
|
||||||
let general_road_marking =
|
|
||||||
cs.general_road_marking(map.get_i(turn.id.parent).get_rank(map));
|
|
||||||
batch.push(
|
batch.push(
|
||||||
general_road_marking,
|
cs.general_road_marking,
|
||||||
perp_line(Line::must_new(pt1, pt2), width).make_polygons(CROSSWALK_LINE_THICKNESS),
|
perp_line(Line::must_new(pt1, pt2), width).make_polygons(CROSSWALK_LINE_THICKNESS),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -508,7 +506,7 @@ pub fn make_crosswalk(batch: &mut GeomBatch, turn: &Turn, map: &Map, cs: &ColorS
|
|||||||
.expect(&err);
|
.expect(&err);
|
||||||
let pt4 = pt3.project_away(Distance::meters(1.0), line.angle());
|
let pt4 = pt3.project_away(Distance::meters(1.0), line.angle());
|
||||||
batch.push(
|
batch.push(
|
||||||
general_road_marking,
|
cs.general_road_marking,
|
||||||
perp_line(Line::must_new(pt3, pt4), width).make_polygons(CROSSWALK_LINE_THICKNESS),
|
perp_line(Line::must_new(pt3, pt4), width).make_polygons(CROSSWALK_LINE_THICKNESS),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ impl DrawLane {
|
|||||||
self.polygon.clone(),
|
self.polygon.clone(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let general_road_marking = app.cs().general_road_marking(rank);
|
let general_road_marking = app.cs().general_road_marking;
|
||||||
|
|
||||||
match lane.lane_type {
|
match lane.lane_type {
|
||||||
LaneType::Sidewalk | LaneType::Shoulder => {
|
LaneType::Sidewalk | LaneType::Shoulder => {
|
||||||
@ -105,13 +105,13 @@ impl DrawLane {
|
|||||||
LaneType::SharedLeftTurn => {
|
LaneType::SharedLeftTurn => {
|
||||||
let thickness = Distance::meters(0.25);
|
let thickness = Distance::meters(0.25);
|
||||||
batch.push(
|
batch.push(
|
||||||
app.cs().road_center_line(rank),
|
app.cs().road_center_line,
|
||||||
lane.lane_center_pts
|
lane.lane_center_pts
|
||||||
.must_shift_right((lane.width - thickness) / 2.0)
|
.must_shift_right((lane.width - thickness) / 2.0)
|
||||||
.make_polygons(thickness),
|
.make_polygons(thickness),
|
||||||
);
|
);
|
||||||
batch.push(
|
batch.push(
|
||||||
app.cs().road_center_line(rank),
|
app.cs().road_center_line,
|
||||||
lane.lane_center_pts
|
lane.lane_center_pts
|
||||||
.must_shift_left((lane.width - thickness) / 2.0)
|
.must_shift_left((lane.width - thickness) / 2.0)
|
||||||
.make_polygons(thickness),
|
.make_polygons(thickness),
|
||||||
@ -174,7 +174,7 @@ impl DrawLane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LaneType::Buffer(style) => {
|
LaneType::Buffer(style) => {
|
||||||
calculate_buffer_markings(app, style, lane, road, &mut batch);
|
calculate_buffer_markings(app, style, lane, &mut batch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,10 +393,9 @@ fn calculate_buffer_markings(
|
|||||||
app: &dyn AppLike,
|
app: &dyn AppLike,
|
||||||
style: BufferType,
|
style: BufferType,
|
||||||
lane: &Lane,
|
lane: &Lane,
|
||||||
road: &Road,
|
|
||||||
batch: &mut GeomBatch,
|
batch: &mut GeomBatch,
|
||||||
) {
|
) {
|
||||||
let color = app.cs().general_road_marking(road.get_rank());
|
let color = app.cs().general_road_marking;
|
||||||
|
|
||||||
let side_lines = |batch: &mut GeomBatch| {
|
let side_lines = |batch: &mut GeomBatch| {
|
||||||
let thickness = Distance::meters(0.25);
|
let thickness = Distance::meters(0.25);
|
||||||
|
@ -79,7 +79,7 @@ impl DrawParkingLot {
|
|||||||
let right = pt.project_away(width / 2.0, angle.rotate_degs(-90.0));
|
let right = pt.project_away(width / 2.0, angle.rotate_degs(-90.0));
|
||||||
|
|
||||||
batch.push(
|
batch.push(
|
||||||
app.cs().general_road_marking(rank),
|
app.cs().general_road_marking,
|
||||||
PolyLine::must_new(vec![
|
PolyLine::must_new(vec![
|
||||||
left.project_away(height, *angle),
|
left.project_away(height, *angle),
|
||||||
left,
|
left,
|
||||||
|
@ -30,12 +30,10 @@ impl DrawRoad {
|
|||||||
|
|
||||||
let mut batch = GeomBatch::new();
|
let mut batch = GeomBatch::new();
|
||||||
let r = app.map().get_r(self.id);
|
let r = app.map().get_r(self.id);
|
||||||
// TODO Need to detangle how road_center_line is used.
|
let center_line_color = if r.is_private() {
|
||||||
let center_color = app.cs().road_center_line(r.get_rank());
|
app.cs().road_center_line.lerp(app.cs().private_road, 0.5)
|
||||||
let color = if r.is_private() {
|
|
||||||
center_color.lerp(app.cs().private_road, 0.5)
|
|
||||||
} else {
|
} else {
|
||||||
center_color
|
app.cs().road_center_line
|
||||||
};
|
};
|
||||||
|
|
||||||
// Draw a center line every time two driving/bike/bus lanes of opposite direction are
|
// Draw a center line every time two driving/bike/bus lanes of opposite direction are
|
||||||
@ -47,7 +45,7 @@ impl DrawRoad {
|
|||||||
if dir1 != dir2 && lt1.is_for_moving_vehicles() && lt2.is_for_moving_vehicles() {
|
if dir1 != dir2 && lt1.is_for_moving_vehicles() && lt2.is_for_moving_vehicles() {
|
||||||
let pl = r.get_left_side(app.map()).must_shift_right(width);
|
let pl = r.get_left_side(app.map()).must_shift_right(width);
|
||||||
batch.extend(
|
batch.extend(
|
||||||
color,
|
center_line_color,
|
||||||
pl.dashed_lines(
|
pl.dashed_lines(
|
||||||
Distance::meters(0.25),
|
Distance::meters(0.25),
|
||||||
Distance::meters(2.0),
|
Distance::meters(2.0),
|
||||||
@ -63,12 +61,6 @@ impl DrawRoad {
|
|||||||
if r.center_pts.length() >= Distance::meters(30.0) && name != "???" {
|
if r.center_pts.length() >= Distance::meters(30.0) && name != "???" {
|
||||||
// TODO If it's definitely straddling bus/bike lanes, change the color? Or
|
// TODO If it's definitely straddling bus/bike lanes, change the color? Or
|
||||||
// even easier, just skip the center lines?
|
// even easier, just skip the center lines?
|
||||||
let center_color = app.cs().road_center_line(r.get_rank());
|
|
||||||
let fg = if r.is_private() {
|
|
||||||
center_color.lerp(app.cs().private_road, 0.5)
|
|
||||||
} else {
|
|
||||||
center_color
|
|
||||||
};
|
|
||||||
let bg = if r.is_private() {
|
let bg = if r.is_private() {
|
||||||
app.cs()
|
app.cs()
|
||||||
.zoomed_road_surface(LaneType::Driving, r.get_rank())
|
.zoomed_road_surface(LaneType::Driving, r.get_rank())
|
||||||
@ -80,13 +72,13 @@ impl DrawRoad {
|
|||||||
|
|
||||||
if false {
|
if false {
|
||||||
// TODO Not ready yet
|
// TODO Not ready yet
|
||||||
batch.append(
|
batch.append(Line(name).fg(center_line_color).render_curvey(
|
||||||
Line(name)
|
prerender,
|
||||||
.fg(fg)
|
&r.center_pts,
|
||||||
.render_curvey(prerender, &r.center_pts, 0.1),
|
0.1,
|
||||||
);
|
));
|
||||||
} else {
|
} else {
|
||||||
let txt = Text::from(Line(name).fg(fg)).bg(bg);
|
let txt = Text::from(Line(name).fg(center_line_color)).bg(bg);
|
||||||
let (pt, angle) = r.center_pts.must_dist_along(r.center_pts.length() / 2.0);
|
let (pt, angle) = r.center_pts.must_dist_along(r.center_pts.length() / 2.0);
|
||||||
batch.append(
|
batch.append(
|
||||||
txt.render_autocropped(prerender)
|
txt.render_autocropped(prerender)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use abstio::{CityName, Manifest, MapName};
|
use abstio::{CityName, Manifest, MapName};
|
||||||
use abstutil::VecMap;
|
|
||||||
use geom::{Distance, Percent};
|
use geom::{Distance, Percent};
|
||||||
use map_model::City;
|
use map_model::City;
|
||||||
use widgetry::{
|
use widgetry::{
|
||||||
@ -60,19 +59,20 @@ impl<A: AppLike + 'static> CityPicker<A> {
|
|||||||
// If somebody has just generated a new map somewhere with an existing
|
// If somebody has just generated a new map somewhere with an existing
|
||||||
// city.bin, but hasn't updated city.bin yet, that new map will be invisible on
|
// city.bin, but hasn't updated city.bin yet, that new map will be invisible on
|
||||||
// the city-wide diagram.
|
// the city-wide diagram.
|
||||||
|
let outline_color = app.cs().minimap_cursor_border;
|
||||||
let mut tooltips = Vec::new();
|
let mut tooltips = Vec::new();
|
||||||
let mut colors = VecMap::new();
|
|
||||||
for (name, polygon) in city.districts {
|
for (name, polygon) in city.districts {
|
||||||
if &name != app.map().get_name() {
|
if &name != app.map().get_name() {
|
||||||
let color = app.cs().rotating_color_agents(colors.len());
|
batch.push(
|
||||||
batch.push(color, polygon.to_outline(Distance::meters(200.0)).unwrap());
|
outline_color,
|
||||||
|
polygon.to_outline(Distance::meters(200.0)).unwrap(),
|
||||||
|
);
|
||||||
let polygon = polygon.scale(zoom);
|
let polygon = polygon.scale(zoom);
|
||||||
tooltips.push((
|
tooltips.push((
|
||||||
polygon.clone(),
|
polygon.clone(),
|
||||||
Text::from(nice_map_name(&name)),
|
Text::from(nice_map_name(&name)),
|
||||||
Some(ClickOutcome::Custom(Box::new(name))),
|
Some(ClickOutcome::Custom(Box::new(name))),
|
||||||
));
|
));
|
||||||
colors.push(polygon, color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawWithTooltips::new_widget(
|
DrawWithTooltips::new_widget(
|
||||||
@ -80,8 +80,7 @@ impl<A: AppLike + 'static> CityPicker<A> {
|
|||||||
batch.scale(zoom),
|
batch.scale(zoom),
|
||||||
tooltips,
|
tooltips,
|
||||||
Box::new(move |poly| {
|
Box::new(move |poly| {
|
||||||
let color = colors.get(poly).unwrap();
|
GeomBatch::from(vec![(outline_color.alpha(0.5), poly.clone())])
|
||||||
GeomBatch::from(vec![(color.alpha(0.5), poly.clone())])
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user