Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill plot area when using min/max down sampling #74

Open
CramBL opened this issue Oct 13, 2024 · 2 comments
Open

Fill plot area when using min/max down sampling #74

CramBL opened this issue Oct 13, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@CramBL
Copy link
Contributor

CramBL commented Oct 13, 2024

Can be achieved by painting trapezoids between the plots like this:

fn create_filled_segments(line1: &[[f64; 2]], line2: &[[f64; 2]]) -> Vec<Polygon> {
    let mut segments = Vec::new();

    for i in 0..(line1.len() - 1) {
        // Create a trapezoid between line1[i], line1[i+1], line2[i+1], and line2[i]
        let mut points = Vec::new();
        points.push(line1[i]);
        points.push(line1[i + 1]);
        points.push(line2[i + 1]);
        points.push(line2[i]);

        // Create a polygon for this segment
        let polygon = Polygon::new(PlotPoints::new(points))
            .fill_color(Color32::from_rgba_premultiplied(100, 40, 50, 0))
            .stroke(Stroke::NONE);
        segments.push(polygon);
    }

    segments
}
@CramBL CramBL added the enhancement New feature or request label Oct 13, 2024
@CramBL
Copy link
Contributor Author

CramBL commented Oct 15, 2024

This is more complicated that it seems... Polygons has to be convex, and drawing it like the approach above ends up painting areas outside the min/max area between plots.

Going with a triangles approach also doesn't work, if the triangle has one very large angle and two small then visual artifacts appear that stretch the corner with small angles beyond the points where they actually end.

@CramBL
Copy link
Contributor Author

CramBL commented Oct 18, 2024

The issue is already reported at egui_plot: emilk/egui_plot#36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant