本文整理汇总了C++中PlatformCALayer::position方法的典型用法代码示例。如果您正苦于以下问题:C++ PlatformCALayer::position方法的具体用法?C++ PlatformCALayer::position怎么用?C++ PlatformCALayer::position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlatformCALayer
的用法示例。
在下文中一共展示了PlatformCALayer::position方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTileMapContents
void TileGrid::drawTileMapContents(CGContextRef context, CGRect layerBounds) const
{
CGContextSetRGBFillColor(context, 0.3, 0.3, 0.3, 1);
CGContextFillRect(context, layerBounds);
CGFloat scaleFactor = layerBounds.size.width / m_controller.bounds().width();
CGFloat contextScale = scaleFactor / m_scale;
CGContextScaleCTM(context, contextScale, contextScale);
for (TileMap::const_iterator it = m_tiles.begin(), end = m_tiles.end(); it != end; ++it) {
const TileInfo& tileInfo = it->value;
PlatformCALayer* tileLayer = tileInfo.layer.get();
CGFloat red = 1;
CGFloat green = 1;
CGFloat blue = 1;
CGFloat alpha = 1;
if (tileInfo.hasStaleContent) {
red = 0.25;
green = 0.125;
blue = 0;
} else if (m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort) {
red = 0.8;
green = 0.8;
blue = 0.8;
}
TileCohort newestCohort = newestTileCohort();
TileCohort oldestCohort = oldestTileCohort();
if (!m_controller.shouldAggressivelyRetainTiles() && tileInfo.cohort != VisibleTileCohort && newestCohort > oldestCohort)
alpha = 1 - (static_cast<float>((newestCohort - tileInfo.cohort)) / (newestCohort - oldestCohort));
CGContextSetRGBFillColor(context, red, green, blue, alpha);
if (tileLayer->superlayer()) {
CGContextSetLineWidth(context, 0.5 / contextScale);
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
} else {
CGContextSetLineWidth(context, 1 / contextScale);
CGContextSetRGBStrokeColor(context, 0.2, 0.1, 0.9, 1);
}
CGRect frame = CGRectMake(tileLayer->position().x(), tileLayer->position().y(), tileLayer->bounds().size().width(), tileLayer->bounds().size().height());
CGContextFillRect(context, frame);
CGContextStrokeRect(context, frame);
CGContextSetRGBFillColor(context, 0, 0, 0, 0.5);
String repaintCount = String::number(m_tileRepaintCounts.get(tileLayer));
CGContextSaveGState(context);
tileLayer->drawTextAtPoint(context, frame.origin.x + 64, frame.origin.y + 192, CGSizeMake(3, -3), 58,
repaintCount.ascii().data(), repaintCount.length());
CGContextRestoreGState(context);
}
}