Recent

Author Topic: Rounding radius  (Read 601 times)

hedgehog

  • Jr. Member
  • **
  • Posts: 75
Rounding radius
« on: August 29, 2025, 04:53:42 pm »
I think something is wrong here.
I am drawing two rectangles with rounded corners.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
  2. begin
  3.   Bitmap.FillRoundRect(50,50,150,150, 16, 16, VGABlue);
  4.   Bitmap.FillRoundRectAntialias(200,50,300,150, 16, 16, VGAGreen);
  5. end;
  6.  

The one in green (antialiasing is used) is drawn correctly.
The one in blue (without antialiasing) has a very small corner radius.

(Lazarus 4, Win10-64, BGRABitmap 11.6.6 from Github)

circular

  • Hero Member
  • *****
  • Posts: 4450
    • Personal webpage
Re: Rounding radius
« Reply #1 on: November 03, 2025, 10:30:16 am »
Hi hedgehog,

I understand the confusion.

The FillRoundRect function uses integer coordinates. In order to have enough precision on the rounded corners, the parameter is the diameter (DX,DY) instead of the radius (RX,RY).

To get the same result, you need to supply DX=32 to have the same rounded corners as with RX=16.

Regards
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018