getQuantizedColor method
Find the index of the closest color to c
in the colorMap.
Implementation
@override
Color getQuantizedColor(Color c) {
var r = c.r as int;
var g = c.g as int;
var b = c.b as int;
_OctreeNode? root = _root;
for (var bit = 1 << 7; bit != 0; bit >>= 1) {
final i = ((g & bit) != 0 ? 1 : 0) * 4 +
((r & bit) != 0 ? 1 : 0) * 2 +
((b & bit) != 0 ? 1 : 0);
if (root!.children[i] == null) {
break;
}
root = root.children[i];
}
r = root!.r;
g = root.g;
b = root.b;
return ColorRgb8(r, g, b);
}