Skip to content

Conversation

@Yohsi
Copy link
Contributor

@Yohsi Yohsi commented Aug 22, 2025

The gradient fill color for point N was incorrectly computed using the coordinates of point N+1. In adition, the corner case where the line crossed the reference line was also handled incorrectly.

This caused a visible offset, as shown in the screenshot below (notice how the line color and the fill color do not match).

With this fix, the line and fill colors now match exactly:

Code used for the screenshots
Line::new(
    "line",
    vec![[-1.0, 0.8], [0.1, 0.2], [0.5, -0.8], [1.3, 0.6]],
)
.gradient_color(
    Arc::new(|point| {
        Color32::BLUE.lerp_to_gamma(Color32::RED, (point.y as f32 + 1.0) / 2.0)
    }),
    true,
)
.fill(0.0)
.fill_alpha(1.0)

Copy link
Contributor

@bircni bircni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to adjust some tests?
else lgtm

@Yohsi
Copy link
Contributor Author

Yohsi commented Aug 22, 2025

I don't see any tests for this gradient fill feature, so I don't think so.

Note: when running cargo test, some demo tests are somehow failing on my machine (scale_1.39, Items, Linked Axes, light_mode) , but they are failing on main as well. It is only a few pixels difference.

@emilk emilk added bug Something isn't working include in changelog This change will be included in the changelog labels Oct 10, 2025
@emilk emilk merged commit cef89f1 into emilk:main Oct 10, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working include in changelog This change will be included in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants