本文整理汇总了C++中FillLayer::xPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ FillLayer::xPosition方法的具体用法?C++ FillLayer::xPosition怎么用?C++ FillLayer::xPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FillLayer
的用法示例。
在下文中一共展示了FillLayer::xPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setRepeatX
void BackgroundImageGeometry::setRepeatX(const FillLayer& fillLayer,
LayoutUnit unsnappedTileWidth,
LayoutUnit snappedAvailableWidth,
LayoutUnit unsnappedAvailableWidth,
LayoutUnit extraOffset) {
// We would like to identify the phase as a fraction of the image size in the
// absence of snapping, then re-apply it to the snapped values. This is to
// handle large positions.
if (unsnappedTileWidth) {
LayoutUnit computedXPosition = roundedMinimumValueForLength(
fillLayer.xPosition(), unsnappedAvailableWidth);
if (fillLayer.backgroundXOrigin() == RightEdge) {
float numberOfTilesInPosition =
(snappedAvailableWidth - computedXPosition + extraOffset).toFloat() /
unsnappedTileWidth.toFloat();
float fractionalPositionWithinTile =
numberOfTilesInPosition - truncf(numberOfTilesInPosition);
setPhaseX(LayoutUnit(
roundf(fractionalPositionWithinTile * tileSize().width())));
} else {
float numberOfTilesInPosition =
(computedXPosition + extraOffset).toFloat() /
unsnappedTileWidth.toFloat();
float fractionalPositionWithinTile =
1.0f - (numberOfTilesInPosition - truncf(numberOfTilesInPosition));
setPhaseX(LayoutUnit(
roundf(fractionalPositionWithinTile * tileSize().width())));
}
} else {
setPhaseX(LayoutUnit());
}
setSpaceSize(LayoutSize(LayoutUnit(), spaceSize().height()));
}
示例2: calculate
//.........这里部分代码省略.........
viewportRect.moveBy(
accumulatedScrollOffsetForFixedBackground(obj, paintContainer));
}
if (paintContainer)
viewportRect.moveBy(
LayoutPoint(-paintContainer->localToAbsolute(FloatPoint())));
setDestRect(viewportRect);
positioningAreaSize = destRect().size();
}
LayoutSize fillTileSize(
calculateFillTileSize(positioningBox, fillLayer, positioningAreaSize));
// It's necessary to apply the heuristic here prior to any further
// calculations to avoid incorrectly using sub-pixel values that won't be
// present in the painted tile.
setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect));
EFillRepeat backgroundRepeatX = fillLayer.repeatX();
EFillRepeat backgroundRepeatY = fillLayer.repeatY();
LayoutUnit unsnappedAvailableWidth =
positioningAreaSize.width() - fillTileSize.width();
LayoutUnit unsnappedAvailableHeight =
positioningAreaSize.height() - fillTileSize.height();
positioningAreaSize =
LayoutSize(snapSizeToPixel(positioningAreaSize.width(), m_destRect.x()),
snapSizeToPixel(positioningAreaSize.height(), m_destRect.y()));
LayoutUnit availableWidth = positioningAreaSize.width() - tileSize().width();
LayoutUnit availableHeight =
positioningAreaSize.height() - tileSize().height();
LayoutUnit computedXPosition =
roundedMinimumValueForLength(fillLayer.xPosition(), availableWidth);
if (backgroundRepeatX == RoundFill &&
positioningAreaSize.width() > LayoutUnit() &&
fillTileSize.width() > LayoutUnit()) {
int nrTiles = std::max(
1, roundToInt(positioningAreaSize.width() / fillTileSize.width()));
LayoutUnit roundedWidth = positioningAreaSize.width() / nrTiles;
// Maintain aspect ratio if background-size: auto is set
if (fillLayer.size().size.height().isAuto() &&
backgroundRepeatY != RoundFill) {
fillTileSize.setHeight(fillTileSize.height() * roundedWidth /
fillTileSize.width());
}
fillTileSize.setWidth(roundedWidth);
setTileSize(applySubPixelHeuristicToImageSize(fillTileSize, m_destRect));
setPhaseX(tileSize().width()
? LayoutUnit(roundf(
tileSize().width() -
fmodf((computedXPosition + left), tileSize().width())))
: LayoutUnit());
setSpaceSize(LayoutSize());
}
LayoutUnit computedYPosition =
roundedMinimumValueForLength(fillLayer.yPosition(), availableHeight);
if (backgroundRepeatY == RoundFill &&
positioningAreaSize.height() > LayoutUnit() &&
fillTileSize.height() > LayoutUnit()) {
int nrTiles = std::max(
1, roundToInt(positioningAreaSize.height() / fillTileSize.height()));
LayoutUnit roundedHeight = positioningAreaSize.height() / nrTiles;