Skip to content

Commit 67c2bdd

Browse files
committed
add end-to-end test as an example on thick lines
this code previously failed getting stuck in a very very long loop. the example shows the pathological case (separately included as a unit test) but also some simple cases with with and without capping.
1 parent 1c4a931 commit 67c2bdd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

plotters/examples/thick_lines.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use plotters::prelude::*;
2+
3+
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
4+
let root = BitMapBackend::new("test.bmp", (1000, 1000)).into_drawing_area();
5+
let mut chart = ChartBuilder::on(&root)
6+
.build_cartesian_2d(0.0..1000.0, 0.0..1000.0)?;
7+
let pahts = vec![
8+
PathElement::new(
9+
vec![(336.0, 614.0), (339.0, 674.0),(341.0,714.0)],
10+
ShapeStyle::from(RED).stroke_width(2),
11+
),
12+
PathElement::new(
13+
vec![(100.0, 100.0), (150.0, 150.0),(200.0,100.0)],
14+
ShapeStyle::from(BLUE).stroke_width(2),
15+
),
16+
PathElement::new(
17+
vec![(400.0, 400.0), (400.0, 450.0),(400.0,500.0)],
18+
ShapeStyle::from(GREEN).stroke_width(5),
19+
),
20+
PathElement::new(
21+
vec![(900.0, 410.0), (600.0, 400.0),(900.0,500.0), (1000.0, 1000.0)],
22+
ShapeStyle::from(YELLOW).stroke_width(10),
23+
),
24+
];
25+
chart.draw_series(pahts.into_iter())?;
26+
Ok(())
27+
}

0 commit comments

Comments
 (0)