Page 1 of 1

Copying Canvases?

Posted: Mon Jul 21, 2014 8:00 pm
by IndieLöver
Hi fellow lövers,

I was just wondering can one copy canvases?

Code: Select all

local oldCanvas = mainCanvas
Obviously that doesn't work, because now the oldCanvas just refers to the mainCanvas. And as far as I know canvases don't have :clone() function like particleEffects do.

Thanks, ;)
IndieLöver

Re: Copying Canvases?

Posted: Mon Jul 21, 2014 9:21 pm
by Joemag
You can create a new canvas and render the old canvas in it:

Code: Select all

local oldCanvas = love.graphics.newCanvas(mainCanvas:getDimensions())
oldCanvas:renderTo(function()
    love.graphics.setColor(255,255,255)
    love.graphics.draw(mainCanvas, 0, 0)
end)


Re: Copying Canvases?

Posted: Tue Jul 22, 2014 4:45 am
by IndieLöver
Thanks Joemag. It's amazing how fast people respond here. I löve this community :awesome: