Fixed Plot Line::fill does not fill last segment correctly (#2275)

* Fix missing vertex to fill the triangle

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
WesleyCh3n 2022-11-10 22:00:20 +08:00 committed by GitHub
parent b1e71d308f
commit b2edbe617e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -447,7 +447,7 @@ impl PlotItem for Line {
let expected_intersections = 20;
mesh.reserve_triangles((n_values - 1) * 2);
mesh.reserve_vertices(n_values * 2 + expected_intersections);
values_tf[0..n_values - 1].windows(2).for_each(|w| {
values_tf.windows(2).for_each(|w| {
let i = mesh.vertices.len() as u32;
mesh.colored_vertex(w[0], fill_color);
mesh.colored_vertex(pos2(w[0].x, y), fill_color);