I’m not trying to find the aspect ratio. (It can be found using X/Y). I’m trying to use the aspect ratio to find the Y value. The only inputs I have are the X Value and Aspect Ratio.
function GetAspectRatioValues(X, OriginalSize)
local Val = X / OriginalSize
return Val * OriginalSize
end
This worked fine for a while. But then I started adding the ability to resize the UI. And it all messed up. If this is confusing as questions and I will give you the info you need.
Is originalSize a vector2 value?
Either way it’s still just dividing then multiplying, unless you meant the second line of the function to have a different variable, like originalSizeY for example
If you’re making a function that returns the aspect ratio of a certain 2d rectangle given a Vector2 value, then the function would look like:
function GetAspectRatio(Size)
return Size.X / Size.Y -- assuming x is the major axis
end
To get a size that fits an aspect ratio given an aspect ratio and a scalar X, you would use a function like this:
function GetAspectSize(XScale, AspectRatio)
return Vector2.new(X, X / AspectRatio); --returns the x and y sizes respectively, fitting the aspect ratio
end