summaryrefslogtreecommitdiffstats
path: root/thirdparty/thorvg/src/common/tvgMath.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/thorvg/src/common/tvgMath.h')
-rw-r--r--thirdparty/thorvg/src/common/tvgMath.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/thirdparty/thorvg/src/common/tvgMath.h b/thirdparty/thorvg/src/common/tvgMath.h
index df39e3b9af..50786754a1 100644
--- a/thirdparty/thorvg/src/common/tvgMath.h
+++ b/thirdparty/thorvg/src/common/tvgMath.h
@@ -26,7 +26,7 @@
#define _USE_MATH_DEFINES
#include <float.h>
-#include <math.h>
+#include <cmath>
#include "tvgCommon.h"
#define MATH_PI 3.14159265358979323846f
@@ -68,6 +68,13 @@ static inline bool mathEqual(float a, float b)
}
+template <typename T>
+static inline void mathClamp(T& v, const T& min, const T& max)
+{
+ if (v < min) v = min;
+ else if (v > max) v = max;
+}
+
/************************************************************************/
/* Matrix functions */
/************************************************************************/