[solved] Canvases
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 23
- Joined: Fri Oct 26, 2018 8:41 pm
[solved] Canvases
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?
Last edited by Purple Fedora on Wed Nov 21, 2018 10:47 pm, edited 1 time in total.
-
- Party member
- Posts: 512
- Joined: Wed Oct 05, 2016 11:53 am
Re: Canvases
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 )
- zorg
- Party member
- Posts: 3444
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Canvases
To actually answer part of your question, unlike drawing to the screen (more or less) directly, you can render stuff to a canvas outside of love.draw... but unless you're just pre-rendering some static stuff, i'd (erase, and) draw to canvases in love.draw too.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-
- Prole
- Posts: 23
- Joined: Fri Oct 26, 2018 8:41 pm
Re: Canvases
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 )
- zorg
- Party member
- Posts: 3444
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Canvases
Because you forgot to setColor(1,1,1) before drawing the canvas to the screen; the graphics state remembers the last set color, and if you're not careful, it can tint things you don't want tinted.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: No registered users and 228 guests