diff options
Diffstat (limited to 'not/Layer.lua')
-rw-r--r-- | not/Layer.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/not/Layer.lua b/not/Layer.lua new file mode 100644 index 0000000..db16175 --- /dev/null +++ b/not/Layer.lua @@ -0,0 +1,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 |