SA-MP Forums Archive
Huge math problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Huge math problem. (/showthread.php?tid=543021)



Huge math problem. - Fj0rtizFredde - 23.10.2014

Hey, long time no see.

Since math isn't my strong side I really hope you guys can help me.

So I got a plugin which gets my screen resolution and cursor position and they do work fine for just outputing what they are created for. My problem is that I'm trying to detect if I have my cursor over a textdraw and since textdraw's are based on the 640x480 canvas how would I calculate the correct position for my cursor?

Let's make a simple example:
Textdraw Position: X: 90.0, Y: 120.0 (based on 640x480)
My cursor position at the same place: X: 300.0, Y: 55.0 (based on my resolution)
(Note: This is not any correct numbers that I used, just an example)

So how would I calculate to get my cursor position to be the same as the textdraw?

I really hope you get what I'm talking about haha.


Re: Huge math problem. - KingHual - 23.10.2014

scale_x = resolution_x/640
scale_y = resolution_y/480

coord_x(90) = 90*scale_x
coord_y(120) = 120*scale_y