diff options
author | Hugues Ross <hugues.ross@gmail.com> | 2020-04-11 16:39:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-11 21:39:30 +0100 |
commit | f780bae05cc2fdd23a6d7326c770783da8d94ea3 (patch) | |
tree | 31d7e764d86e9f5731c3d3a4e35c598cdc7f777c /src/util | |
parent | ba3587e7769113fed9a076ae2e4d2153686fb163 (diff) | |
download | minetest-f780bae05cc2fdd23a6d7326c770783da8d94ea3.tar.gz minetest-f780bae05cc2fdd23a6d7326c770783da8d94ea3.tar.bz2 minetest-f780bae05cc2fdd23a6d7326c770783da8d94ea3.zip |
Formspecs: Add state-selection to style elements (#9378)
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/numeric.h | 10 |
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)); +} |