MCPcopy Create free account
hub / github.com/axmolengine/axmol / color3BWithString

Method color3BWithString

core/ui/UIRichText.cpp:1676–1700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1674}
1675
1676ax::Color3B RichText::color3BWithString(std::string_view color)
1677{
1678 if (color.length() == 4)
1679 {
1680 unsigned int r, g, b;
1681 sscanf(color.data(), "%*c%1x%1x%1x", &r, &g, &b);
1682 r += r * 16;
1683 g += g * 16;
1684 b += b * 16;
1685 return Color3B(r, g, b);
1686 }
1687 else if (color.length() == 7)
1688 {
1689 unsigned int r, g, b;
1690 sscanf(color.data(), "%*c%2x%2x%2x", &r, &g, &b);
1691 return Color3B(r, g, b);
1692 }
1693 else if (color.length() == 9)
1694 {
1695 unsigned int r, g, b, a;
1696 sscanf(color.data(), "%*c%2x%2x%2x%2x", &r, &g, &b, &a);
1697 return Color3B(r, g, b);
1698 }
1699 return Color3B::WHITE;
1700}
1701
1702std::string RichText::stringWithColor3B(const ax::Color3B& color3b)
1703{

Callers 2

startElementMethod · 0.80

Calls 3

Color3BFunction · 0.85
lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected