ST7789-STM32-uGUI
ST7789-STM32-uGUI copied to clipboard
UG_DrawRoundFrame and UG_FillRoundFrame do rounded corners differently
Hi It seems that UG_DrawRoundFrame is making nice rounded corners while UG_FillRoundFrame is making flat ones that look like you cut them with scissors (2x 45 degrees).
When I add the lines below to the end of UG_FillRoundFrame function it fixes that.
UG_DrawArc(x1+r, y1+r, r, 0x0C, c); UG_DrawArc(x2-r, y1+r, r, 0x03, c); UG_DrawArc(x1+r, y2-r, r, 0x30, c); UG_DrawArc(x2-r, y2-r, r, 0xC0, c);
I pulled them out of UG_DrawRoundFrame.
Maybe... ?
void UG_FillRoundFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_S16 r, UG_COLOR c )
{
UG_S16 x,y,xd;
if ( x2 < x1 )
swap(x1,x2);
if ( y2 < y1 )
swap(y1,y2);
if ( r<=0 ) return;
xd = 3 - (r << 1);
x = 0;
y = r;
UG_FillFrame(x1 + r, y1, x2 - r, y2, c);
while ( x <= y )
{
if( y > 0 )
{
UG_DrawLine(x2 + x - r, y1 - y + r, x2+ x - r, y + y2 - r, c);
UG_DrawLine(x1 - x + r, y1 - y + r, x1- x + r, y + y2 - r, c);
}
if( x > 0 )
{
UG_DrawLine(x1 - y + r, y1 - x + r, x1 - y + r, x + y2 - r, c);
UG_DrawLine(x2 + y - r, y1 - x + r, x2 + y - r, x + y2 - r, c);
}
if ( xd < 0 )
{
xd += (x << 2) + 6;
}
else
{
xd += ((x - y) << 2) + 10;
y--;
}
x++;
}
UG_DrawRoundFrame(x1, y1, x2, y2, r, c );
}
This one works too but I don't know if it's faster or not
It should perform pretty much the same. Please note I'm not the author of uGUI neither I'm developing this fork anymore. My main contribution was adding a new font structure and UTF-8 support. If this works for you consider making a pull request. Thanks!
Yeah, this works for me but I have no idea how to create a pull request with this patch since I've never used this feature before