summaryrefslogtreecommitdiff
path: root/math.cpp
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-12-13 11:42:52 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-12-13 11:42:52 -0500
commite7330bacc808cfc54cc9f7b46f12295811edee65 (patch)
tree9495a77c88bcf2b3af7d871bcfb47976dbda06a4 /math.cpp
parent442bb01af8b9cbf88189a4d2368548f41149413f (diff)
evolve menu working well
Diffstat (limited to 'math.cpp')
-rw-r--r--math.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/math.cpp b/math.cpp
index 0050d7a..568c306 100644
--- a/math.cpp
+++ b/math.cpp
@@ -701,6 +701,12 @@ static void gl_quad(float x1, float y1, float x2, float y2) {
glVertex2f(x1, y2);
}
+// returns average of red green and blue components of color
+static float rgba_brightness(u32 color) {
+ u8 r = (u8)(color >> 24), g = (u8)(color >> 16), b = (u8)(color >> 8);
+ return ((float)r+(float)g+(float)b) * (1.0f / 3);
+}
+
static float rects_intersect(Rect r1, Rect r2) {
if (r1.pos.x >= r2.pos.x + r2.size.x) return false; // r1 is to the right of r2
if (r2.pos.x >= r1.pos.x + r1.size.x) return false; // r2 is to the right of r1