From 734557bda5924e563a9f0b39aca37d5953fcda5c Mon Sep 17 00:00:00 2001 From: shan Date: Thu, 29 Sep 2022 14:01:57 -0700 Subject: Fixed issue where stops could be declared out of order in the builder but must be sorted before being passed to shader. --- graphics/src/widget/canvas/gradient/linear.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'graphics/src') 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 = 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 })) } } -- cgit