Advertisement
HugoBDesigner

Untitled

Jun 7th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. _translate = love.graphics.translate
  2. _translateX, _translateY = {0}, {0}
  3. _pop = love.graphics.pop
  4. _origin = love.graphics.origin
  5. _scissor = love.graphics.setScissor
  6.  
  7. function love.graphics.pop()
  8.     table.remove(_translateX)
  9.     table.remove(_translateY)
  10.     _pop()
  11. end
  12.  
  13. function love.graphics.translate(x, y)
  14.     table.insert(_translateX, x)
  15.     table.insert(_translateY, y)
  16.     _translate(x, y)
  17. end
  18.  
  19. function love.graphics.getTranslation()
  20.     return love.graphics.getTranslationX(), love.graphics.getTranslationY()
  21. end
  22.  
  23. function love.graphics.getTranslationX()
  24.     local x = 0
  25.     for i, v in ipairs(_translateX) do
  26.         x = x + v
  27.     end
  28.     return x
  29. end
  30.  
  31. function love.graphics.getTranslationY()
  32.     local y = 0
  33.     for i, v in ipairs(_translateY) do
  34.         y = y + v
  35.     end
  36.     return y
  37. end
  38.  
  39. function love.graphics.origin()
  40.     _translateX = {0}
  41.     _translateY = {0}
  42.     _origin()
  43. end
  44.  
  45. function love.graphics.setScissor(x, y, w, h)
  46.     if x and type(x) == "number" then
  47.         x = x + love.graphics.getTranslationX()
  48.     end
  49.     if y and type(y) == "number" then
  50.         y = y + love.graphics.getTranslationY()
  51.     end
  52.     _scissor(x, y, w, h)
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement