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) {
if (chroma < 0.0001 || lstar < 0.0001 || lstar > 99.9999) {
return ColorUtils.argbFromLstar(lstar);
}
hueDegrees = MathUtils.sanitizeDegreesDouble(hueDegrees);
final hueRadians = hueDegrees / 180 * pi;
final y = ColorUtils.yFromLstar(lstar);
final exactAnswer = _findResultByJ(hueRadians, chroma, y);
if (exactAnswer != 0) {
return exactAnswer;
}
final linrgb = _bisectToLimit(y, hueRadians);
return ColorUtils.argbFromLinrgb(linrgb);
}