Page 1 of 1

How to rotate an img based on a reference point?

Posted: Sun Oct 10, 2010 4:26 pm
by weilies
I realized the love framework always based on point 0,0

Imagine I loaded arrow up image and rotate 30 degree, the rotation point suppose to based on the bottom of the img and not 0, 0 of the img

Re: How to rotate an img based on a reference point?

Posted: Sun Oct 10, 2010 4:32 pm
by Robin
Look at http://love2d.org/wiki/love.graphics.draw

The last two parameters, ox and oy are the origin offset, around that point are images rotated.

When in doubt, read the wiki. ;)

Re: How to rotate an img based on a reference point?

Posted: Sun Oct 10, 2010 5:19 pm
by zac352
Then there's doing it manually...

Code: Select all

local angle;
local x,y;
local ox,oy;

local a,b=math.sin(angle),math.cos(angle) --Trig ftw.
local rx,ry=x+a*ox,y+a*oy;
If that doesn't work, blame my sugar rush from just drinking a LOT of pepsi. :death:

Re: How to rotate an img based on a reference point?

Posted: Sun Oct 10, 2010 5:48 pm
by Robin
zac, please don't do that.

weilies: you can ignore zac's post.

Re: How to rotate an img based on a reference point?

Posted: Sun Oct 10, 2010 6:03 pm
by zac352
Robin wrote:zac, please don't do that.

weilies: you can ignore zac's post.
I'm sowwy. :(
I couldn't help it. :3