summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar shan <shankern@protonmail.com>2022-09-29 14:01:57 -0700
committerLibravatar shan <shankern@protonmail.com>2022-09-29 14:01:57 -0700
commit734557bda5924e563a9f0b39aca37d5953fcda5c (patch)
tree2ca70970c7d7918eed6750db7d8ae47d8fa7cc03 /graphics
parent91b5ab6ab3aee1103a834d25198e5d0d9c5d73f5 (diff)
downloadiced-734557bda5924e563a9f0b39aca37d5953fcda5c.tar.gz
iced-734557bda5924e563a9f0b39aca37d5953fcda5c.tar.bz2
iced-734557bda5924e563a9f0b39aca37d5953fcda5c.zip
Fixed issue where stops could be declared out of order in the builder but must be sorted before being passed to shader.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/widget/canvas/gradient/linear.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/graphics/src/widget/canvas/gradient/linear.rs b/graphics/src/widget/canvas/gradient/linear.rs
index 37533e19..1dc7e3a8 100644
--- a/graphics/src/widget/canvas/gradient/linear.rs
+++ b/graphics/src/widget/canvas/gradient/linear.rs
@@ -57,17 +57,17 @@ impl Builder {
return None;
}
+ let mut stops: Vec<ColorStop> = self.stops.clone().into_iter().map(|f| ColorStop {
+ offset: f.0,
+ color: f.1
+ }).collect();
+
+ stops.sort_by(|a, b| a.offset.partial_cmp(&b.offset).unwrap());
+
Some(Gradient::Linear(Linear {
start: self.start,
end: self.end,
- color_stops: self
- .stops
- .into_iter()
- .map(|f| ColorStop {
- offset: f.0,
- color: f.1,
- })
- .collect(),
+ color_stops: stops
}))
}
}