summaryrefslogtreecommitdiffhomepage
path: root/not/Layer.lua
blob: db161753b51e9f346379ac0d47d5d588fd8d2006 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
--- A little bit more than just a Canvas.
Layer = require "not.Object":extends()

function Layer:new (width, height)
	self.canvas = love.graphics.newCanvas(width, height)
end

--- Sets this layer as current canvas for drawing with love.graphics functions.
-- @return old canvas used by love
function Layer:setAsCanvas ()
	local c = love.graphics.getCanvas()
	love.graphics.setCanvas(self.canvas)
	return c
end

function Layer:clear ()
	local c = self:setAsCanvas()
	love.graphics.clear()
	love.graphics.setCanvas(c)
end

function Layer:draw ()
	love.graphics.setColor(255, 255, 255, 255)
	love.graphics.draw(self.canvas)
end

return Layer