summaryrefslogtreecommitdiff
path: root/bench/core_widget.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-06-01 17:09:27 -0400
committerBenji Dial <benji@benjidial.net>2023-06-01 17:09:27 -0400
commitf2b2f9b800ed182daae9c898746a4c16bd53df10 (patch)
tree0870e2cbfe619bc86bfe26f2cd7066c45343393c /bench/core_widget.cpp
parent2a75cd152585c9cfb603523f473ccebe7b720664 (diff)
downloadlib94-f2b2f9b800ed182daae9c898746a4c16bd53df10.tar.gz
give core better padding
Diffstat (limited to 'bench/core_widget.cpp')
-rw-r--r--bench/core_widget.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/bench/core_widget.cpp b/bench/core_widget.cpp
index b687a01..d1f2b78 100644
--- a/bench/core_widget.cpp
+++ b/bench/core_widget.cpp
@@ -119,9 +119,27 @@ void core_widget::draw(int width, int height) {
}
}
- cpr = width / scale;
- xpad = (width % scale) / 2;
- ypad = (height % scale) / 2;
+ cpr = width / scale + 1;
+ xpad = INT_MAX;
+ ypad = 0;
+
+ while (cpr >= 1) {
+ --cpr;
+
+ int rows = (LIB94_CORE_SIZE - 1) / cpr + 1;
+ int new_xpad = (width - cpr * scale) / 2;
+ int new_ypad = (height - rows * scale) / 2;
+
+ if (abs(new_xpad - new_ypad) < abs(xpad - ypad)) {
+ xpad = new_xpad;
+ ypad = new_ypad;
+ }
+
+ else {
+ ++cpr;
+ break;
+ }
+ }
uint8_t *buffer = (uint8_t *)pixbuf->property_pixels().get_value();