AdobeXD / xd-to-flutter-plugin

Generate assets from XD for use in an existing Flutter project
BSD 2-Clause "Simplified" License
952 stars 97 forks source link

Ovals drawing improperly #98

Open gskinner opened 3 years ago

gskinner commented 3 years ago

Bug Description

Ovals translated into Containers are drawing incorrectly (see image below). This is due to a recent change in Flutter where elliptical corners are now drawn differently.

We previously set oval corner x & y radii to 9999.0, to ensure corners would draw to the full extent in both dimensions, even when the shape scales. Now though, it appears to calculate the ratio of the two dimensions and then multiply the shorter dimension by that ratio to calculate the longer dimension.

Ex. a 50 x 100 Container, with radius x=50, y=50, would result in a circular corner of radius 25 (the maximum radius along the shortest side 25 times the ratio 50 / 50 = 1.0). With radius x=50, y=75, the corner would be drawn with an x radius of 25 (half the width), and a y radius of 37.5 (75/50 * 25). Formerly it would have been drawn with a y radius of 100, since 75 is greater than the max radius of 100/2=50.

image Flutter on top, XD on bottom.

We can partially work around this by maintaining the ratio, but it will break if the oval is scaled non-uniformly.