MAB Posted July 18, 2015 Posted July 18, 2015 How to make images , lines , rectangles fit all screen resolutions?
Dealman Posted July 19, 2015 Posted July 19, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now