Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Transform mouse coordinates into local space of an image

Author
Message
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 6th Oct 2017 07:39
Hey there,

is there a way to transform mouse (touch) coordinates into the local space of an image.

Example: Let's say I have an image which is 100x100px and rotated by 45°. As soon as the mouse pointer is above that image I want to have the mouse coordinates transformed into the local space of that image which means they would go from 0...100 depending where the mouse pointer exactly is within that rotated image.

How can this be achieved? Thanks.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 6th Oct 2017 11:24
Like this: ?

Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 6th Oct 2017 11:37
You're awesome, thanks! This works perfectly!
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 6th Oct 2017 11:41
Your welcome

I wrapped it into a couple of handy functions

Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 8th Oct 2017 08:44
Thank you, you helped me a lot! At some part in the future I hope to give back some knowledge from my side.

Login to post a reply

Server time is: 2024-04-25 10:41:13
Your offset time is: 2024-04-25 10:41:13