MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / PercentToScreen

Function PercentToScreen

TombEngine/Scripting/Internal/TEN/Util/Util.cpp:106–114  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 2

PickMoveableFunction · 0.85
PickStaticFunction · 0.85

Calls 1

Vec2Class · 0.85

Tested by

no test coverage detected