Advertisement
szymski

Untitled

Aug 27th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. /*--------------------------------
  2.     Stencil functions
  3. ----------------------------------*/
  4.    
  5. function matcore.StencilStart()
  6.     render.ClearStencil()
  7.     render.SetStencilEnable( true )
  8.     render.SetStencilWriteMask( 1 )
  9.     render.SetStencilTestMask( 1 )
  10.     render.SetStencilFailOperation( STENCILOPERATION_KEEP )
  11.     render.SetStencilZFailOperation( STENCILOPERATION_KEEP )
  12.     render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
  13.     render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS )    
  14.     render.SetStencilReferenceValue( 1 )
  15.     render.SetColorModulation( 1, 1, 1 )
  16. end
  17.  
  18. function matcore.StencilStartC(m)
  19.     render.ClearStencil()
  20.     render.SetStencilEnable( true )
  21.     render.SetStencilWriteMask( m )
  22.     render.SetStencilTestMask( 1 )
  23.     render.SetStencilFailOperation( STENCILOPERATION_KEEP )
  24.     render.SetStencilZFailOperation( STENCILOPERATION_KEEP )
  25.     render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
  26.     render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS )    
  27.     render.SetStencilReferenceValue( 1 )
  28.     render.SetColorModulation( 1, 1, 1 )
  29. end
  30.  
  31. function matcore.StencilReplace(v)
  32.     render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
  33.     render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
  34.     render.SetStencilReferenceValue(v or 1)
  35. end
  36.  
  37. function matcore.StencilEnd()
  38.     render.SetStencilEnable( false )
  39. end
  40.  
  41. /*--------------------------------
  42.     Circles
  43. ----------------------------------*/
  44.  
  45. function matcore.DrawCircle(posx, posy, radius, color)
  46.     local poly = { }
  47.     local v = 40
  48.     for i = 0, v do
  49.         poly[i+1] = {x = math.sin(-math.rad(i/v*360)) * radius + posx, y = math.cos(-math.rad(i/v*360)) * radius + posy}
  50.     end
  51.     draw.NoTexture()
  52.     surface.SetDrawColor(color)
  53.     surface.DrawPoly(poly)
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement