Translate a pair display position coordinates to pixel coordinates. To be used with `Strings.DisplayString` and `Strings.DisplayString:SetPosition`. @function PercentToScreen @tparam float x X component of the display position. @tparam float y Y component of the display position. @treturn int x X coordinate in pixels. @treturn int y Y coordinate in pixels. @usage -- Example 1: Simple usage of
| 104 | // -- Example 2: Using PercentToScreen with DisplayString:SetPosition. |
| 105 | // str1:SetPosition(TEN.Util.PercentToScreen(50, 50)) |
| 106 | static std::tuple<int, int> PercentToScreen(float x, float y) |
| 107 | { |
| 108 | float fWidth = g_Configuration.ScreenWidth; |
| 109 | float fHeight = g_Configuration.ScreenHeight; |
| 110 | int resX = (int)std::round(fWidth / 100.0f * x); |
| 111 | int resY = (int)std::round(fHeight / 100.0f * y); |
| 112 | |
| 113 | return std::make_tuple(resX, resY); |
| 114 | } |
| 115 | |
| 116 | /// Translate a Vec2 of display position coordinates to Vec2 pixel coordinates.<br> |
| 117 | // To be used with `Strings.DisplayString` and `Strings.DisplayString:SetPosition`. |
no test coverage detected