Scaling Rect for all screen sizes with script

Hello fellow programmers! Today I’m asking how to scale properly a Rect based on Screen size as I’m getting weird artifacts with a Rect in a smaller screen size and with that Rect fixed for smaller screen sizes, I’m getting a weird artifact for bigger sizes.

Fix for smaller sizes:
image

Fix for smaller sizes on bigger screen:
image

And the same thing viceversa, so that’s why I’m wondering what’s the formula to scale a Rect based on the absolute size of screen.

1 Like

Tried with this formula but didn’t work

local ViewportRatio = self.OriginalViewportSize / Value
local RatioedRect = Rect.new(
    self.OriginalRectSize.Min * ViewportRatio,
    self.OriginalRectSize.Max * ViewportRatio
)

self.Instance.SliceCenter = RatioedRect

I would recommend using this

I don’t want to constraint the size, I want the slicecenter to be re-caculated based on the screen size or image absolute size

1 Like

Bumping this topic as still haven’t found a formula