How to get the size of the image knowing the scale given to it when drawing

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
notcl4y
Citizen
Posts: 85
Joined: Fri Nov 25, 2022 12:23 pm

How to get the size of the image knowing the scale given to it when drawing

Post by notcl4y »

Or vice versa.

Code: Select all

loves_lua = "not so",
wants_to = true
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: How to get the size of the image knowing the scale given to it when drawing

Post by MrFariator »

If you have an image, you can get its dimensions with getDimensions. Multiply these by your scaling factor.
User avatar
notcl4y
Citizen
Posts: 85
Joined: Fri Nov 25, 2022 12:23 pm

Re: How to get the size of the image knowing the scale given to it when drawing

Post by notcl4y »

MrFariator wrote: Mon Jun 26, 2023 5:07 pm If you have an image, you can get its dimensions with getDimensions. Multiply these by your scaling factor.
What about vice versa? Divide these by dimensions?

Code: Select all

loves_lua = "not so",
wants_to = true
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: How to get the size of the image knowing the scale given to it when drawing

Post by MrFariator »

If you know the scaling factor used to scale up the images while drawing, then you just divide the dimensions by the scaling factor, yeah. Of course, that assumes that you know the resulting drawn dimensions of the image. This is because getDimensions returns the dimensions of the texture, it won't give you the dimensions the image was last drawn with.
User avatar
notcl4y
Citizen
Posts: 85
Joined: Fri Nov 25, 2022 12:23 pm

Re: How to get the size of the image knowing the scale given to it when drawing

Post by notcl4y »

MrFariator wrote: Mon Jun 26, 2023 5:28 pm If you know the scaling factor used to scale up the images while drawing, then you just divide the dimensions by the scaling factor, yeah. Of course, that assumes that you know the resulting drawn dimensions of the image. This is because getDimensions returns the dimensions of the texture, it won't give you the dimensions the image was last drawn with.
Ok, thanks

Code: Select all

loves_lua = "not so",
wants_to = true
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], zingo and 5 guests