Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _translate = love.graphics.translate
- _translateX, _translateY = {0}, {0}
- _pop = love.graphics.pop
- _origin = love.graphics.origin
- _scissor = love.graphics.setScissor
- function love.graphics.pop()
- table.remove(_translateX)
- table.remove(_translateY)
- _pop()
- end
- function love.graphics.translate(x, y)
- table.insert(_translateX, x)
- table.insert(_translateY, y)
- _translate(x, y)
- end
- function love.graphics.getTranslation()
- return love.graphics.getTranslationX(), love.graphics.getTranslationY()
- end
- function love.graphics.getTranslationX()
- local x = 0
- for i, v in ipairs(_translateX) do
- x = x + v
- end
- return x
- end
- function love.graphics.getTranslationY()
- local y = 0
- for i, v in ipairs(_translateY) do
- y = y + v
- end
- return y
- end
- function love.graphics.origin()
- _translateX = {0}
- _translateY = {0}
- _origin()
- end
- function love.graphics.setScissor(x, y, w, h)
- if x and type(x) == "number" then
- x = x + love.graphics.getTranslationX()
- end
- if y and type(y) == "number" then
- y = y + love.graphics.getTranslationY()
- end
- _scissor(x, y, w, h)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement