mirror of
https://github.com/typst/typst
synced 2025-08-23 19:24:14 +08:00
Make behavior match PDF backend behavior again
This commit is contained in:
parent
0e567ad697
commit
52ff5964e6
@ -1287,13 +1287,19 @@ fn sample_stops(stops: &[(Color, Ratio)], mixing_space: ColorSpace, t: f64) -> C
|
||||
assert!(!stops.is_empty(), "Cannot sample from gradient with no stops");
|
||||
|
||||
let t = t.clamp(0.0, 1.0);
|
||||
let j = stops.partition_point(|(_, ratio)| ratio.get() < t);
|
||||
let mut j = stops.partition_point(|(_, ratio)| ratio.get() < t);
|
||||
|
||||
if j == 0 {
|
||||
return stops[0].0;
|
||||
while stops.get(j + 1).is_some_and(|(_, r)| r.is_zero()) {
|
||||
j += 1;
|
||||
}
|
||||
return stops[j].0;
|
||||
}
|
||||
if j == stops.len() {
|
||||
return stops.last().unwrap().0;
|
||||
while j > 0 && stops[j].1.is_one() {
|
||||
j -= 1;
|
||||
}
|
||||
return stops[j].0;
|
||||
}
|
||||
|
||||
let (col_0, pos_0) = stops[j - 1];
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 522 B |
Loading…
x
Reference in New Issue
Block a user