Created
January 8, 2017 20:41
-
-
Save serpent7776/a8d6a628d6fb5418362d596732a40e8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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