ForeverDev

LINE LIBRARY

Oct 23rd, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. local sqrt, deg, acos, pow, abs = math.sqrt, math.deg, math.acos, math.pow, math.abs
  2.  
  3. local distance = function(point1, point2)
  4.     return abs(sqrt(pow(point2.Y - point1.Y, 2) + pow(point2.X - point1.X, 2)))
  5. end
  6.  
  7. local angle = function(point1, point2)
  8.     return abs(deg(acos((point2.X - point1.X) / (distance(point1, point2)))))
  9. end
  10.  
  11. local newLine = function(x1, y1, x2, y2)
  12.     local point1, point2 = Vector2.new(x1, y1), Vector2.new(x2, y2)
  13.  
  14.     local line = Instance.new("TextLabel", script.Parent)
  15.     line.Text = ""
  16.     line.Size = UDim2.new(0, distance(point1, point2), 0, 1)
  17.     line.Position = UDim2.new(0, (point1 + (((point2 - point1).unit) * (distance(point1, point2) / 2))).X - line.Size.X.Offset/2, 0, point1.Y + ((point2.Y - point1.Y) / 2))
  18.     line.Rotation = angle(point1, point2)
  19.     line.BorderSizePixel = 0
  20.     line.BackgroundColor3 = Color3.new(1, 0, 0)
  21. end
Advertisement
Add Comment
Please, Sign In to add comment