[solved] Canvases
Posted: Fri Nov 02, 2018 10:47 pm
If I want to draw something to a canvas, do I need to put the draw functions to draw something on to the canvas in the love.draw function? And how do I draw something to a canvas?
Code: Select all
-- create a canvas somewhere outside love.draw
local myCanvas = love.graphics..newCanvas ( width, height, {format="normal"}, 1 )
-- set the canvas inside love.draw, and clear its contents if need be
love.graphics.setCanvas ( myCanvas )
love.graphics.clear()
-- draw things to canvas with love.graphics.draw, love.graphics.rectangle, or other methods here
-- unset the canvas
love.graphics.setCanvas()
-- draw the canvas to screen
love.graphics.draw ( myCanvas, x, y, rotation, scaleX, scaleY )
I have seen your code but why do things get discoloured?MrFariator wrote: ↑Sat Nov 03, 2018 12:23 amWhen you draw stuff between the "set" and "unset" steps, everything you draw ends up on the canvas.Code: Select all
-- create a canvas somewhere outside love.draw local myCanvas = love.graphics..newCanvas ( width, height, {format="normal"}, 1 ) -- set the canvas inside love.draw, and clear its contents if need be love.graphics.setCanvas ( myCanvas ) love.graphics.clear() -- draw things to canvas with love.graphics.draw, love.graphics.rectangle, or other methods here -- unset the canvas love.graphics.setCanvas() -- draw the canvas to screen love.graphics.draw ( myCanvas, x, y, rotation, scaleX, scaleY )