Skip to content

Commit 22729d4

Browse files
committed
fix(color): Fix transform filter mappings
1 parent 56a14b4 commit 22729d4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/color.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -309,19 +309,19 @@ impl ChannelAdjustmentsBuilder {
309309

310310
pub fn build(&self) -> ChannelAdjustments {
311311
let mut adjustments = SlotMap::with_capacity(self.adjustments.len());
312-
let mut led_mappings = Vec::with_capacity(self.led_count as _);
312+
let mut led_mappings = vec![None; self.led_count as _];
313313

314314
for adjustment in &self.adjustments {
315315
match &adjustment.leds {
316316
LedMatch::All => {
317317
let key = adjustments.insert(adjustment.data);
318-
led_mappings.fill(key);
318+
led_mappings.fill(Some(key));
319319
}
320320
LedMatch::Ranges(ranges) => {
321321
let key = adjustments.insert(adjustment.data);
322322
for range in &ranges.ranges {
323323
if let Some(range) = led_mappings.get_mut(range.clone()) {
324-
range.fill(key);
324+
range.fill(Some(key));
325325
} else {
326326
error!(range = ?range, led_count = %self.led_count, "invalid range");
327327
}
@@ -341,7 +341,7 @@ impl ChannelAdjustmentsBuilder {
341341
#[derive(Debug, Clone)]
342342
pub struct ChannelAdjustments {
343343
adjustments: SlotMap<DefaultKey, ColorAdjustmentData>,
344-
led_mappings: Vec<DefaultKey>,
344+
led_mappings: Vec<Option<DefaultKey>>,
345345
}
346346

347347
impl ChannelAdjustments {
@@ -350,7 +350,8 @@ impl ChannelAdjustments {
350350
if let Some(adjustment) = self
351351
.led_mappings
352352
.get(i)
353-
.and_then(|key| self.adjustments.get(*key))
353+
.and_then(|key| *key)
354+
.and_then(|key| self.adjustments.get(key))
354355
{
355356
// TODO: Actual 16-bit color?
356357
*led = color_to16(adjustment.apply(color_to8(*led)));

0 commit comments

Comments
 (0)