VirtualToRealCoords

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


Screen

native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom = false, bool handleaspect = true)

Usage

Used to translates coordinates in a virtual canvas to real screen coordinates. Useful if you want to do something like translate a position in the status bar to an actual location on the screen since the status bar uses scaled coordinates. Coordinates start from the top left of the screen with positive x values shifting to the right and positive y values shifting downward.

Parameters

  • pos - The xy offset of the coordinate in the virtual canvas
  • size - the width and height respectively of the bounding box in the virtual canvas
  • vsize - the virtual width and virtual height to use respectively for the virtual canvas
  • vbottom - Default is false. If true scales the y coordinate based off the bottom of the screen instead of the top. Only used for tall aspect ratios (e.g. 5:4)
  • handleaspect - Default is true. If true, uses the current aspect ratio of the screen. Otherwise assumes a 4:3 aspect ratio

Return value

Returns two values in this order:

  • The top left coordinate of the box scaled to real screen coordinates
  • The size of the box scaled to real screen coordinates

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.