50 lines
952 B
Lua
50 lines
952 B
Lua
|
Canvas = {class = "Canvas"}
|
||
|
|
||
|
function Canvas:New(name)
|
||
|
local o = {}
|
||
|
o.name = name
|
||
|
o.width = game.width/game.scale
|
||
|
o.height = game.height/game.scale
|
||
|
o.canvas = love.graphics.newCanvas(o.width,o.height)
|
||
|
|
||
|
setmetatable(o, self)
|
||
|
self.__index = self
|
||
|
Canvas[name] = o
|
||
|
end
|
||
|
|
||
|
function Canvas:Recreate()
|
||
|
self.canvas:release()
|
||
|
self = Canvas:New(self.name)
|
||
|
end
|
||
|
|
||
|
function Canvas:Reset()
|
||
|
love.graphics.setCanvas(Canvas[self.name].canvas)
|
||
|
love.graphics.setBlendMode("replace")
|
||
|
love.graphics.setColor(0,0,0,0)
|
||
|
love.graphics.rectangle(
|
||
|
"fill",
|
||
|
0,
|
||
|
0,
|
||
|
self.width,
|
||
|
self.height
|
||
|
)
|
||
|
love.graphics.setCanvas()
|
||
|
end
|
||
|
|
||
|
function Canvas:DrawingStart()
|
||
|
self:Reset()
|
||
|
love.graphics.setCanvas(Canvas[self.name].canvas)
|
||
|
end
|
||
|
|
||
|
function Canvas:DrawingEnd()
|
||
|
love.graphics.setCanvas()
|
||
|
love.graphics.setBlendMode("alpha")
|
||
|
love.graphics.setColor(1,1,1,1)
|
||
|
end
|
||
|
|
||
|
function Canvas:Draw()
|
||
|
love.graphics.draw(self.canvas)
|
||
|
end
|
||
|
|
||
|
require "code/canvasses/darkness"
|