# Bug with drawing round rectangles

**URL:** <https://forum.xojo.com/t/bug-with-drawing-round-rectangles/77572>\
**Category:** Bugs and Feature Requests\
**Created:** [October 9, 2023, 2:59am UTC](https://forum.xojo.com/t/bug-with-drawing-round-rectangles/77572 "2023-10-09T02:59:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Balestrieri](https://forum.xojo.com/user_avatar/forum.xojo.com/john_balestrieri/32/9956_2.png) [@John\_Balestrieri](https://forum.xojo.com/u/John_Balestrieri)\
**Post date:** [October 9, 2023, 2:59am UTC](https://forum.xojo.com/t/bug-with-drawing-round-rectangles/77572/1 "2023-10-09T02:59:48Z")

</div>

I filed a bug tonight:

[https://tracker.xojo.com/xojoinc/xojo/-/issues/74347](https://tracker.xojo.com/xojoinc/xojo/-/issues/74347)

where Graphics.FillRoundRectangle and Graphics.DrawRoundRectangle produce different results on desktop (macOS) and iOS:

```auto
Dim r As Double = 50 - .000001 // BYO epsilon to prevent crash in iOS (until 2023 R3)
g.FillRoundRectangle(100,100,200,100,r,r)

```

Desktop (macOS):  
 ![Screenshot 2023-10-08 at 10.41.28 PM](https://forum.xojo.com/uploads/default/original/2X/6/6d20e66661ebdd6be302dd28300e906a90c77d5e.png)

Mobile:  
 ![Screenshot 2023-10-08 at 10.41.33 PM](https://forum.xojo.com/uploads/default/original/2X/9/9a6d3fd33e8aebe9d3b23fb2c1508d8f011f41e6.png)

I’m not posting this to get people to sign on—I’m sure it will be fixed. But my question is, it looks like the desktop (macOS) version is wrong. Given that the desktop implementation has been around **a lot** longer than the iOS version, I’m curious how people feel about how this gets fixed—which version is the “correct” one? And if you have an opinion, please leave a comment on the feedback! 🙂

I’m in favor (and hope XOJO is too) of fixing the desktop version, even if it means breaking people’s code. The desktop version is clearly wrong, constructing a radius based on half the height and width values.

Documentation:

> _x_ and _y_ are the coordinates of the top-left corner. _width_ and _height_ specify the size of the round rectangle. _arcWidth_ and _arcHeight_control the shape of the corners in the horizontal and vertical axes, respectively. They are the distance (in points) from the corner at which the arc begins. Setting them to zero results in a rectangle with sharp corners.
> 
> This example (in the [Paint] event of a [DesktopCanvas] draws a rounded rectangle with a red fill and 30 pixel rounded corners.

```auto
g.DrawingColor = &cff0000
g.FillRoundRectangle(10, 10, 100, 60, 30, 30)

```

Let’s run this and measure the radii. I’m using an internal picture so I don’t have to worry about points ≠ pixels:

```auto
Dim p As Picture = New Picture(200,200)
p.Graphics.DrawingColor = &cff0000
p.Graphics.FillRoundRectangle(10, 10, 100, 60, 30, 30)

Dim c As New Clipboard
c.Picture = p

```

Paste the output into PhotoShop and we see that the example code actually draws 15 px x 15 px corners instead of 30px x 30px:

 ![image](https://forum.xojo.com/uploads/default/original/2X/a/a1a4c7a6bd15a8436667bbd7df33a89d2ae37ec8.png)

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [October 9, 2023, 3:57am UTC](https://forum.xojo.com/t/bug-with-drawing-round-rectangles/77572/2 "2023-10-09T03:57:57Z")

</div>

While it may not be consistent between iOS and macOS, the behavior is consistent for the target types (or, I guess I should say, Mobile is different from everything else).

macOS/Windows/Linux/Web have a common result, while iOS/Android have a common result. I think this is more of a time-induced inconsistency. It behaves the same way it always has for the older targets, but the naming and documentation have made that inconsistent with expectations and the newer platforms implemented it differently, possibly because of this ambiguity.

Considering that the impact of making this change everywhere else would be significantly greater than the impact of changing it for Mobile targets, I’d prefer any change happen to the Mobile targets rather than **all** of the other targets, and the API naming be corrected everywhere for the function parameters (which shouldn’t break much anywhere, if at all).

It is worth noting that another inconsistency exists between Graphics and WebGraphics where the Draw/FillRoundRectangle methods need only one radius parameter while everywhere else it’s two.

---

<div class="post-metadata">

**Author:** ![Greg\_O](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o/32/22785_2.png) [@Greg\_O](https://forum.xojo.com/u/Greg_O)\
**Post date:** [October 9, 2023, 9:48am UTC](https://forum.xojo.com/t/bug-with-drawing-round-rectangles/77572/3 "2023-10-09T09:48:22Z")

</div>

> [@Anthony\_G\_Cyphers](#):
>
> It is worth noting that another inconsistency exists between Graphics and WebGraphics where the Draw/FillRoundRectangle methods need only one radius parameter while everywhere else it’s two.

IIRC, that’s because the underlying API only has one. Honestly I’m surprised that there’s two on iOS though. I don’t think there’s two radii there either.
