Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Quality = 2
- --Points are based on offset, do not account for scale!
- local function DrawTriangle(Parent,Point1,Point2,Point3)
- local X1,Y1 = Point1.X.Offset,Point1.Y.Offset
- local X2,Y2 = Point2.X.Offset,Point2.Y.Offset
- local X3,Y3 = Point3.X.Offset,Point3.Y.Offset
- local function Lerp(S,E,A)
- return S + (E-S)*A
- end
- local function GetLeftAndRightPointsOnY(PosY)
- local ReturnPoint1,ReturnPoint2
- local function SetPoint(UDim1,UDim2)
- if not ReturnPoint1 then
- ReturnPoint1 = {UDim1,UDim2}
- elseif not ReturnPoint2 then
- ReturnPoint2 = {UDim1,UDim2}
- end
- end
- if (Y1 < PosY and Y2 >= PosY) or (Y2 < PosY and Y1 >= PosY) then
- SetPoint(Point1,Point2)
- end
- if (Y3 < PosY and Y2 >= PosY) or (Y2 < PosY and Y3 >= PosY) then
- SetPoint(Point2,Point3)
- end
- if (Y1 < PosY and Y3 >= PosY) or (Y3 < PosY and Y1 >= PosY) then
- SetPoint(Point1,Point3)
- end
- return ReturnPoint1,ReturnPoint2
- end
- local function GetLeftAndRightPointsOnX(PosX)
- local ReturnPoint1,ReturnPoint2
- local function SetPoint(UDim1,UDim2)
- if not ReturnPoint1 then
- ReturnPoint1 = {UDim1,UDim2}
- elseif not ReturnPoint2 then
- ReturnPoint2 = {UDim1,UDim2}
- end
- end
- if (X1 < PosX and X2 >= PosX) or (X2 < PosX and X1 >= PosX) then
- SetPoint(Point1,Point2)
- end
- if (X3 < PosX and X2 >= PosX) or (X2 < PosX and X3 >= PosX) then
- SetPoint(Point2,Point3)
- end
- if (X1 < PosX and X3 >= PosX) or (X3 < PosX and X1 >= PosX) then
- SetPoint(Point1,Point3)
- end
- return ReturnPoint1,ReturnPoint2
- end
- local function DrawLineOnY(PosY)
- local Pos1T,Pos2T = GetLeftAndRightPointsOnY(PosY)
- if Pos1T and Pos2T then
- local function GetRatio(Point1Y,Point2Y)
- local Point2Y,PosY = Point2Y - Point1Y,PosY - Point1Y
- return PosY/Point2Y
- end
- local R1,R2 = GetRatio(Pos1T[1].Y.Offset,Pos1T[2].Y.Offset),GetRatio(Pos2T[1].Y.Offset,Pos2T[2].Y.Offset)
- local LerpedPos1,LerpedPos2 = UDim2.new(0,Lerp(Pos1T[1].X.Offset,Pos1T[2].X.Offset,R1),0,PosY),UDim2.new(0,Lerp(Pos2T[1].X.Offset,Pos2T[2].X.Offset,R2),0,PosY)
- if LerpedPos1.X.Offset > LerpedPos2.X.Offset then
- local TempPos = LerpedPos2
- LerpedPos2,LerpedPos1 = LerpedPos1,TempPos
- end
- local Length = LerpedPos2.X.Offset - LerpedPos1.X.Offset
- if Length > 0 then
- local Frame = Instance.new("Frame")
- Frame.Position = LerpedPos1
- Frame.Size = UDim2.new(0,Length,0,Quality)
- Frame.BorderSizePixel = 0
- Frame.Parent = Parent
- end
- end
- end
- local function DrawLineOnX(PosX)
- local Pos1T,Pos2T = GetLeftAndRightPointsOnX(PosX)
- if Pos1T and Pos2T then
- local function GetRatio(Point1X,Point2X)
- local Point2X,PosX = Point2X - Point1X,PosX - Point1X
- return PosX/Point2X
- end
- local R1,R2 = GetRatio(Pos1T[1].X.Offset,Pos1T[2].X.Offset),GetRatio(Pos2T[1].X.Offset,Pos2T[2].X.Offset)
- local LerpedPos1,LerpedPos2 = UDim2.new(0,PosX,0,Lerp(Pos1T[1].Y.Offset,Pos1T[2].Y.Offset,R1)),UDim2.new(0,PosX,0,Lerp(Pos2T[1].Y.Offset,Pos2T[2].Y.Offset,R2))
- if LerpedPos1.Y.Offset > LerpedPos2.Y.Offset then
- local TempPos = LerpedPos2
- LerpedPos2,LerpedPos1 = LerpedPos1,TempPos
- end
- local Length = LerpedPos2.Y.Offset - LerpedPos1.Y.Offset
- if Length > 0 then
- local Frame = Instance.new("Frame")
- Frame.Position = LerpedPos1
- Frame.Size = UDim2.new(0,Quality,0,Length)
- Frame.BorderSizePixel = 0
- Frame.Parent = Parent
- end
- end
- end
- local MinX = math.min(Point1.X.Offset,Point2.X.Offset,Point3.X.Offset)
- local MaxX = math.max(Point1.X.Offset,Point2.X.Offset,Point3.X.Offset)
- local MinY = math.min(Point1.Y.Offset,Point2.Y.Offset,Point3.Y.Offset)
- local MaxY = math.max(Point1.Y.Offset,Point2.Y.Offset,Point3.Y.Offset)
- if (MaxY - MinY) < (MaxX - MinX) then
- for Add = 1, (MaxY - MinY)/Quality do
- DrawLineOnY(MinY + (Quality*Add))
- end
- else
- for Add = 1, (MaxX - MinX)/Quality do
- DrawLineOnX(MinX + (Quality*Add))
- end
- end
- end
- local Point1 = UDim2.new(0,220,0,20)
- local Point2 = UDim2.new(0,25,0,100)
- local Point3 = UDim2.new(0,170,0,260)
- local Point4 = UDim2.new(0,300,0,500)
- local Point5 = UDim2.new(0,500,0,500)
- local Point6 = UDim2.new(0,500,0,300)
- game.StarterGui.ScreenGui.Container:ClearAllChildren()
- DrawTriangle(game.StarterGui.ScreenGui.Container,Point1,Point2,Point3)
- DrawTriangle(game.StarterGui.ScreenGui.Container,Point4,Point5,Point6)
Advertisement
Add Comment
Please, Sign In to add comment