shuffle the mapnik::hue_to_rgb method - no need for it to be in the cpp file

This commit is contained in:
Dane Springmeyer 2012-08-28 20:08:43 -07:00
parent 6aa9043352
commit de5970f45e
2 changed files with 13 additions and 31 deletions

View file

@ -106,7 +106,19 @@ struct alpha_conv_impl
};
// http://www.w3.org/TR/css3-color/#hsl-color
inline double hue_to_rgb( double m1, double m2, double h);
inline double hue_to_rgb( double m1, double m2, double h)
{
if (h < 0.0) h = h + 1.0;
else if (h > 1) h = h - 1.0;
if (h * 6 < 1.0)
return m1 + (m2 - m1) * h * 6.0;
if (h * 2 < 1.0)
return m2;
if (h * 3 < 2.0)
return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0;
return m1;
}
struct hsl_conv_impl
{
@ -396,22 +408,6 @@ struct alpha_conv_impl
}
};
// http://www.w3.org/TR/css3-color/#hsl-color
inline double hue_to_rgb( double m1, double m2, double h)
{
if (h < 0.0) h = h + 1.0;
else if (h > 1) h = h - 1.0;
if (h * 6 < 1.0)
return m1 + (m2 - m1) * h * 6.0;
if (h * 2 < 1.0)
return m2;
if (h * 3 < 2.0)
return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0;
return m1;
}
struct hsl_conv_impl
{
template<typename T0,typename T1, typename T2, typename T3>

View file

@ -183,20 +183,6 @@ named_colors_::named_colors_()
;
}
double hue_to_rgb( double m1, double m2, double h)
{
if (h < 0.0) h = h + 1.0;
else if (h > 1) h = h - 1.0;
if (h * 6 < 1.0)
return m1 + (m2 - m1) * h * 6.0;
if (h * 2 < 1.0)
return m2;
if (h * 3 < 2.0)
return m1 + (m2 - m1)* (2.0/3.0 - h) * 6.0;
return m1;
}
template struct mapnik::css_color_grammar<std::string::const_iterator>;
}