partial fix for text drawing in wrong row

calib-gui
Ondřej Hruška 1 year ago
parent fcc37515c5
commit 0d9565dbb7
  1. 10
      Lib/ufb/Src/framebuffer.c

@ -57,7 +57,7 @@ void fb_px(fbpos_t x, fbpos_t y, fbcolor_t color)
uint8_t fb_getpx(fbpos_t x, fbpos_t y)
{
if (x >= FBW || y >= FBH) { return 0; }
if (x >= FBW || y >= FBH || x < 0 || y < 0) { return 0; }
const fbpos_t row = y / 8;
const fbpos_t rowrem = y % 8;
const fbsize_t cell = (fbsize_t) x + (fbsize_t) row * FBW;
@ -70,7 +70,7 @@ uint8_t fb_getpx(fbpos_t x, fbpos_t y)
void fb_hline(fbpos_t x, fbpos_t y, fbpos_t w, fbcolor_t color)
{
if (x >= FBW || y >= FBH) { return; }
if (x >= FBW || y >= FBH || x < -w || y < 0) { return; }
w = MIN(FBW - x, w);
const fbpos_t row = y / 8;
const fbpos_t rowrem = y % 8;
@ -83,7 +83,7 @@ void fb_hline(fbpos_t x, fbpos_t y, fbpos_t w, fbcolor_t color)
void fb_vline(fbpos_t x, fbpos_t y, fbpos_t h, fbcolor_t color)
{
if (x >= FBW || y >= FBH) { return; }
if (x >= FBW || y >= FBH || x < 0 || y < -h) { return; }
h = MIN(FBH - y - 1, h);
const fbpos_t row = y / 8;
const fbpos_t rowrem = y % 8;
@ -116,7 +116,7 @@ void fb_vline(fbpos_t x, fbpos_t y, fbpos_t h, fbcolor_t color)
void fb_rect(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbcolor_t color)
{
if (x >= FBW || y >= FBH) { return; }
if (x >= FBW || y >= FBH || x < -w || y < -h) { return; }
w = MIN(FBW - x, w);
h = MIN(FBH - y, h);
const fbpos_t row = y / 8;
@ -235,7 +235,7 @@ void fb_bitmap_ex_P(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *m
void fb_bitmap_ex(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, const uint8_t *map, fbcolor_t color)
#endif
{
if (x >= FBW || y >= FBH) { return; }
if (x >= FBW || y >= FBH || x < -w || h < -h) { return; }
const fbpos_t w0 = w;
w = MIN(FBW - x - 1, w);
h = MIN(FBH - y - 1, h);

Loading…
Cancel
Save