Jump to content

dxDrawText - same text Scale in other resolutions.


Recommended Posts

Hi, my problem is, there is users using 800 * 600 resolution, and users using 1600 * 900 resolution.

How should be the algorithm of this scaling?

I solved the position problem, but scaling algorithm is too hard :mrgreen:

example:

(I'm creating texts with a MTA using 1600 * 900 resolution)

  
local width, height = guiGetScreenSize() 
scaleX = width/1600 
scaleY = height/900 
  
... 
function renderText() 
    dxDrawText("text", 487*scaleX, 244*scaleY, 682*scaleX, 261*scaleY, tocolor(255, 255, 255, 255), 1 * (???), "default") 
end 
  

??? = ? :mrgreen:

Link to comment

You can just sorta combine random algorithms, until you get it. Try using something like this:

  
local width, height = guiGetScreenSize() 
scaleX = width/1600 
scaleY = height/900 
  
function renderText() 
    dxDrawText("text", 487*scaleX, 244*scaleY, 682*scaleX, 261*scaleY, tocolor(255, 255, 255, 255), (scaleX+scaleY), "default") 
end 
  

Link to comment

You should just work over relative values.

eg:

  
--Original resolution made on 1360*768 
local width,height = guiGetScreenSize() 
local Difference = 0.8 -- Reducing exponential difference throught scales 
ScaleWorkout = ( ( 1360 / width ) * ( 768 / height ) ) * Difference 
dxDrawText("text", width * 0.2, height * 0.5, width * 0.4, height * 0.6, tocolor(255,0,0,255), 2 / ScaleWorkout, "default") 
  

BTW: I'm still looking for an efficient text scaling, the exponential size going to 800x600 without the exponential reduction is a very small text, this should work perfectly, but it will be a bit too much.

Link to comment

Thx. I tried that already. But the problem is, that the ratio of the resolutions are not same.

800/600 = 1.33..

1600/900 = 1.77..

I pasted a little sticker on my monitor full bottom of the text.

and changed the resolution of the game to 800*600

and sticker was no more under the text.

Link to comment

well why dont you check for every screen like this ,

Example ,

height , width = guiGetScreenSize() 
scaleX = width 
scaleY = height 
if ( scaleX == 1600 and scaleY == 900 ) or ( scaleX == 800 and scaleY == 600 ) then 
--- do something 

Link to comment

My code should work, it just needs some maths workout for the exponentials including widescreen values based on the difference width-height.

BTW: You're doing something wrong by using the text position with text scaling, just use the relative values (e.g. width*0.2) for position. Then work out the maths for scale.

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...