Consistently draw rectangles
@@ -870,6 +870,8 @@ ENGINE_ellipse(ENGINE* engine, int64_t x0, int64_t y0, int64_t x1, int64_t y1, u
internal void
ENGINE_rect(ENGINE* engine, int64_t x, int64_t y, int64_t w, int64_t h, uint32_t c) {
+ w = w - 1;
+ h = h - 1;
ENGINE_line(engine, x, y, x, y+h, c, 1);
ENGINE_line(engine, x, y, x+w, y, c, 1);
ENGINE_line(engine, x, y+h, x+w, y+h, c, 1);
@@ -883,12 +885,12 @@ ENGINE_rectfill(ENGINE* engine, int64_t x, int64_t y, int64_t w, int64_t h, uint
return;
} else {
int64_t y1 = y;
- int64_t y2 = y + h;
+ int64_t y2 = y + h - 1;
if (alpha == 0xFF) {
- size_t lineWidth = w+1; // x2 - x1;
+ size_t lineWidth = w; // x2 - x1;
uint32_t buf[lineWidth];
- for (size_t i = 0; i < lineWidth; i++) {
+ for (size_t i = 0; i <= lineWidth; i++) {
buf[i] = c;
}
for (int64_t j = y1; j <= y2; j++) {
@@ -896,7 +898,7 @@ ENGINE_rectfill(ENGINE* engine, int64_t x, int64_t y, int64_t w, int64_t h, uint
}
} else {
int64_t x1 = x;
- int64_t x2 = x + w;
+ int64_t x2 = x + w - 1;
for (int64_t j = y1; j <= y2; j++) {
for (int64_t i = x1; i <= x2; i++) {
