Know how much to increase or decrease the amount of scale based on the gui element inside

Let’s say a main frame has a width of 200 and a height of 500, and a secondary frame is inside the main frame with a scale size of 0.1, 0.2. I want to decrease or increase the size of the secondary frame by an x amount from the main frame’s size.

The idea was to get the absolute size of the main frame and decrease that by an x amount, but this does not work as it only affects like a 1% percentage of the x amount.

Is there any reason you don’t change the scale size? Since you want to do percentage-based size changes it feels like changing the scale size would be the best way.

Which size are you talking about? And yes, all of the gui elements are using scale, so of course I will use scale to change the size.

I don’t really understand your main question to be honest, can you give me an example of what you want to achieve? I don’t understand why you’d want to change the size of something based off of something without having it pre-set (as in, why not just update the initial scale to work for all sizes you want?)

Example:

237, 305 -- The size of the secondary frame
67 -- this is the amount that I want to decrease the secondary frame

The 67 is the x value from 305-237 so the secondary frame would have the same size, which is 237, 237. The only thing that is left is to subtract the main frame, so it also affects every frame inside the main frame. Here is what it looks like if I only change the secondary frame:
Screenshot_2

Do you mean you want it to have an aspect ratio of 1:1? I don’t really understand what your size is in this case, since it is a 2D object and not 1D. I’m just trying to understand why you’d need to do this programatically?

UDim2 | Roblox Creator Documentation, which is the description of a UI’s size, allows to set the size to be a % of its parent

That’s because I have this method that allows to change the image:
Screenshot_3
And changing the image to circle must be the same size, as it looks weird when its not.

I’m assuming you have a few different frames. Color area, input area, preview area, basic area and Custom area.

If I understand things correctly you want to change the size of Color area (which includes the circle/square and the large bar on the side.) depending on the size of the square/circle? Do you also want to increase the size of the input area or do you intend on leaving a gap between them?

No, I repeat, I want to change the main frame’s size based on the x amount from the secondary frame.
From this:

To this:

Screenshot_2

Never mind, I figured it out; I just had to divide the x amount by the scale size of the secondary frame:

local mainSize = main.AbsoluteSize
local currentSize = guiElement.AbsoluteSize

local yMainSize = mainSize.Y
local yCurrentSize = currentSize.Y

local sizeDiff = ((yCurrentSize  / yMainSize) - minSize) / (yCurrentSize / yMainSize)
print(sizeDiff)

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