Page 1 of 1
Rotating images doesn't rotate the image
Posted: Sun Jul 23, 2023 11:23 am
by togFox
In the image above - the image on the right is drawn with zero rotation and draws as expected:
Code: Select all
v.rotation = 0 -- radians
love.graphics.draw(IMAGE[v.imagetype], v.x, v.y, v.rotation, 1, 1, 0,0)
I use the mouse to do bounding box so it has a 'click zone' that works well and everything is good.
The image on the left is rotated by 90 degrees:
Code: Select all
v.rotation = math.pi / 2 -- 90 degrees clockwise expressed as radians
love.graphics.draw(IMAGE[v.imagetype], v.x, v.y, v.rotation, 1, 1, 0,0)
It draws correctly as the image is rotated by the upper left corner - as per normal but I was expecting the bounding box for this image to also rotate but it does not. The bounding box remains as per the unrotated image and is highlighted by the blue box I added to the image.
How do I rotate/transform the image dimensions so that it really rotates and is not just appear to rotate. If I can do that then my bounding box mouse clicks will start to work as expected.
Re: Rotating images doesn't rotate the image
Posted: Sun Jul 23, 2023 3:51 pm
by darkfrei
Use the ox, oy as offset to the middle of your picture:
Code: Select all
love.graphics.draw( drawable, x, y, r, sx, sy, ox, oy, kx, ky )
https://love2d.org/wiki/love.graphics.draw
Re: Rotating images doesn't rotate the image
Posted: Sun Jul 23, 2023 8:52 pm
by togFox
That will shift the drawn image but won't rotate my 'click' zone.
I think I'm going to have to do some run time translation on the click zone based on the rotation of the image before doing a bounding box check.
Re: Rotating images doesn't rotate the image
Posted: Sun Jul 23, 2023 9:32 pm
by togFox
Can someone confirm: rotating the image during love.graphics.draw does not change the values of image:getWidth() and image:getHeight()?
Re: Rotating images doesn't rotate the image
Posted: Sun Jul 23, 2023 10:22 pm
by BrotSagtMist
Of course it does not, what gave you that idea to begin with?
Draw draws data not changing it, getSomething gets a value from that data, which of course has not been changed.
And we have no idea where your bounding box actually comes from, you left that code out.