How can I resize an image without resizing the entire co-ordinate system

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
shabbs15
Prole
Posts: 6
Joined: Sat Jun 29, 2019 8:43 am

How can I resize an image without resizing the entire co-ordinate system

Post by shabbs15 »

Code: Select all

window = love.window.setMode( 500, 500 )
love.graphics.setDefaultFilter("nearest", "nearest", 0)

monsterImage = love.graphics.newImage("Monster.png")

love.graphics.setBackgroundColor(255, 255, 255)

function love.draw()
    love.graphics.scale(4,4)    
    love.graphics.draw(monsterImage, 50, 50)
end
When I run this, the image is 4 times larger but it's position is also 4 times bigger so this means it is in the centre of the screen. How can I only enlarge the image and not it's position.

Sorry for the, I'm guessing, easy question
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Re: How can I resize an image without resizing the entire co-ordinate system

Post by KayleMaster »

Did you try scaling in the draw call instead of the entire stack? sx, sy are the parameters, check the API.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: How can I resize an image without resizing the entire co-ordinate system

Post by raidho36 »

Image is drawn at its top left corner, but you can offset it to draw it at its center instead. You can use extended draw command with more arguments to do this.
shabbs15
Prole
Posts: 6
Joined: Sat Jun 29, 2019 8:43 am

Re: How can I resize an image without resizing the entire co-ordinate system

Post by shabbs15 »

KayleMaster wrote: Sat Jun 29, 2019 12:42 pm Did you try scaling in the draw call instead of the entire stack? sx, sy are the parameters, check the API.
I thought I did that in the draw call. Can you expand on what you think I should do. Sorry for the late response btw
tahoma
Prole
Posts: 22
Joined: Mon Apr 22, 2019 1:13 am

Re: How can I resize an image without resizing the entire co-ordinate system

Post by tahoma »

shabbs15 wrote: Tue Jul 02, 2019 3:14 pm
KayleMaster wrote: Sat Jun 29, 2019 12:42 pm Did you try scaling in the draw call instead of the entire stack? sx, sy are the parameters, check the API.
I thought I did that in the draw call. Can you expand on what you think I should do. Sorry for the late response btw
See the definition of the draw function. Scaling factors some in as inputs to the function.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: How can I resize an image without resizing the entire co-ordinate system

Post by pgimeno »

I think shabbs15 confused the draw event/callback (love.draw) with the draw call (love.graphics.draw).
Post Reply

Who is online

Users browsing this forum: Google [Bot], slime and 46 guests