Page 1 of 1

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

Posted: Sat Jun 29, 2019 8:50 am
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

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

Posted: Sat Jun 29, 2019 12:42 pm
by KayleMaster
Did you try scaling in the draw call instead of the entire stack? sx, sy are the parameters, check the API.

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

Posted: Sat Jun 29, 2019 9:15 pm
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.

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

Posted: Tue Jul 02, 2019 3:14 pm
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

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

Posted: Tue Jul 02, 2019 5:27 pm
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.

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

Posted: Tue Jul 02, 2019 9:15 pm
by pgimeno
I think shabbs15 confused the draw event/callback (love.draw) with the draw call (love.graphics.draw).