forked from danielalvsaaker/staticmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline.rs
42 lines (34 loc) · 954 Bytes
/
line.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use staticmap::{
tools::{Color, LineBuilder},
Error, StaticMapBuilder,
};
fn main() -> Result<(), Error> {
let mut map = StaticMapBuilder::new()
.width(300)
.height(400)
.padding((10, 0))
.build()
.unwrap();
let lat: &[f64] = &[52.5, 48.9];
let lon: Vec<f64> = vec![13.4, 2.3];
let red = Color::new(true, 255, 0, 0, 255);
let white = Color::new(true, 255, 255, 255, 255);
let line = LineBuilder::new()
.lat_coordinates(lat.into_iter().copied())
.lon_coordinates(lon.clone())
.width(3.)
.simplify(true)
.color(red)
.build()?;
let underline = LineBuilder::new()
.lat_coordinates(lat.into_iter().copied())
.lon_coordinates(lon)
.width(5.)
.simplify(true)
.color(white)
.build()?;
map.add_tool(underline);
map.add_tool(line);
map.save_png("line.png")?;
Ok(())
}