So that we can multiply UDim2s and not have to disassemble and reassemble them whenever we need to multiply them.
Also this:
local xScale, xOffset, yScale, yOffset = udim2:components()
No support.
If you actually try to define a reasonable * or / operator for UDim2s you’ll find that there isn’t really one that makes sense. Any one that’s added will only work for about 50% of cases, leaving the other 50% still needing the old solution, and fragmenting codebases between the two methods.
Stravant, how about an operation like this:
local a = UDim2.new(.5,100,.5,100) -- the UDim2 to be modified
local b = UDim2.new (1,2,1,2) -- the factor by which to modify the UDim2
print(a*b) -- UDim2.new(.5,200,.5,200)
print(a/b) -- UDim2.new(.5,50,.5,50)
so basically,
UDim2.new(a,b,c,d) * UDim2.new(e,f,g,h) = UDim2.new(ae,bf,cg,dh)
UDim2.new(a,b,c,d) / UDim2.new(e,f,g,h) = UDim2.new(a/e,b/f,c/g,d/h)
with the appropriate errors thrown for division by zero
It fits structurally with the existing property for UDim2 addition, and it would do what Ethan is asking for (I think).
[quote] No support.
If you actually try to define a reasonable * or / operator for UDim2s you’ll find that there isn’t really one that makes sense. Any one that’s added will only work for about 50% of cases, leaving the other 50% still needing the old solution, and fragmenting codebases between the two methods. [/quote]
What are those 50% of cases? The only legitimate use I see for this is interpolation, which would work fine.
Any other case than interpolation
Interpolation is really the only thing that the method would work for. I would support directly adding a way to interpolate them if you really want to roll your own animations with it:
UDim2:lerp(UDim2 other, float f)
Why add a multiply that’s just a clunky excuse for an interpolate function in disguise instead of adding the interpolate function that you actually wanted in the first place?
[quote] Any other case than interpolation
Interpolation is really the only thing that the method would work for. I would support directly adding a way to interpolate them if you really want to roll your own animations with it:
UDim2:lerp(UDim2 other, float f)
Why add a multiply that’s just a clunky excuse for an interpolate function in disguise instead of adding the interpolate function that you actually wanted in the first place? [/quote]
All userdata (CFrames, Vector2s, etc) needs a :lerp() function
Edit: By that, I mean something built into RBX.Lua, not a module.
[quote] No support.
If you actually try to define a reasonable * or / operator for UDim2s you’ll find that there isn’t really one that makes sense. Any one that’s added will only work for about 50% of cases, leaving the other 50% still needing the old solution, and fragmenting codebases between the two methods. [/quote]
[tt]UDim2 * number[/tt] I can understand. I don’t see the problem with [tt]UDim2 * UDim2[/tt], though. No one said both had to be defined.