Summary Files Commits Branches @commit @diff @stats
path: root / src / LEDVideoWall.cpp
diff options
context:
space:
mode:
1 files changed, 15 insertions, 0 deletions
-rw-r--r--src/LEDVideoWall.cpp15
diff --git a/src/LEDVideoWall.cpp b/src/LEDVideoWall.cpp
index e235aa2..5fb69ac 100644
--- a/src/LEDVideoWall.cpp
+++ b/src/LEDVideoWall.cpp
@@ -14,7 +14,22 @@ LEDVideoWall* LEDVideoWall::Freeform(mm panel_width, mm panel_height, mm wall_ma
rows);
}
+#define CMP_EPSILON 0.0000001
+
+// GCD is available in stl from C++17 onwards, but I'm still reimplementing it
+unsigned int gcd(unsigned int a, unsigned int b) {
+ if (a == b) return a;
+ if (a < b) return gcd(b, a);
+ return gcd(a - b, b);
+}
+
LEDVideoWall* LEDVideoWall::Aspect(mm panel_width, mm panel_height, unsigned int aspect_width, unsigned int aspect_height) {
+ // Simplify the fraction (aspect), because we want the smallest screen size
+ // For example, turn 16:10 into 8:5
+ unsigned int aspect_gcd = gcd(aspect_width, aspect_height);
+ aspect_width /= aspect_gcd;
+ aspect_height /= aspect_gcd;
+
return new LEDVideoWall(
aspect_width * panel_width,
aspect_height * panel_height,