mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Merge d036e02bb007a6aeaff1beb12451d954a17d9b44 into 9b09146a6b5e936966ed7ee73bce9dd2df3810ae
This commit is contained in:
commit
8792a3299c
@ -1290,9 +1290,21 @@ fn sample_stops(stops: &[(Color, Ratio)], mixing_space: ColorSpace, t: f64) -> C
|
||||
if low == 0 {
|
||||
low = 1;
|
||||
}
|
||||
if t == 1.0 {
|
||||
while stops[low - 1].1 >= stops[low].1 {
|
||||
low -= 1;
|
||||
}
|
||||
} else {
|
||||
while stops[low - 1].1 >= stops[low].1 {
|
||||
low += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let (col_0, pos_0) = stops[low - 1];
|
||||
let (col_1, pos_1) = stops[low];
|
||||
debug_assert!(pos_0 < pos_1);
|
||||
debug_assert!(pos_0.get() <= t);
|
||||
debug_assert!(t <= pos_1.get());
|
||||
let t = (t - pos_0.get()) / (pos_1.get() - pos_0.get());
|
||||
|
||||
Color::mix_iter(
|
||||
|
BIN
tests/ref/issue-6162-coincident-gradient-stops-export-png.png
Normal file
BIN
tests/ref/issue-6162-coincident-gradient-stops-export-png.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 522 B |
@ -666,3 +666,29 @@ $ A = mat(
|
||||
#let _ = gradient.linear(..my-gradient.stops())
|
||||
#let my-gradient2 = gradient.linear(red, blue).repeat(5, mirror: true)
|
||||
#let _ = gradient.linear(..my-gradient2.stops())
|
||||
|
||||
--- issue-6162-coincident-gradient-stops-export-png ---
|
||||
// Ensure that multiple gradient stops with the same position
|
||||
// don't cause a panic.
|
||||
#rect(
|
||||
fill: gradient.linear(
|
||||
(red, 0%),
|
||||
(green, 0%),
|
||||
(blue, 100%),
|
||||
)
|
||||
)
|
||||
#rect(
|
||||
fill: gradient.linear(
|
||||
(red, 0%),
|
||||
(green, 100%),
|
||||
(blue, 100%),
|
||||
)
|
||||
)
|
||||
#rect(
|
||||
fill: gradient.linear(
|
||||
(white, 0%),
|
||||
(red, 50%),
|
||||
(green, 50%),
|
||||
(blue, 100%),
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user