hello I am using love2dcs however I use these docs to look up most things since its almost the same.
my question is how would lua love2d load a image like a canvas and draw to it?
I would guess it would be possible since a image and a canvas are basically the same thing.
however due to the lack of support for pulling imagedata from a image as of love 11,
I wouldn't be surprised if there was a oversight in this as well.
how would vanilla love2d draw unto a image(NOT A CANVAS)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Citizen
- Posts: 73
- Joined: Wed Oct 28, 2015 11:18 pm
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: how would vanilla love2d draw unto a image(NOT A CANVAS)
The big difference between Images and Canvases is that you can draw to a Canvas, and you can't draw to an Image. If both had equal capabilities, there wouldn't be any reason to have them separated.
What are you trying to do? Maybe there's an alternative that we can recommend. It is also possible to update an Image's contents after it's loaded via Image:replacePixels, and if you load a file into an ImageData (love.image.newImageData) and then create an Image using that ImageData, you can update the ImageData's pixels and then call Image:replacePixels, which replicates the old Image:getData/Image:refresh behaviour.
What are you trying to do? Maybe there's an alternative that we can recommend. It is also possible to update an Image's contents after it's loaded via Image:replacePixels, and if you load a file into an ImageData (love.image.newImageData) and then create an Image using that ImageData, you can update the ImageData's pixels and then call Image:replacePixels, which replicates the old Image:getData/Image:refresh behaviour.
-
- Citizen
- Posts: 73
- Joined: Wed Oct 28, 2015 11:18 pm
Re: how would vanilla love2d draw unto a image(NOT A CANVAS)
@slime
so idk if C# code is allowed here but basically this is what I was trying to do
I wanted a way I could have images be used as canvases so I don't need to convert back and forth.
maybe a just storing a canvas would be better? that is if they support being drawn, drawn to, and created from image files.
currently my Image class is a wrapper around love.image and love.imagedata
so idk if C# code is allowed here but basically this is what I was trying to do
Code: Select all
public static void SetColor(Color color)
{
Love.Graphics.SetColor((Love.Color)color);
}
/*
//SetImage function for my customn Graphics manager.
public static void SetImage(Image image)
{
//note I am trying to convert a Love image to a Love Canvas and then set it as the surface.
Love.Graphics.SetCanvas((Love.Canvas)((Love.Image)image));
}
*/
maybe a just storing a canvas would be better? that is if they support being drawn, drawn to, and created from image files.
currently my Image class is a wrapper around love.image and love.imagedata
Re: how would vanilla love2d draw unto a image(NOT A CANVAS)
For rendering purposes you don't need to do this conversion, you can just render the canvas itself as if it was an image.
Do you really need a canvas for this? You can just render all of your GUI details every frame, it's no big deal especially if it gets spritebatched.
Off topic; wouldn't regular Love2d run faster, because of LuaJIT?
Do you really need a canvas for this? You can just render all of your GUI details every frame, it's no big deal especially if it gets spritebatched.
Off topic; wouldn't regular Love2d run faster, because of LuaJIT?
-
- Citizen
- Posts: 73
- Joined: Wed Oct 28, 2015 11:18 pm
Re: how would vanilla love2d draw unto a image(NOT A CANVAS)
ya I would like it i'm not doing gui right now I was making a json entity config framework.
also idk if it would run faster or not but I hate lua's if..end syntax with a passion I find it ugly and unreadable.
I also like using C# for its object oriented syntax. in lua you have to mess with metatables and deep cloning
also idk if it would run faster or not but I hate lua's if..end syntax with a passion I find it ugly and unreadable.
I also like using C# for its object oriented syntax. in lua you have to mess with metatables and deep cloning
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: how would vanilla love2d draw unto a image(NOT A CANVAS)
Not if you use a decent class library, and the syntax thing is of course subjective, but i digressShadowblitz16 wrote: ↑Fri Dec 13, 2019 6:31 am ya I would like it i'm not doing gui right now I was making a json entity config framework.
also idk if it would run faster or not but I hate lua's if..end syntax with a passion I find it ugly and unreadable.
I also like using C# for its object oriented syntax. in lua you have to mess with metatables and deep cloning
Anyway, vanilla löve can still load in images into ImageData first, and create images from that; that's the workflow it wants you to use. Also, i might be misinterpreting the inherent issue, but both ImageData and Canvases are good for similar things (i.e. allowing modifications to them), but the former is CPU-side, the latter is GPU-side manipulation, basically.
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: how would vanilla love2d draw unto a image(NOT A CANVAS)
Well analyze your GPU code because unless you're doing something that requires canvases, you're incurring performance penalty for no reason by using them, on account of having to render the canvas itself after you've already did all the rendering.Shadowblitz16 wrote: ↑Fri Dec 13, 2019 6:31 am ya I would like it i'm not doing gui right now I was making a json entity config framework.
also idk if it would run faster or not but I hate lua's if..end syntax with a passion I find it ugly and unreadable.
I also like using C# for its object oriented syntax. in lua you have to mess with metatables and deep cloning
I used to hate Lua because it didn't had curly brackets but it's just a matter of habit, you get used to it. As for classes, I'm pretty sure you got it wrong.
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 9 guests