resolve method
Implementation
Color resolve(GhosttyTerminalColor? color, {required Color fallback}) {
if (color == null) {
return fallback;
}
if (!color.isPalette) {
return Color(0xFF000000 | color.rgb!);
}
final index = color.paletteIndex!;
if (index >= 0 && index < ansi.length) {
return ansi[index];
}
if (index >= 16 && index <= 231) {
final cubeIndex = index - 16;
const levels = <int>[0, 95, 135, 175, 215, 255];
final red = levels[(cubeIndex ~/ 36) % 6];
final green = levels[(cubeIndex ~/ 6) % 6];
final blue = levels[cubeIndex % 6];
return Color.fromARGB(0xFF, red, green, blue);
}
if (index >= 232 && index <= 255) {
final value = 8 + (index - 232) * 10;
return Color.fromARGB(0xFF, value, value, value);
}
return fallback;
}