当前位置: 首页>>代码示例>>C++>>正文


C++ FillLayer::xPosition方法代码示例

本文整理汇总了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()));
}
开发者ID:mirror,项目名称:chromium,代码行数:33,代码来源:BackgroundImageGeometry.cpp

示例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;
开发者ID:mirror,项目名称:chromium,代码行数:67,代码来源:BackgroundImageGeometry.cpp


注:本文中的FillLayer::xPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。