Actually, completely scratch what I just sent. It is a poorly optimized method.
I have devised a better strategy, doesn’t need you to clone anything:
function Canvas:DrawDistortedImageRect(PointA: Vector2, PointB: Vector2, PointC: Vector2, PointD: Vector2, RectOffset, RectSize, ImageData: {}, Brightness: number?)
Canvas:DrawDistortedImageRectXY(
PointA.X, PointA.Y, PointB.X, PointB.Y, PointC.X, PointC.Y, PointD.X, PointD.Y,
RectOffset, RectSize,
ImageData, Brightness
)
end
function Canvas:DrawDistortedImageRectXY(X1, Y1, X2, Y2, X3, Y3, X4, Y4, RectOffset, RectSize, ImageData: {}, Brightness: number?)
local U1, V1 = RectOffset.X / ImageData.Width, RectOffset.Y / ImageData.Height
local U2, V2 = (RectOffset.X + RectSize.X) / ImageData.Width, RectOffset.Y / ImageData.Height
local U3, V3 = (RectOffset.X + RectSize.X) / ImageData.Width, (RectOffset.Y + RectSize.Y) / ImageData.Height
local U4, V4 = RectOffset.X / ImageData.Width, (RectOffset.Y + RectSize.Y) / ImageData.Height
Canvas:DrawTexturedTriangleXY(
X1, Y1, X2, Y2, X3, Y3,
U1, V1, U2, V2, U3, V3,
ImageData, Brightness
)
Canvas:DrawTexturedTriangleXY(
X1, Y1, X4, Y4, X3, Y3,
U1, V1, U4, V4, U3, V3,
ImageData, Brightness
)
end
local x, y, width, height = 0,0, 320, 320
local currentsize = Vector2.new(.1, .1)
while true do
local dt = RunService.Heartbeat:Wait()
local PointA = Vector2.new(x, y) -- Top-left
local PointB = Vector2.new(x + width, y) -- Top-right
local PointC = Vector2.new(x + width, y + height) -- Bottom-right
local PointD = Vector2.new(x, y + height) -- Bottom-left
Canvas:DrawDistortedImageRect(PointA, PointB, PointC, PointD, Vector2.new(), currentsize, ImageData)
currentsize = currentsize:Lerp(Vector2.new(ImageData.Width, ImageData.Height), .1)
end