fix: make gui functions return a texture

Fix #14
This commit is contained in:
Kazhnuz 2020-08-02 13:29:41 +02:00
parent 77d793dc66
commit 16f3ea023b

View file

@ -11,9 +11,9 @@ function gui.newBorder(width, height, middlePosition)
tilequad[3] = love.graphics.newQuad(40, 0, 20, 20, w, h) tilequad[3] = love.graphics.newQuad(40, 0, 20, 20, w, h)
tilequad[4] = love.graphics.newQuad(60, 0, 20, 20, w, h) tilequad[4] = love.graphics.newQuad(60, 0, 20, 20, w, h)
local Texture = love.graphics.newCanvas(width, height) local canvas = love.graphics.newCanvas(width, height)
love.graphics.setCanvas(Texture) love.graphics.setCanvas(canvas)
utils.graphics.resetColor() utils.graphics.resetColor()
local height = math.ceil(height / 20) local height = math.ceil(height / 20)
@ -37,7 +37,12 @@ function gui.newBorder(width, height, middlePosition)
love.graphics.setCanvas( ) love.graphics.setCanvas( )
return Texture local imagedata = canvas:newImageData()
local texture = love.graphics.newImage( imagedata )
imagedata:release()
canvas:release()
return texture
end end
function gui.drawBar(x, y, width, height) function gui.drawBar(x, y, width, height)
@ -108,7 +113,11 @@ function gui.newTextBox(filename, width, height)
love.graphics.setCanvas( ) love.graphics.setCanvas( )
return canvas local imagedata = canvas:newImageData()
local texture = love.graphics.newImage( imagedata )
imagedata:release()
canvas:release()
return texture
end end