[SOLVED] Drawing shapes on an image
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[SOLVED] Drawing shapes on an image
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.
Last edited by Jetmate on Tue May 16, 2017 9:16 pm, edited 1 time in total.
Re: Drawing shapes on an image
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.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Drawing shapes on an image
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.
As for drawing on Canvases, setting a canvas as the active... canvas will allow you to do this.
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.
Re: Drawing shapes on an image
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?
Last edited by Jetmate on Sat May 13, 2017 2:55 pm, edited 1 time in total.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Drawing shapes on an image
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.
Converting a canvas to an image is a bit pointless in this case, i think.
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.
Re: Drawing shapes on an image
Generally, then, what's the advantages to using images over canvases? Is it just easier because you can quickly create images from a file?
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Drawing shapes on an image
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.
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: Ahrefs [Bot], pgimeno and 1 guest