How to rotate an img based on a reference point?

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
User avatar
weilies
Prole
Posts: 28
Joined: Sat Oct 09, 2010 6:16 am

How to rotate an img based on a reference point?

Post 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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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. ;)
Help us help you: attach a .love.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

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

Post 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:
Hello, I am not dead.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post by Robin »

zac, please don't do that.

weilies: you can ignore zac's post.
Help us help you: attach a .love.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

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

Post 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
Hello, I am not dead.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 6 guests