stop searching for color matches if this color is an exact match
probably very rarely ever an optimization in real-world use, but it still seems like the logical thing to do
This commit is contained in:
parent
d9739b4e3e
commit
fb101db0ac
|
@ -483,6 +483,9 @@ impl Palette {
|
||||||
for (index, color) in self.colors.iter().enumerate() {
|
for (index, color) in self.colors.iter().enumerate() {
|
||||||
let (this_r, this_g, this_b) = from_rgb32(*color);
|
let (this_r, this_g, this_b) = from_rgb32(*color);
|
||||||
|
|
||||||
|
if r == this_r && g == this_g && b == this_b {
|
||||||
|
return index as u8;
|
||||||
|
} else {
|
||||||
// this comparison method is using the sRGB Euclidean formula described here:
|
// this comparison method is using the sRGB Euclidean formula described here:
|
||||||
// https://en.wikipedia.org/wiki/Color_difference
|
// https://en.wikipedia.org/wiki/Color_difference
|
||||||
|
|
||||||
|
@ -495,6 +498,7 @@ impl Palette {
|
||||||
closest_distance = distance;
|
closest_distance = distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
closest
|
closest
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue