give core better padding

This commit is contained in:
Benji Dial 2023-06-01 17:09:27 -04:00
parent 2a75cd1525
commit f2b2f9b800

View file

@ -119,9 +119,27 @@ void core_widget::draw(int width, int height) {
} }
} }
cpr = width / scale; cpr = width / scale + 1;
xpad = (width % scale) / 2; xpad = INT_MAX;
ypad = (height % scale) / 2; 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(); uint8_t *buffer = (uint8_t *)pixbuf->property_pixels().get_value();