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

Method LabelOutlineAndGlowTest

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:1619–1660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1617
1618
1619LabelOutlineAndGlowTest::LabelOutlineAndGlowTest()
1620{
1621 auto size = Director::getInstance()->getWinSize();
1622
1623 auto bg = LayerColor::create(Color4B(200, 191, 231, 255));
1624 this->addChild(bg);
1625
1626 TTFConfig ttfConfig("fonts/arial.ttf", 40, GlyphCollection::DYNAMIC, nullptr, true);
1627
1628 // Glow SDF (GPU)
1629 auto label1 = Label::createWithTTF(ttfConfig, "Glow1", TextHAlignment::CENTER, size.width);
1630 label1->setPosition(Vec2(size.width / 2, size.height * 0.7));
1631 label1->setTextColor(Color4B::GREEN);
1632 label1->enableGlow(Color4B::YELLOW);
1633 addChild(label1);
1634
1635 // Glow normal(CPU)
1636 ttfConfig.distanceFieldEnabled = false;
1637 auto label2 = Label::createWithTTF(ttfConfig, "Glow2", TextHAlignment::CENTER, size.width);
1638 label2->setPosition(Vec2(size.width / 2, size.height * 0.6));
1639 label2->setTextColor(Color4B::GREEN);
1640 label2->enableGlow(Color4B::YELLOW);
1641 addChild(label2);
1642
1643 // Outline SDF(GPU)
1644 ttfConfig.distanceFieldEnabled = true;
1645 ttfConfig.outlineSize = 2;
1646 auto label3 = Label::createWithTTF(ttfConfig, "Outline1", TextHAlignment::CENTER, size.width);
1647 label3->setPosition(Vec2(size.width / 2, size.height * 0.48));
1648 label3->setTextColor(Color4B::RED);
1649 label3->enableOutline(Color4B::BLUE);
1650 addChild(label3);
1651
1652 // Outline normal(CPU by freetype2)
1653 ttfConfig.distanceFieldEnabled = false;
1654 ttfConfig.outlineSize = 2;
1655 auto label4 = Label::createWithTTF(ttfConfig, "Outline2", TextHAlignment::CENTER, size.width);
1656 label4->setPosition(Vec2(size.width / 2, size.height * 0.36));
1657 label4->setTextColor(Color4B::RED);
1658 label4->enableOutline(Color4B::BLUE, 2);
1659 addChild(label4);
1660}
1661
1662std::string LabelOutlineAndGlowTest::title() const
1663{

Callers

nothing calls this directly

Calls 9

getInstanceFunction · 0.85
createFunction · 0.85
Color4BFunction · 0.85
Vec2Function · 0.50
addChildMethod · 0.45
setPositionMethod · 0.45
setTextColorMethod · 0.45
enableGlowMethod · 0.45
enableOutlineMethod · 0.45

Tested by

no test coverage detected