Skip to content

Instantly share code, notes, and snippets.

@ElementW
Last active September 14, 2017 13:18
Show Gist options
  • Save ElementW/3702119021e6d4abdf27f04a0a4c09b3 to your computer and use it in GitHub Desktop.
Save ElementW/3702119021e6d4abdf27f04a0a4c09b3 to your computer and use it in GitHub Desktop.
LÖVE transform stack test
local t = 0
function love.update(dt)
t = t + dt
end
function love.draw()
local w, h = love.graphics.getWidth(), love.graphics.getHeight()
love.graphics.clear(0, 0, 0)
love.graphics.translate(w/2, h/2)
love.graphics.push()
love.graphics.scale(.7 + math.sin(t)*.2, .7 + math.cos(t)*.2)
love.graphics.push()
love.graphics.rotate(math.sin(t)*.5)
love.graphics.push()
love.graphics.scale(.5, .5)
love.graphics.shear(math.sin(-t), 0)
love.graphics.push()
love.graphics.scale(.5, .5)
love.graphics.shear(0, math.cos(t*3))
love.graphics.setColor(0, 255, 127, 255)
love.graphics.rectangle('fill', -w/4, -h/4, w/2, h/2)
love.graphics.pop()
love.graphics.setColor(127, 255, 0, 255)
love.graphics.rectangle('line', -w/4, -h/4, w/2, h/2)
love.graphics.pop()
love.graphics.setColor(255, 255, 0, 255)
love.graphics.rectangle('line', -w/4, -h/4, w/2, h/2)
love.graphics.pop()
love.graphics.setColor(255, 127, 0, 255)
love.graphics.rectangle('line', -w/4, -h/4, w/2, h/2)
love.graphics.pop()
love.graphics.setColor(255, 0, 0, 255)
love.graphics.rectangle('line', -w/4, -h/4, w/2, h/2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment