MCPcopy Create free account
hub / github.com/Tencent/tgfx / CreateImageLayer

Function CreateImageLayer

drawers/src/layertree/SimpleLayerTree.cpp:83–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static std::shared_ptr<tgfx::Layer> CreateImageLayer(const AppHost* host) {
84 auto image = host->getImage("bridge");
85 if (!image) {
86 return nullptr;
87 }
88 auto card = tgfx::Layer::Make();
89 auto cardMatrix = tgfx::Matrix::MakeTrans(24, 150);
90 auto imageLayer = tgfx::ImageLayer::Make();
91 imageLayer->setImage(image);
92 auto imageScale = static_cast<float>(std::min(327.0 / image->width(), 344.0 / image->height()));
93 auto maskLayer = tgfx::ShapeLayer::Make();
94 maskLayer->setFillStyle(tgfx::SolidColor::Make());
95 auto maskPath = tgfx::Path();
96 auto radius = 20.f / imageScale;
97 maskPath.addRoundRect(tgfx::Rect::MakeWH(image->width(), image->height()), radius, radius);
98 maskLayer->setPath(maskPath);
99 imageLayer->setMask(maskLayer);
100 cardMatrix.preScale(imageScale, imageScale);
101 card->setMatrix(cardMatrix);
102 card->addChild(imageLayer);
103 card->addChild(maskLayer);
104 card->setFilters(
105 {tgfx::DropShadowFilter::Make(0, 8, 32, 32, tgfx::Color::FromRGBA(6, 0, 71, 51))});
106 return card;
107}
108
109std::shared_ptr<tgfx::Layer> SimpleLayerTree::buildLayerTree(const AppHost* host) {
110 auto root = tgfx::Layer::Make();

Callers 1

buildLayerTreeMethod · 0.85

Calls 14

MakeFunction · 0.85
setFillStyleMethod · 0.80
addRoundRectMethod · 0.80
setPathMethod · 0.80
setMaskMethod · 0.80
preScaleMethod · 0.80
addChildMethod · 0.80
setFiltersMethod · 0.80
PathClass · 0.50
getImageMethod · 0.45
setImageMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected