summaryrefslogtreecommitdiff
path: root/frontend/shared_cpp
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/shared_cpp')
-rw-r--r--frontend/shared_cpp/mathlib.cpp11
-rw-r--r--frontend/shared_cpp/mathlib.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/frontend/shared_cpp/mathlib.cpp b/frontend/shared_cpp/mathlib.cpp
new file mode 100644
index 0000000..8222d00
--- /dev/null
+++ b/frontend/shared_cpp/mathlib.cpp
@@ -0,0 +1,11 @@
+#include "mathlib.h"
+#include <cstdlib>
+
+Vector2 getRandomNormalVector2() {
+ Vector2 retval = {
+ static_cast<float>(rand()) / static_cast<float>(RAND_MAX),
+ static_cast<float>(rand()) / static_cast<float>(RAND_MAX)
+ };
+
+ return retval.normalize();
+}
diff --git a/frontend/shared_cpp/mathlib.h b/frontend/shared_cpp/mathlib.h
index a08ec39..3ed61cd 100644
--- a/frontend/shared_cpp/mathlib.h
+++ b/frontend/shared_cpp/mathlib.h
@@ -110,6 +110,10 @@ struct Vector4 {
float scale = 1.f / 255.f;
return { r * scale, g * scale, b * scale, a * scale };
}
+
+ Vector4 toNormalizedColor() {
+ return fromColor(x, y, z, w);
+ }
};
struct Mat4x4 {