Jump to content

[QUESTION] Why change distance?


Tokio

Recommended Posts

I have this script:

        dxDrawRectangle(screenW * 0.7549, screenH * 0.6933 - 1 -  (33*k), screenW * 0.2347, screenH * 0.0211, tocolor(0, 0, 0, 145), false)
		dxDrawText(v.text, screenW * 0.7535, screenH * 0.6933 - 1 - (66*k), screenW * 0.9896, screenH * 0.7144, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, true, false)

and different resolutions the distance grow, or lessen. Picture:

How to fix this problem? I want, that all resulotions distance the same. Thanks the help! :) 

And sorry for my very bad english! :| 

Link to comment
dxDrawRectangle(screenW * 0.7549, screenH * 0.6933 - 1 - (33*k), 1440 * 0.2347, 990 * 0.0211, tocolor(0, 0, 0, 145), false)
dxDrawText(v.text, screenW * 0.7535, screenH * 0.6933 - 1 - (66*k), 1440 * 0.9896, 990 * 0.7144, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, true, false)

Try this.

Link to comment
21 minutes ago, Hale said:

dxDrawRectangle(screenW * 0.7549, screenH * 0.6933 - 1 - (33*k), 1440 * 0.2347, 990 * 0.0211, tocolor(0, 0, 0, 145), false)
dxDrawText(v.text, screenW * 0.7535, screenH * 0.6933 - 1 - (66*k), 1440 * 0.9896, 990 * 0.7144, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, true, false)

Try this.

now does not show in 800x600 

Link to comment
  • Moderators

I recent figured out that this is an easy way to calculate your absolute resolution to relative values:

local yourScreenYResolution = -- <fill in> 900 wasn't it?

local screenX, screenY = guiGetScreenSize()

local scalefactor = 1 / yourScreenYResolution * screenY
-- You created something of 50 pixels on 1440 x 900.
outputDebugString(scalefactor * 50)
-- And now it will be rescaled on all other resolutions correctly.

Try it and don't buy it.

  • Like 2
Link to comment
1 hour ago, IIYAMA said:

I recent figured out that this is an easy way to calculate your absolute resolution to relative values:


local yourScreenYResolution = -- <fill in> 900 wasn't it?

local screenX, screenY = guiGetScreenSize()

local scalefactor = 1 / yourScreenYResolution * screenY

-- You created something of 50 pixels on 1440 x 900.
outputDebugString(scalefactor * 50)
-- And now it will be rescaled on all other resolutions correctly.

Try it and don't buy it.

Sorry, i don't understand this. :( How to add this to code?

Link to comment
  • Moderators

An X amount of pixels on your resolution is automatic scaled to all other resolutions.

 

This for example will create a perfect centred rectangle scaled for all resolutions:

dxDrawRectangle((screenW * 0.5) - (50 * scalefactor), (screenH * 0.5) - (50 * scalefactor), 100 * scalefactor, 100 * scalefactor, tocolor(0, 0, 0, 145), false)

 

 

Link to comment

The main problem with your code, why the length is smaller than the length of the text, is because the bar is relative on both axis, and 1440x900 is a different aspect ratio to 800x600. What you'd want to do is just look at, for example, the width of the screen.

local screenW, screenH = guiGetScreenSize()
local scaleFactor = screenW / 1440 -- higher resoultion than 1440 means scaleFactor > 1, lower means scaleFactor < 1.
dxDrawRectangle(0, 0, 50*scaleFactor, 200*scaleFactor) --This will draw a bar on the top left corner, on your native resoultion, 50 x 200 px, but on a 720x450 (half of your resolution), it would be 25 x 100 px, and on a 800x600 it would be 27.77 x 11.11 px

 

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