MCPcopy Create free account
hub / github.com/ImageOptim/libimagequant / split

Method split

src/mediancut.rs:119–131  ·  view source on GitHub ↗
(mut self)

Source from the content-addressed store, hash-verified

117
118 #[inline]
119 pub fn split(mut self) -> [Self; 2] {
120 self.prepare_sort();
121 let half_weight = self.prepare_color_weight_total() / 2.;
122 // yeah, there's some off-by-one error in there
123 let break_at = hist_item_sort_half(self.colors, half_weight).max(1);
124
125 let (left, right) = self.colors.split_at_mut(break_at);
126 let left_sum = left.iter().map(|a| f64::from(a.adjusted_weight)).sum();
127 let right_sum = self.adjusted_weight_sum - left_sum;
128
129 [MBox::from_split(left, left_sum),
130 MBox::from_split(right, right_sum)]
131 }
132}
133
134#[inline]

Callers 1

cutMethod · 0.80

Calls 3

hist_item_sort_halfFunction · 0.85
prepare_sortMethod · 0.80

Tested by

no test coverage detected