femtovg: clamping sim - add a stop at 1.0 on a gradient (#7909)

* femtovg: clamping sim - add a stop at 1.0  on a gradient to match the last stop set if last stop is not at 1.0
linear and radial adjusted

* [autofix.ci] apply automated fixes

* add conditional for last stop for femtovg gradients

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
szecket 2025-07-31 14:22:33 +02:00 committed by GitHub
parent 5449360415
commit 729f83d8ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1559,8 +1559,18 @@ impl<'a, R: femtovg::Renderer + TextureImporter> GLItemRenderer<'a, R> {
[path_width, path_height].into(),
);
let stops =
gradient.stops().map(|stop| (stop.position, to_femtovg_color(&stop.color)));
let mut stops: Vec<_> = gradient
.stops()
.map(|stop| (stop.position, to_femtovg_color(&stop.color)))
.collect();
// Add an extra stop at 1.0 with the same color as the last stop
if let Some(last_stop) = stops.last().cloned() {
if last_stop.0 != 1.0 {
stops.push((1.0, last_stop.1));
}
}
femtovg::Paint::linear_gradient_stops(start.x, start.y, end.x, end.y, stops)
}
Brush::RadialGradient(gradient) => {
@ -1569,8 +1579,18 @@ impl<'a, R: femtovg::Renderer + TextureImporter> GLItemRenderer<'a, R> {
let path_width = path_bounds.width();
let path_height = path_bounds.height();
let stops =
gradient.stops().map(|stop| (stop.position, to_femtovg_color(&stop.color)));
let mut stops: Vec<_> = gradient
.stops()
.map(|stop| (stop.position, to_femtovg_color(&stop.color)))
.collect();
// Add an extra stop at 1.0 with the same color as the last stop
if let Some(last_stop) = stops.last().cloned() {
if last_stop.0 != 1.0 {
stops.push((1.0, last_stop.1));
}
}
femtovg::Paint::radial_gradient_stops(
path_width / 2.,
path_height / 2.,