Sign in to follow this  
Followers 0
=sinister=

Converting x,y Positions To Different Resolution

7 posts in this topic

#1 ·  Posted (edited)

I made a function to convert x and y positions to different resolutions. My mom helped me with the equation :) so i don't know if it will work exactly. I keep getting decimals, so you might need to roud or take off the decimals along with the numbers. Tell me what ya think. It grabs the resolution of the current window and converts your x and y position. There were 2 different equations, so there are 2 different UDF's.

Func ConvertX($Number)
    $Resolution = WinGetClientSize("")
    $PosX = $Number * $Resolution[0]/800
    Return $PosX
EndFunc

Func ConvertY($Number)
    $Resolution = WinGetClientSize("")
    $PosY = $Number * $Resolution[1]/600
    Return $PosY
EndFunc

:P Hope ya like it.

--Edit--

Forgot to tell you the smallest Resolution it works with is 800x600!

Edited by =sinister=

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

From this topic:

; converts coords (x,y) in (a,b ) screen resolution to (c,d) screen resolution
Func _ConvertCoords( $x, $y, $a, $b, $c = @DesktopWidth, $d = @DesktopHeight )
   Local $ret[2] = [( $c * $x ) / $a, ( $d * $y ) / $b]
   Return $ret
EndFunc

Hope it helps! :)

Edited by erifash

Share this post


Link to post
Share on other sites

I tried yours, and I still get decimals. I think rouding may help? Any ideas?

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

works good enough for me


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

Int($x), Int($y) will return only the integer portions of the numbers. This is a simple way to get integers.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0