From d4a6d348f9939a6022a9f7c3724fb76ff4d20388 Mon Sep 17 00:00:00 2001 From: Cristy Date: Fri, 3 Mar 2017 18:43:30 -0500 Subject: [PATCH] ... --- MagickCore/enhance.c | 54 ++++++++------------------------------------ 1 file changed, 9 insertions(+), 45 deletions(-) diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 1a0280d99..92d8d8729 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -2947,11 +2947,7 @@ static inline void ModulateHCL(const double percent_hue, Increase or decrease color luma, chroma, or hue. */ ConvertRGBToHCL(*red,*green,*blue,&hue,&chroma,&luma); - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue > 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; chroma*=0.01*percent_chroma; luma*=0.01*percent_luma; ConvertHCLToRGB(hue,chroma,luma,red,green,blue); @@ -2970,11 +2966,7 @@ static inline void ModulateHCLp(const double percent_hue, Increase or decrease color luma, chroma, or hue. */ ConvertRGBToHCLp(*red,*green,*blue,&hue,&chroma,&luma); - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue > 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; chroma*=0.01*percent_chroma; luma*=0.01*percent_luma; ConvertHCLpToRGB(hue,chroma,luma,red,green,blue); @@ -2993,11 +2985,7 @@ static inline void ModulateHSB(const double percent_hue, Increase or decrease color brightness, saturation, or hue. */ ConvertRGBToHSB(*red,*green,*blue,&hue,&saturation,&brightness); - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue > 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; saturation*=0.01*percent_saturation; brightness*=0.01*percent_brightness; ConvertHSBToRGB(hue,saturation,brightness,red,green,blue); @@ -3016,11 +3004,7 @@ static inline void ModulateHSI(const double percent_hue, Increase or decrease color intensity, saturation, or hue. */ ConvertRGBToHSI(*red,*green,*blue,&hue,&saturation,&intensity); - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue > 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; saturation*=0.01*percent_saturation; intensity*=0.01*percent_intensity; ConvertHSIToRGB(hue,saturation,intensity,red,green,blue); @@ -3039,11 +3023,7 @@ static inline void ModulateHSL(const double percent_hue, Increase or decrease color lightness, saturation, or hue. */ ConvertRGBToHSL(*red,*green,*blue,&hue,&saturation,&lightness); - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue >= 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; saturation*=0.01*percent_saturation; lightness*=0.01*percent_lightness; ConvertHSLToRGB(hue,saturation,lightness,red,green,blue); @@ -3062,11 +3042,7 @@ static inline void ModulateHSV(const double percent_hue, Increase or decrease color value, saturation, or hue. */ ConvertRGBToHSV(*red,*green,*blue,&hue,&saturation,&value); - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue >= 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; saturation*=0.01*percent_saturation; value*=0.01*percent_value; ConvertHSVToRGB(hue,saturation,value,red,green,blue); @@ -3085,11 +3061,7 @@ static inline void ModulateHWB(const double percent_hue, Increase or decrease color blackness, whiteness, or hue. */ ConvertRGBToHWB(*red,*green,*blue,&hue,&whiteness,&blackness); - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue >= 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; blackness*=0.01*percent_blackness; whiteness*=0.01*percent_whiteness; ConvertHWBToRGB(hue,whiteness,blackness,red,green,blue); @@ -3110,11 +3082,7 @@ static inline void ModulateLCHab(const double percent_luma, ConvertRGBToLCHab(*red,*green,*blue,&luma,&chroma,&hue); luma*=0.01*percent_luma; chroma*=0.01*percent_chroma; - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue >= 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; ConvertLCHabToRGB(luma,chroma,hue,red,green,blue); } @@ -3133,11 +3101,7 @@ static inline void ModulateLCHuv(const double percent_luma, ConvertRGBToLCHuv(*red,*green,*blue,&luma,&chroma,&hue); luma*=0.01*percent_luma; chroma*=0.01*percent_chroma; - hue+=0.5*(0.01*percent_hue-1.0); - while (hue < 0.0) - hue+=1.0; - while (hue >= 1.0) - hue-=1.0; + hue+=fmod((percent_hue-100.0),200.0)/200.0; ConvertLCHuvToRGB(luma,chroma,hue,red,green,blue); } -- 2.40.0