Jump to content

Screen Resolution


Recommended Posts

Of course, it's very simple math - you're using relative values instead of absolute. Relative values range from 0 to 1 and are floating point values, rather than integers like the absolute values are.

For example, using absolute values you'd do it like this;

dxDrawRectangle(860, 440, 200, 200) -- Creates a Rectangle 200x200 pixels wide, centered for 1920x1080. 

This will only work for 1920x1080, if you use a smaller resolution it will look as if it's too big. If you use a bigger resolution, it would be too small. To make it relative, you divide the absolute value with the source resolution(In this case it was designed on a 1920x1080 resolution). Then you multiply this by the current screen resolution.

local screenWidth, screenHeight = guiGetScreenSize() 
dxDrawRectangle((860/1920)*screenWidth, (440/1080)*screenHeight, (200/1920)*screenWidth, (200/1080)*screenHeight) -- Creates a Rectangle 200x200 pixels wide, centered for all resolutions. 
-- 860/1920 = 0.4479166666666667 
-- 0.4479166666666667 * 1920 = 860 

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...