Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Quality = 1
- local function DrawTriangle(Parent,Points)
- local function GetLinesFromPosY(PosY)
- local function GetPoint(Num)
- if Num > #Points then
- return Points[1]
- end
- return Points[Num]
- end
- local Lines = {}
- for i = 1, #Points do
- local Point1,Point2 = GetPoint(i),GetPoint(i+1)
- if (Point1.Y.Offset < PosY and Point2.Y.Offset >= PosY) then
- table.insert(Lines,{Point1,Point2})
- elseif (Point2.Y.Offset < PosY and Point1.Y.Offset >= PosY) then
- table.insert(Lines,{Point2,Point1})
- end
- end
- return Lines
- end
- local function Lerp(S,E,A)
- return S + (E-S)*A
- end
- local function DrawLine(PosY)
- local Lines = GetLinesFromPosY(PosY)
- local LinePoses = {}
- for _,Data in pairs(Lines) do
- local Pos1,Pos2 = Data[1],Data[2]
- local function GetRatio(Point1Y,Point2Y)
- local Point2Y,PosY = Point2Y - Point1Y,PosY - Point1Y
- return PosY/Point2Y
- end
- local Ratio = GetRatio(Pos1.Y.Offset,Pos2.Y.Offset)
- local LerpedPos = UDim2.new(0,Lerp(Pos1.X.Offset,Pos2.X.Offset,Ratio),0,PosY)
- table.insert(LinePoses,LerpedPos)
- end
- table.sort(LinePoses,function(Pos1,Pos2) return Pos1.X.Offset < Pos2.X.Offset end)
- for i = 1, #LinePoses/2 do
- i = i*2
- local Pos1,Pos2 = LinePoses[i-1],LinePoses[i]
- local Length = Pos2.X.Offset - Pos1.X.Offset
- if Length > 0 then
- local Frame = Instance.new("Frame")
- Frame.Position = Pos1
- Frame.Size = UDim2.new(0,Length,0,Quality)
- Frame.BorderSizePixel = 0
- Frame.Parent = Parent
- end
- end
- end
- local MinY,MaxY = math.huge,0
- for _,Point in pairs(Points) do
- if Point.Y.Offset < MinY then
- MinY = Point.Y.Offset
- end
- if Point.Y.Offset > MaxY then
- MaxY = Point.Y.Offset
- end
- end
- for Add = 1, (MaxY - MinY)/Quality do
- DrawLine(MinY + (Quality*Add))
- end
- end
- local Point3 = UDim2.new(0,220,0,20)
- local Point1 = UDim2.new(0,25,0,100)
- local Point2 = UDim2.new(0,130,0,130)
- local Point4 = UDim2.new(0,200,0,260)
- local Point5 = UDim2.new(0,180,0,110)
- local Point6 = UDim2.new(0,130,0,220)
- local Point7 = UDim2.new(0,80,0,70)
- local Point8 = UDim2.new(0,90,0,160)
- game.StarterGui.ScreenGui.Container:ClearAllChildren()
- DrawTriangle(game.StarterGui.ScreenGui.Container,{Point1,Point2,Point3,Point4,Point5,Point6,Point7,Point8})
Advertisement
Add Comment
Please, Sign In to add comment