summaryrefslogtreecommitdiff
path: root/bench/core_widget.cpp
diff options
context:
space:
mode:
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();