Advertisement
CapsAdmin

Untitled

Feb 20th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1.  
  2. local white = surface.GetTextureID("vgui/white")
  3.  
  4. function surface.DrawLineEx(x1,y1, x2,y2, w, skip_tex)
  5.     w = w or 1
  6.     if not skip_tex then surface.SetTexture(white) end
  7.    
  8.     local dx,dy = x1-x2, y1-y2
  9.     local ang = math.atan2(dx, dy)
  10.     local dst = math.sqrt((dx * dx) + (dy * dy))
  11.    
  12.     x1 = x1 - dx * 0.5
  13.     y1 = y1 - dy * 0.5
  14.    
  15.     surface.DrawTexturedRectRotated(x1, y1, w, dst, math.deg(ang))
  16. end
  17.  
  18. function surface.DrawCircleEx(x, y, rad, color, res, ...)
  19.     res = res or 16
  20.        
  21.     surface.SetDrawColor(color)
  22.    
  23.     local spacing = (res/rad) - 0.1
  24.    
  25.     for i = 0, res do      
  26.         local i1 = ((i+0) / res) * math.pi * 2
  27.         local i2 = ((i+1 + spacing) / res) * math.pi * 2
  28.        
  29.         surface.DrawLineEx(
  30.             x + math.sin(i1) * rad,
  31.             y + math.cos(i1) * rad,
  32.            
  33.             x + math.sin(i2) * rad,
  34.             y + math.cos(i2) * rad,
  35.             ...
  36.         )
  37.     end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement