Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UG_DrawRoundFrame and UG_FillRoundFrame do rounded corners differently #8

Open
awocrf opened this issue Nov 9, 2023 · 5 comments
Open

Comments

@awocrf
Copy link

awocrf commented Nov 9, 2023

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).

@awocrf
Copy link
Author

awocrf commented Nov 9, 2023

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.

@deividAlfa
Copy link
Owner

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 );
}

@awocrf
Copy link
Author

awocrf commented Nov 13, 2023

This one works too but I don't know if it's faster or not

@awocrf awocrf closed this as completed Nov 13, 2023
@awocrf awocrf reopened this Nov 13, 2023
@deividAlfa
Copy link
Owner

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!

@awocrf
Copy link
Author

awocrf commented Nov 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants