| 81 | } |
| 82 | |
| 83 | static 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 | |
| 109 | std::shared_ptr<tgfx::Layer> SimpleLayerTree::buildLayerTree(const AppHost* host) { |
| 110 | auto root = tgfx::Layer::Make(); |
no test coverage detected