Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. local tan = math.tan
  2. function draw.Parallelogram(x,y,w,h,angle,rot)
  3. -- sin Y
  4. -- cos X
  5. local length = 1/(tan(math.rad(angle))/h)
  6. local dots = {
  7. { x = (x+length) , y = y}, -- A
  8. { x = (x+length+w), y = y}, -- B
  9. { x = (x+w), y = (y + h)}, -- C
  10. { x = x, y = (y+h)} -- D
  11. }
  12.  
  13. if rot != nil then
  14. local rotate_rad = math.rad(rot)
  15. local sine = math.sin(rotate_rad)
  16. local cosine = math.cos(rotate_rad)
  17.  
  18. for k,v in pairs(dots) do -- apply rotation
  19. local stored = { x = v.x - x - w/2, y = v.y - y - h/2} -- centre?
  20. v.x = stored.x * cosine - stored.y * sine + x + w/2
  21. v.y = stored.y * cosine + stored.x * sine + y + h/2
  22. end
  23.  
  24. surface.DrawPoly( dots )
  25. return
  26. end
  27.  
  28. surface.DrawPoly( dots )
  29. end
  30.  
  31. hook.Add( "HUDPaint", "PolygonTest", function()
  32. draw.NoTexture()
  33. --////////DRAW HOLDER/////
  34. surface.SetDrawColor( 0, 0, 0, 255 )
  35. draw.Parallelogram( 250, 250, 200, 15, 45 )
  36. surface.SetDrawColor( 255, 0, 0, 255 )
  37. --///// END DRAW HOLDER////////
  38.  
  39. --/// DRAW HBAR ////
  40. local BarQuantity = LocalPlayer():GetMaxHealth()/100
  41. local bars = math.ceil(LocalPlayer():Health()/BarQuantity)
  42. for I = 1,bars do
  43. draw.Parallelogram( 250 + 2*I, 250, 2, 15, 45 ) -- 400 ( len
  44. end
  45. --// END DRAWHBAR //
  46.  
  47. --// DRAW HOLDER ( ABAR) //
  48. surface.SetDrawColor( 0, 0, 0, 255 )
  49. draw.Parallelogram( 235, 265, 200, 15, 45 )
  50. surface.SetDrawColor( 0, 0, 255, 255 )
  51. --// END DRAW HOLDER //
  52.  
  53. -- // DRAW ABAR
  54. for I = 1,math.ceil(LocalPlayer():Armor()) do
  55. draw.Parallelogram( 235 + 2*I, 265, 2, 15, 45 )
  56. end
  57. --// END DRAW ABAR
  58.  
  59. surface.SetDrawColor( 0, 255, 0, 255 ) -- avatar
  60. draw.Parallelogram( 206, 225, 50, 50, 90, 45) -- avatar
  61.  
  62. surface.SetDrawColor( 0, 0, 0, 255 )
  63. draw.Parallelogram( 250, 235, 200, 15, -45 )
  64.  
  65. draw.Parallelogram( 250, 220, 200, 15, -45 )
  66. end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement