Merge pull request #78 from BlaXpirit/feature/color_subtract

Added subtract function for Colors
This commit is contained in:
Laurent Gomila committed 2015-05-01 22:21:06 +02:00
commit 4069448128
2 files changed
+26

No files matched your search

+11
View File
@@ -109,6 +109,17 @@ CSFML_GRAPHICS_API sfUint32 sfColor_toInteger(sfColor color);
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfColor_add(sfColor color1, sfColor color2);
////////////////////////////////////////////////////////////
/// \brief Subtract two colors
///
/// \param color1 First color
/// \param color2 Second color
///
/// \return Component-wise saturated subtraction of the two colors
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API sfColor sfColor_subtract(sfColor color1, sfColor color2);
////////////////////////////////////////////////////////////
/// \brief Modulate two colors
///
+15
View File
@@ -97,6 +97,21 @@ sfColor sfColor_add(sfColor color1, sfColor color2)
}
////////////////////////////////////////////////////////////
sfColor sfColor_subtract(sfColor color1, sfColor color2)
{
int red = std::max(color1.r - color2.r, 0);
int green = std::max(color1.g - color2.g, 0);
int blue = std::max(color1.b - color2.b, 0);
int alpha = std::max(color1.a - color2.a, 0);
return sfColor_fromRGBA(static_cast<sfUint8>(red),
static_cast<sfUint8>(green),
static_cast<sfUint8>(blue),
static_cast<sfUint8>(alpha));
}
////////////////////////////////////////////////////////////
sfColor sfColor_modulate(sfColor color1, sfColor color2)
{