Skip to content

Instantly share code, notes, and snippets.

@serpent7776
Created January 8, 2017 20:41
Show Gist options
  • Select an option

  • Save serpent7776/a8d6a628d6fb5418362d596732a40e8f to your computer and use it in GitHub Desktop.

Select an option

Save serpent7776/a8d6a628d6fb5418362d596732a40e8f to your computer and use it in GitHub Desktop.

Revisions

  1. serpent7776 created this gist Jan 8, 2017.
    24 changes: 24 additions & 0 deletions main.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    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