Fix an issue (created by commit 16cb6a6ca0) when converting a color4D to a legacy color

Fixes: lp:1704724
https://bugs.launchpad.net/kicad/+bug/1704724
This commit is contained in:
jean-pierre charras 2017-07-17 09:59:34 +02:00
parent e797af3315
commit ed66496242
2 changed files with 12 additions and 7 deletions

View File

@ -263,7 +263,7 @@ std::ostream &operator<<( std::ostream &aStream, COLOR4D const &aColor )
}
void COLOR4D::ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue ) const
void COLOR4D::ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue, bool aAlwaysDefineHue ) const
{
double min, max, delta;
@ -283,7 +283,7 @@ void COLOR4D::ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue
else // for black color (r = g = b = 0 ) saturation is set to 0.
{
aOutSaturation = 0.0;
aOutHue = 0.0;
aOutHue = aAlwaysDefineHue ? 0.0 : NAN;
return;
}
@ -309,8 +309,10 @@ void COLOR4D::ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue
if( aOutHue < 0.0 )
aOutHue += 360.0;
}
else // delta = 0 means r = g = b. hue is set to 0.0
aOutHue = 0.0;
else // delta = 0 means r = g = b. hue is set to 0.0
{
aOutHue = aAlwaysDefineHue ? 0.0 : NAN;
}
}

View File

@ -264,10 +264,13 @@ public:
* @param aOutHue is the conversion result for hue component, in degrees 0 ... 360.0
* @param aOutSaturation is the conversion result for saturation component (0 ... 1.0).
* @param aOutValue is conversion result for value component (0 ... 1.0).
* @note saturation is set to 0.0 for black color (r = v = b = 0), and
* hue is set to 0.0 if r = v = b = 0.
* @param aAlwaysDefineHue controls the way hue is defined when r = v = b
* @note saturation is set to 0.0 for black color (r = v = b = 0), and if r = v = b,
* hue is set to 0.0 if aAlwaysDefineHue = true, and set to NAN if aAlwaysDefineHue = false.
* this option is usefull to convert a 4D color to a legacy color, because Red has hue = 0,
* therefore aAlwaysDefineHue = false makes difference between Red and Gray colors.
*/
void ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue ) const;
void ToHSV( double& aOutHue, double& aOutSaturation, double& aOutValue, bool aAlwaysDefineHue = false ) const;
/**
* Function FromHSV()