Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitde14e63ab5a26f26e08a9ae33f456465d466776f (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-07-23 14:58:23 +0300
Committer
 Syndamia <kamen@syndamia.com>
2025-07-23 14:58:23 +0300
Files695d96389a02cc2ea98435947f9440c9726f4856
screen-generator-nemetschek-de14e63ab5a26f26e08a9ae33f456465d466776f.tar
screen-generator-nemetschek-de14e63ab5a26f26e08a9ae33f456465d466776f.tar.gz
screen-generator-nemetschek-de14e63ab5a26f26e08a9ae33f456465d466776f.zip
Parenta876a695ee15557c6a95c64a4f6c268a0c587660 (diff)
feat: Simplify aspect fraction
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,