mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-19 04:12:12 +03:00
Scale text at low zoom
This commit is contained in:
parent
f584603065
commit
28b9702032
@ -29,6 +29,7 @@ impl DrawRoadLabels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn discretize_zoom(zoom: f64) -> (f64, usize) {
|
fn discretize_zoom(zoom: f64) -> (f64, usize) {
|
||||||
|
// TODO Maybe more values between 1.0 and min_zoom_for_detail?
|
||||||
if zoom >= 1.0 {
|
if zoom >= 1.0 {
|
||||||
return (1.0, 10);
|
return (1.0, 10);
|
||||||
}
|
}
|
||||||
@ -45,6 +46,9 @@ impl DrawRoadLabels {
|
|||||||
// close to each other.
|
// close to each other.
|
||||||
let mut labels_per_road: HashMap<String, Vec<Pt2D>> = HashMap::new();
|
let mut labels_per_road: HashMap<String, Vec<Pt2D>> = HashMap::new();
|
||||||
|
|
||||||
|
let scale_text = 1.0 + 2.0 * (1.0 - zoom);
|
||||||
|
//println!("at zoom {}, scale labels {}", zoom, scale_text);
|
||||||
|
|
||||||
for r in map.all_roads() {
|
for r in map.all_roads() {
|
||||||
if r.get_rank() == osm::RoadRank::Local
|
if r.get_rank() == osm::RoadRank::Local
|
||||||
|| r.is_light_rail()
|
|| r.is_light_rail()
|
||||||
@ -72,8 +76,7 @@ impl DrawRoadLabels {
|
|||||||
let txt = Text::from(Line(name).fg(Color::WHITE)).bg(Color::BLACK);
|
let txt = Text::from(Line(name).fg(Color::WHITE)).bg(Color::BLACK);
|
||||||
batch.append(
|
batch.append(
|
||||||
txt.render_autocropped(g)
|
txt.render_autocropped(g)
|
||||||
// TODO Probably based on the discretized zoom
|
.scale(scale_text)
|
||||||
.scale(1.0)
|
|
||||||
.centered_on(pt)
|
.centered_on(pt)
|
||||||
.rotate_around_batch_center(angle.reorient()),
|
.rotate_around_batch_center(angle.reorient()),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user