Yall all had an issue scaling UISrokes right?
Well for that i made a simple formula that will let you scale them properly
I were in need of scalable Border/UIStroke/RichText and i decided to mess around with formulas and somehow managed to find a working method.
If you want short simple answer here is the formula:
local size = 50
local ViewPort = workspace.CurrentCamera.ViewportSize
math.min(ViewPort.X,ViewPort.Y)/ViewPort.Y *size
How does it work?
It works similar to UIAspectRatioConstraint
If X
is bigger than Y
then we round it to Y
and devide by Y
and multiply by size
I haven’t found any tutorial like mine with this answer; It were either some meh UI bloatware frameworks or such plus they all were doing this simple thing WRONG.
Funny how i figured out answer randomly
UPDATE:
Hower i just made another formula (with ChatGPT’s help this time) that works similarly and fully replicates UIAspectRatioConstraint
IF YOUR UISTROKE DOESNT USE UIAspectRatioConstraint
THEN USE PREVIOUS FORMULA!
--Tips:
--1920/1080 = 1.7777777777777777 Ratio
--Ratio*Y = X
--X/Ratio = Y
local size = 50
local ViewPort = workspace.CurrentCamera.ViewportSize
local Ratio = Vector2.new(1080, 1080) -- `UIAspectRatioConstraint`'s Ratio would be 1
local Scaled = ((ViewPort.X/ViewPort.Y>Ratio.X/Ratio.Y and ViewPort.Y/Ratio.Y) or ViewPort.X / Ratio.X) *size