From f2b2f9b800ed182daae9c898746a4c16bd53df10 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 1 Jun 2023 17:09:27 -0400 Subject: give core better padding --- bench/core_widget.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'bench/core_widget.cpp') 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(); -- cgit v1.2.3