aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/numeric.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h
index 6f82a18c1..864ab7543 100644
--- a/src/util/numeric.h
+++ b/src/util/numeric.h
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irr_v2d.h"
#include "irr_v3d.h"
#include "irr_aabb3d.h"
+#include "SColor.h"
#include <matrix4.h>
#define rangelim(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
@@ -432,3 +433,12 @@ inline v3f getPitchYawRoll(const core::matrix4 &m)
{
return getPitchYawRollRad(m) * core::RADTODEG64;
}
+
+// Muliply the RGB value of a color linearly, and clamp to black/white
+inline irr::video::SColor multiplyColorValue(const irr::video::SColor &color, float mod)
+{
+ return irr::video::SColor(color.getAlpha(),
+ core::clamp<u32>(color.getRed() * mod, 0, 255),
+ core::clamp<u32>(color.getGreen() * mod, 0, 255),
+ core::clamp<u32>(color.getBlue() * mod, 0, 255));
+}