Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function love.load()
screenWidth = love.graphics.getWidth()
screenHeight = love.graphics.getHeight()
canvas = love.graphics.newCanvas(screenWidth, screenHeight)
end
function love.draw(dt)
-- draw to canvas
love.graphics.setCanvas(canvas)
local w = screenWidth / 2
love.graphics.setBlendMode('alpha')
-- draw cyan rect on the left
love.graphics.setColor(0, 255, 255)
love.graphics.rectangle('fill', 0, 0, w, screenHeight)
-- draw yellow rect on the right
love.graphics.setColor(255, 255, 0)
love.graphics.rectangle('fill', w, 0, w, screenHeight)
love.graphics.setCanvas()
-- blit canvas to screen
love.graphics.clear()
love.graphics.setBlendMode("alpha", "premultiplied")
love.graphics.draw(canvas)
-- after drawing canvas to screen, left rect is green
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment