fix erroneous indexed_color results
This commit is contained in:
parent
36920fb071
commit
d2ed0152f1
|
@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed erroneous results when using the `indexed_colors` config option
|
||||||
|
|
||||||
## Version 0.2.1
|
## Version 0.2.1
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -101,24 +101,19 @@ impl List {
|
||||||
for r in 0..6 {
|
for r in 0..6 {
|
||||||
for g in 0..6 {
|
for g in 0..6 {
|
||||||
for b in 0..6 {
|
for b in 0..6 {
|
||||||
// Index of the color is number of named colors + rgb
|
|
||||||
let color_index = 16 + r + g + b;
|
|
||||||
|
|
||||||
// Override colors 16..232 with the config (if present)
|
// Override colors 16..232 with the config (if present)
|
||||||
if let Some(indexed_color) = colors
|
if let Some(indexed_color) = colors
|
||||||
.indexed_colors
|
.indexed_colors
|
||||||
.iter()
|
.iter()
|
||||||
.find(|ic| ic.index == color_index)
|
.find(|ic| ic.index == index as u8)
|
||||||
{
|
{
|
||||||
self[index] = indexed_color.color;
|
self[index] = indexed_color.color;
|
||||||
index += 1;
|
} else {
|
||||||
continue;
|
self[index] = Rgb { r: if r == 0 { 0 } else { r * 40 + 55 },
|
||||||
|
b: if b == 0 { 0 } else { b * 40 + 55 },
|
||||||
|
g: if g == 0 { 0 } else { g * 40 + 55 },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
self[index] = Rgb { r: if r == 0 { 0 } else { r * 40 + 55 },
|
|
||||||
b: if b == 0 { 0 } else { b * 40 + 55 },
|
|
||||||
g: if g == 0 { 0 } else { g * 40 + 55 },
|
|
||||||
};
|
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue