Resizing images
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 16
- Joined: Fri Jan 15, 2016 6:33 pm
Resizing images
Sorry I know this is a noob question but how do I resize an image. I know how to insert an image but the problem is I don't know how to resize it. Thanks.
Re: Resizing images
There's multiple ways, you can use graphics transforms like love.graphics.scale (probably alongside lg.push/pop) or you can use the scale parameters (sx/sy) of the love.graphics.draw, just look at the wiki.
-
- Prole
- Posts: 16
- Joined: Fri Jan 15, 2016 6:33 pm
Re: Resizing images
Thanks again! So if I was to add a plane to my game I could do this to scale it?
Code: Select all
plane = love.graphics.newImage("plane.png")
love.graphics.scale(0.5, 0.5)
Re: Resizing images
No. Please read the wiki page. There's a perfect example on the bottom even. Also the second method is probably more useful for you anyway, and also documented nicely on the wiki.
-
- Prole
- Posts: 16
- Joined: Fri Jan 15, 2016 6:33 pm
Re: Resizing images
Ok, I read the wiki page and I tried for an hour to scale the image but I have not had success. I am a huge noob to this so I really don't know how to do it. Please tell me how to scale an image. The wiki tells me how to scale text. I tried with an image but it didn't work.
Re: Resizing images
love.graphics.scale applies to images, text and graphics primitives alike, as the wiki page says aswell:
but, like I said, love.graphics.scale is probably not what you want, as the same can be accomplished much more reasily using just love.draw:
All you need to do issomeone on the wiki wrote: Scales the coordinate system in two dimensions.
After scaling by sx and sy, all coordinates are treated as if they were multiplied by sx and sy. Every result of a drawing operation is also correspondingly scaled, so scaling by (2, 2) for example would mean making everything twice as large in both x- and y-directions.
Code: Select all
-- somewhere, outside of a callback
plane = love.graphics.newImage("plane.png")
-- somewhere, probably in love.draw
love.graphics.push()
love.graphics.scale(0.5, 0.5)
love.graphics.draw(plane, 200/0.5, 200/0.5) -- '/ 0.5' because scale affects everything, including position obviously
love.graphics.pop() -- so the scale doesn't affect anything else
Code: Select all
-- somewhere, outside of a callback
plane = love.graphics.newImage("plane.png")
-- somewhere, probably in love.draw
love.graphics.draw(plane, 200, 200, 0, 0.5, 0.5) -- 0 is for rotation, see the wiki
-
- Prole
- Posts: 16
- Joined: Fri Jan 15, 2016 6:33 pm
Re: Resizing images
Ah, thank you very much! You are the most helpful person on this forum
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests