From f67aa36e3b7e7435a19902c95d9ff46954d18993 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 6 Sep 2012 12:11:31 +0100 Subject: [PATCH] color: Simplify shade() implementation We can use the CLAMP macro, instead of a bunch of ifs. --- clutter/clutter-color.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/clutter/clutter-color.c b/clutter/clutter-color.c index 1f8a11d27..03ffce19e 100644 --- a/clutter/clutter-color.c +++ b/clutter/clutter-color.c @@ -384,17 +384,8 @@ clutter_color_shade (const ClutterColor *color, clutter_color_to_hls (color, &h, &l, &s); - l *= factor; - if (l > 1.0) - l = 1.0; - else if (l < 0) - l = 0; - - s *= factor; - if (s > 1.0) - s = 1.0; - else if (s < 0) - s = 0; + l = CLAMP (l * factor, 0.0, 1.0); + s = CLAMP (s * factor, 0.0, 1.0); clutter_color_from_hls (result, h, l, s);