clamp (h)sl values
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1695183 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e7f4d132f1
commit
4795b3d2cb
|
@ -356,15 +356,10 @@ public class DrawPaint {
|
||||||
* @returns the RGB Color object
|
* @returns the RGB Color object
|
||||||
*/
|
*/
|
||||||
private static Color HSL2RGB(double h, double s, double l, double alpha) {
|
private static Color HSL2RGB(double h, double s, double l, double alpha) {
|
||||||
if (s <0.0f || s > 100.0f) {
|
// we clamp the values, as it possible to come up with more than 100% sat/lum
|
||||||
String message = "Color parameter outside of expected range - Saturation: " + s;
|
// (see links in applyColorTransform() for more info)
|
||||||
throw new IllegalArgumentException( message );
|
s = Math.max(0, Math.min(100, s));
|
||||||
}
|
l = Math.max(0, Math.min(100, l));
|
||||||
|
|
||||||
if (l <0.0f || l > 100.0f) {
|
|
||||||
String message = "Color parameter outside of expected range - Luminance: " + l;
|
|
||||||
throw new IllegalArgumentException( message );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alpha <0.0f || alpha > 1.0f) {
|
if (alpha <0.0f || alpha > 1.0f) {
|
||||||
String message = "Color parameter outside of expected range - Alpha: " + alpha;
|
String message = "Color parameter outside of expected range - Alpha: " + alpha;
|
||||||
|
|
Loading…
Reference in New Issue