solveToInt static method
Finds an sRGB color with the given hue, chroma, and L*, if possible.
Returns a hexadecimal representing a sRGB color with its hue,
chroma, and L* sufficiently close to hueDegrees, chroma, and
lstar, respectively. If it is impossible to satisfy all three
constraints, the hue and L* will be sufficiently close, and the
chroma will be maximized.
Implementation
static int solveToInt(
double hueDegrees,
double chroma,
double lstar, [
String callSite = '?',
]) {
final sc = _sc;
if (chroma < 0.0001 || lstar < 0.0001 || lstar > 99.9999) {
final y = yFromLstar(lstar);
final v = y / sc.kSum;
final c = _delinearSrgb(v);
return 0xFF000000 | (c << 16) | (c << 8) | c;
}
hueDegrees = sanitizeDegreesDouble(hueDegrees);
final hueRadians = hueDegrees / 180 * pi;
final y = yFromLstar(lstar);
final exact = _findResultByJSrgb(sc, hueRadians, chroma, y);
if (exact != null) {
return 0xFF000000 |
(_delinearSrgb(exact.$1) << 16) |
(_delinearSrgb(exact.$2) << 8) |
_delinearSrgb(exact.$3);
}
final (linR, linG, linB) = _bisectToLimitSrgb(sc, y, hueRadians);
return 0xFF000000 |
(_delinearSrgb(linR) << 16) |
(_delinearSrgb(linG) << 8) |
_delinearSrgb(linB);
}