mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 04:48:27 +00:00
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:
parent
5449360415
commit
729f83d8ec
1 changed files with 24 additions and 4 deletions
|
|
@ -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.,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue