Page 1 of 1

scaling sprite from center

Posted: Sat Dec 14, 2024 9:28 pm
by daegan
hi, im just messing around and trying things out since im new and i was wondering if it's possible to scale a sprite from it's center point? as you can see the rest works well but i couldn't figure that part out...thanks!

Re: scaling sprite from center

Posted: Sun Dec 15, 2024 7:35 pm
by RNavega
Hi, yes, from the center or any other location.

The easiest way to do that is by using the "origin offset" coordinates, it's the ox, oy parameters found in either the love.graphics.draw() function where you manually set them, or when creating/modifying a Transform object (see the docs for love.math.newTransform for more) and using that Transform with the overload of love.graphics.draw() that takes it.

Read pgimeno's in here for more:
- viewtopic.php?p=226336#p226336

These ox,oy values work like a convenience for pre-moving the object to the origin before applying rotation or scale to it, but you still need to set an x,y so the object is moved back where it should be.

(For curiosity, you can manually do the same effect of ox,oy by doing a sequence of operations on a Transform like explained in this.)

Re: scaling sprite from center

Posted: Mon Dec 16, 2024 3:14 pm
by daegan
RNavega wrote: Sun Dec 15, 2024 7:35 pm Hi, yes, from the center or any other location.

The easiest way to do that is by using the "origin offset" coordinates, it's the ox, oy parameters found in either the love.graphics.draw() function where you manually set them, or when creating/modifying a Transform object (see the docs for love.math.newTransform for more) and using that Transform with the overload of love.graphics.draw() that takes it.

Read pgimeno's in here for more:
- viewtopic.php?p=226336#p226336

These ox,oy values work like a convenience for pre-moving the object to the origin before applying rotation or scale to it, but you still need to set an x,y so the object is moved back where it should be.

(For curiosity, you can manually do the same effect of ox,oy by doing a sequence of operations on a Transform like explained in this.)
Thank you! i'll see what i can do.