From d2f5bff92d94ce537b76e80482c62461b7a0d2ef Mon Sep 17 00:00:00 2001 From: howmanysmall Date: Mon, 29 Oct 2018 17:24:52 -0600 Subject: [PATCH] Possible Scale fix --- AsymmetricTransformation.lua | 45 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/AsymmetricTransformation.lua b/AsymmetricTransformation.lua index 348c7fd..d1c60cd 100644 --- a/AsymmetricTransformation.lua +++ b/AsymmetricTransformation.lua @@ -4,16 +4,22 @@ -- AsymmetricTransformation(GuiObject Button, UDim2 EndSize) -- @specs https://material.io/guidelines/motion/transforming-material.html# -local RunService = game:GetService("RunService") +local Workspace = game:GetService("Workspace") local ReplicatedStorage = game:GetService("ReplicatedStorage") +local RunService = game:GetService("RunService") local Resources = require(ReplicatedStorage:WaitForChild("Resources")) local Bezier = Resources:LoadLibrary("Bezier") local Standard = Bezier.new(0.4, 0.0, 0.2, 1) -local Heartbeat = RunService.Heartbeat +local CurrentCamera = Workspace.CurrentCamera +local RenderStepped = RunService.RenderStepped +local math_ceil = math.ceil local function AsymmetricTransformation(Button, EndSize) + Button.Size = UDim2_new(0, Button.AbsoluteSize.X, 0, Button.AbsoluteSize.Y) + EndSize = UDim2_new(0, EndSize.X.Scale * CurrentCamera.ViewportSize.X, 0, EndSize.Y.Scale * CurrentCamera.ViewportSize.Y) + local StartX = Button.Size.X local StartY = Button.Size.Y local EndX = EndSize.X @@ -41,18 +47,18 @@ local function AsymmetricTransformation(Button, EndSize) -- Expanding Clone:Destroy() local Duration = 0.375 - local HeightStart = Duration*0.1 - local WidthDuration = Duration*0.75 + local HeightStart = Duration / 10 + local WidthDuration = Duration * 0.75 - Connection = Heartbeat:Connect(function(Step) + Connection = RenderStepped:Connect(function(Step) ElapsedTime = ElapsedTime + Step if Duration > ElapsedTime then local XScale, XOffset, YScale, YOffset if WidthDuration > ElapsedTime then local WidthAlpha = Standard(ElapsedTime, 0, 1, WidthDuration) - XScale = XStartScale + WidthAlpha*XScaleChange - XOffset = StartX.Offset + WidthAlpha*XOffsetChange + XScale = XStartScale + WidthAlpha * XScaleChange + XOffset = StartX.Offset + WidthAlpha * XOffsetChange else XScale = Button.Size.X.Scale XOffset = Button.Size.X.Offset @@ -60,14 +66,14 @@ local function AsymmetricTransformation(Button, EndSize) if ElapsedTime > HeightStart then local HeightAlpha = Standard(ElapsedTime - HeightStart, 0, 1, Duration) - YScale = YStartScale + HeightAlpha*YScaleChange - YOffset = YStartOffset + HeightAlpha*YOffsetChange + YScale = YStartScale + HeightAlpha * YScaleChange + YOffset = YStartOffset + HeightAlpha * YOffsetChange else YScale = YStartScale YOffset = YStartOffset end - Button.Size = UDim2.new(math.ceil(XScale), math.ceil(XOffset), math.ceil(YScale), math.ceil(YOffset)) + Button.Size = UDim2.new(math_ceil(XScale), math_ceil(XOffset), math_ceil(YScale), math_ceil(YOffset)) else Connection:Disconnect() Button.Size = EndSize @@ -77,18 +83,18 @@ local function AsymmetricTransformation(Button, EndSize) -- Shrinking Clone:Destroy() local Duration = 0.225 - local WidthStart = Duration*0.15 - local HeightDuration = Duration*0.95 + local WidthStart = Duration * 0.15 + local HeightDuration = Duration * 0.95 - Connection = Heartbeat:Connect(function(Step) + Connection = RenderStepped:Connect(function(Step) ElapsedTime = ElapsedTime + Step if Duration > ElapsedTime then local XScale, XOffset, YScale, YOffset if HeightDuration > ElapsedTime then local HeightAlpha = Standard(ElapsedTime, 0, 1, HeightDuration) - YScale = YStartScale + HeightAlpha*YScaleChange - YOffset = YStartOffset + HeightAlpha*YOffsetChange + YScale = YStartScale + HeightAlpha * YScaleChange + YOffset = YStartOffset + HeightAlpha * YOffsetChange else YScale = Button.Size.Y.Scale YOffset = Button.Size.Y.Offset @@ -96,20 +102,17 @@ local function AsymmetricTransformation(Button, EndSize) if ElapsedTime > WidthStart then local WidthAlpha = Standard(ElapsedTime - WidthStart, 0, 1, Duration) - XScale = XStartScale + WidthAlpha*XScaleChange - XOffset = XStartOffset + WidthAlpha*XOffsetChange + XScale = XStartScale + WidthAlpha * XScaleChange + XOffset = XStartOffset + WidthAlpha * XOffsetChange else XScale = XStartScale XOffset = XStartOffset end - Button.Size = UDim2.new(math.ceil(XScale), math.ceil(XOffset), math.ceil(YScale), math.ceil(YOffset)) + Button.Size = UDim2.new(math_ceil(XScale), math_ceil(XOffset), math_ceil(YScale), math_ceil(YOffset)) else Connection:Disconnect() Button.Size = EndSize - --[[if EndSize == UDim2.new() then - Button.Visible = false - end]] end end) end