Copying Canvases?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
IndieLöver
Prole
Posts: 29
Joined: Mon Jun 10, 2013 8:49 am

Copying Canvases?

Post 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
Joemag
Prole
Posts: 24
Joined: Sun Apr 14, 2013 5:42 pm

Re: Copying Canvases?

Post 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)

User avatar
IndieLöver
Prole
Posts: 29
Joined: Mon Jun 10, 2013 8:49 am

Re: Copying Canvases?

Post by IndieLöver »

Thanks Joemag. It's amazing how fast people respond here. I löve this community :awesome:
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 76 guests