[SOLVED] Drawing shapes on an image

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
Jetmate
Prole
Posts: 12
Joined: Sun May 07, 2017 5:48 pm

[SOLVED] Drawing shapes on an image

Post 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.
Last edited by Jetmate on Tue May 16, 2017 9:16 pm, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Drawing shapes on an image

Post 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.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Drawing shapes on an image

Post 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.
Me and my stuff :3True 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.
User avatar
Jetmate
Prole
Posts: 12
Joined: Sun May 07, 2017 5:48 pm

Re: Drawing shapes on an image

Post 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?
Last edited by Jetmate on Sat May 13, 2017 2:55 pm, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Drawing shapes on an image

Post 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.
Me and my stuff :3True 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.
User avatar
Jetmate
Prole
Posts: 12
Joined: Sun May 07, 2017 5:48 pm

Re: Drawing shapes on an image

Post 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?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Drawing shapes on an image

Post 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.
Me and my stuff :3True 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 5 guests