本文整理汇总了C++中UILayer::getRatio方法的典型用法代码示例。如果您正苦于以下问题:C++ UILayer::getRatio方法的具体用法?C++ UILayer::getRatio怎么用?C++ UILayer::getRatio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UILayer
的用法示例。
在下文中一共展示了UILayer::getRatio方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: repaint
void UILabel::repaint(EngineInternals &internals, const UILayer &ui)
{
_elements.clear();
_elementPointers.clear();
_textures.clear();
float x = 0;
float y = 0;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
std::wstring result = convert.from_bytes(_text);
Vector2 resolution(size.x * ui.getRatio(), size.y * ui.getRatio());
for (std::wstring::const_iterator i = result.begin(); i != result.end(); i++)
{
auto &g = _typeEngine.getGlyph(*i, (unsigned int)resolution.y);
float x2 = x + (float)g.bitmap.left;
float y2 = y + (resolution.y - (float)g.bitmap.top);
Texture2D *tex;
if (_textures.find(*i) != _textures.end())
{
tex = _textures[*i].get();
}
else
{
_textures[*i] = std::make_shared<Texture2D>(g.bitmap.buffer, Pixmap::Information(Metric2(g.bitmap.width, g.bitmap.height), Pixmap::Information::Format::ALPHA, 8));
tex = _textures[*i].get();
}
UIElement glyph = UIElement(Vector2((float)g.bitmap.width / ui.getRatio(), (float)g.bitmap.height / ui.getRatio()), Alignment::TOP_LEFT, Vector2(x2 / ui.getRatio(), y2 / ui.getRatio()), tex);
glyph.uvs[0] = Vector2(0, 0);
glyph.uvs[1] = Vector2(1, 0);
glyph.uvs[2] = Vector2(1, 1);
glyph.uvs[3] = Vector2(0, 1);
x += g.advance.x;
y += g.advance.y;
_elements.push_back(glyph);
}
for (auto &element : _elements)
{
_elementPointers.push_back(&element);
}
if (!_fixed)
{
size.x = x / ui.getRatio();
}
}