Calculate UICorner's so they are the same roundness with different sizes

I’m trying to make it so some of my UI has the same roundness on the corners. I’m using Scale on the UI and the UICorner’s, One UI is wider and taller than the other.

(just need an explanation or an example thanks)

just use offset, far easier and more reliable with uicorner

1 Like

It doesn’t stay the same roundness though across different devices.

using offset will make sure it’s always the same amount of pixels

So you need to calculate the scale of UICorner which should be the same size as UICorner of another frame

UICorner calculates offset from scale using this formula:

math.min(SizeX, SizeY) * Scale

So we can use this equation to get the scale of UICorner which keeps the same size as UICorner of another frame

math.min(NewSizeX, NewSizeY) * NewScale = math.min(SizeX, SizeY) * Scale

We can divide both sides of the equation by

math.min(NewSizeX, NewSizeY)

And now we have this new equation

math.min(NewSizeX, NewSizeY) / math.min(NewSizeX, NewSizeY) * NewScale = math.min(SizeX, SizeY) / math.min(NewSizeX, NewSizeY) * Scale

Now since anything divided by itself is 1, this formula can be simplified to 1

math.min(NewSizeX, NewSizeY) / math.min(NewSizeX, NewSizeY) -- will always be equal to 1

So we can simplify the equation to this

1 * NewScale = math.min(SizeX, SizeY) / math.min(NewSizeX, NewSizeY) * Scale

And since anything multiplied by 1 is itself this equation becomes

NewScale = math.min(SizeX, SizeY) / math.min(NewSizeX, NewSizeY) * Scale

Now you can calculate the new scale of UICorner which makes it have the same size as another frame’s UICorner using that formula

btw you need to get the SizeX, SizeY, NewSizeX and NewSizeY variables from the frames’s AbsoluteSize property

2 Likes

Thanks! so much easier than having to manually try to match the round on them.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.