Open sbmrgd opened 5 years ago
Possible. Let me check
I tried to highlight the 2 lines of code (with ) that show the issue: in fill rectangle, x goes from x0 until x1-1 while in drawColumn, y goes from sy until ey.
void Display::fillRectangle(int16_t x0,int16_t y0, int16_t w, int16_t h){
int16_t x,y,x1,y1;
x1=x0+w;y1=y0+h;
if ((x0<0 && x1<0) || (x0>=width && x1 >=width)) return; //completely out of bounds
if ((y0<0 && y1<0) || (y0>=height && y1 >=height)) return; //completely out of bounds
if (x0>x1) {x=x1;x1=x0;}
else x=x0;
if (y0>y1) {y=y1;y1=y0;}
else y=y0;
if (x<0) x=0;
if (y<0) y=0;
**for (;x<x1;x++) drawColumn(x,y,y1);**
}
void Display::drawColumn(int16_t x, int16_t sy, int16_t ey){
if ((uint16_t)sy>=height && (uint16_t)ey>=height) return; //completely out of bounds
if ((uint16_t)x>=width) return; //completely out of bounds
if (sy>ey) {
int y=sy;
sy=ey;
ey=y; // swap around so that x0 is less than x1
}
**for (int y=sy; y <= ey; y++)** {
drawPixel(x,y);
}
}
I think this is easily fixed, but as I am only a beginner I don't feel comfortable to do pull requests etc.
fillRectangle(x0,y0, s,s)
does not draw a square it seems to me, because the x-range goes from x0 till x0+s-1, while the y-range goes from y0 till y0+s