Page 1 of 1
[SOLVED] Drawing shapes on an image
Posted: Sat May 13, 2017 2:39 am
by Jetmate
Pygame, which is the previous game API that I used, had an option to draw shapes on another image or canvas - from what I can tell, love only allows those shapes to be drawn directly to the screen. Is there any way around this? Thank you.
Re: Drawing shapes on an image
Posted: Sat May 13, 2017 2:42 am
by raidho36
You can have canvases in love as well. But, textures are not canvases for performance reasons. If you want to draw on another texture, you need to draw that texture to canvas first, then draw your other texture to it.
Re: Drawing shapes on an image
Posted: Sat May 13, 2017 5:22 am
by zorg
Technically, the Texture supertype in löve contains both Images and Canvases, meaning you can use both in functions that expect a Texture.
As for drawing on Canvases, setting a canvas as the active... canvas will allow you to do this.
Re: Drawing shapes on an image
Posted: Sat May 13, 2017 2:03 pm
by Jetmate
Is the process of creating a canvas, setting it as active, drawing on it, and then setting it as inactive generally considered slow? Instead of using it as a texture to draw with, is it faster to first convert it to an image, and then draw that image?
Re: Drawing shapes on an image
Posted: Sat May 13, 2017 2:55 pm
by zorg
Creating a canvas is relatively slow, in that you don't want to create a new one every frame, but the other 3 steps are fine to do every frame.
Converting a canvas to an image is a bit pointless in this case, i think.
Re: Drawing shapes on an image
Posted: Sat May 13, 2017 2:57 pm
by Jetmate
Generally, then, what's the advantages to using images over canvases? Is it just easier because you can quickly create images from a file?
Re: Drawing shapes on an image
Posted: Sat May 13, 2017 3:47 pm
by zorg
Generally, you don't want to edit the pixels of the images when you load them in. Apart from that, maybe someone else has a better answer.