本文整理汇总了C++中FloatRect::contract方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatRect::contract方法的具体用法?C++ FloatRect::contract怎么用?C++ FloatRect::contract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatRect
的用法示例。
在下文中一共展示了FloatRect::contract方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void TileCoverageMap::update()
{
FloatRect containerBounds = m_controller.bounds();
FloatRect visibleRect = m_controller.visibleRect();
FloatRect coverageRect = m_controller.coverageRect();
visibleRect.contract(4, 4); // Layer is positioned 2px from top and left edges.
float widthScale = 1;
float scale = 1;
if (!containerBounds.isEmpty()) {
widthScale = std::min<float>(visibleRect.width() / containerBounds.width(), 0.1);
float visibleHeight = visibleRect.height() - std::min(m_controller.topContentInset(), visibleRect.y());
scale = std::min(widthScale, visibleHeight / containerBounds.height());
}
float indicatorScale = scale * m_controller.tileGrid().scale();
FloatRect mapBounds = containerBounds;
mapBounds.scale(indicatorScale, indicatorScale);
m_layer.get().setPosition(m_position + FloatPoint(2, 2));
m_layer.get().setBounds(mapBounds);
m_layer.get().setNeedsDisplay();
visibleRect.scale(indicatorScale, indicatorScale);
visibleRect.expand(2, 2);
m_visibleRectIndicatorLayer->setPosition(visibleRect.location());
m_visibleRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), visibleRect.size()));
coverageRect.scale(indicatorScale, indicatorScale);
coverageRect.expand(2, 2);
m_coverageRectIndicatorLayer->setPosition(coverageRect.location());
m_coverageRectIndicatorLayer->setBounds(FloatRect(FloatPoint(), coverageRect.size()));
Color visibleRectIndicatorColor;
switch (m_controller.indicatorMode()) {
case SynchronousScrollingBecauseOfStyleIndication:
visibleRectIndicatorColor = Color(255, 0, 0);
break;
case SynchronousScrollingBecauseOfEventHandlersIndication:
visibleRectIndicatorColor = Color(255, 255, 0);
break;
case AsyncScrollingIndication:
visibleRectIndicatorColor = Color(0, 200, 0);
break;
}
m_visibleRectIndicatorLayer.get().setBorderColor(visibleRectIndicatorColor);
}
示例2: ASSERT
Vector<FloatRect> NinePieceImage::computeIntrinsicRects(const FloatRect& outer, const LayoutBoxExtent& slices, float deviceScaleFactor)
{
FloatRect inner = outer;
inner.move(slices.left(), slices.top());
inner.contract(slices.left() + slices.right(), slices.top() + slices.bottom());
ASSERT(outer.contains(inner));
Vector<FloatRect> rects(MaxPiece);
rects[TopLeftPiece] = snapRectToDevicePixels(outer.x(), outer.y(), slices.left(), slices.top(), deviceScaleFactor);
rects[BottomLeftPiece] = snapRectToDevicePixels(outer.x(), inner.maxY(), slices.left(), slices.bottom(), deviceScaleFactor);
rects[LeftPiece] = snapRectToDevicePixels(outer.x(), inner.y(), slices.left(), inner.height(), deviceScaleFactor);
rects[TopRightPiece] = snapRectToDevicePixels(inner.maxX(), outer.y(), slices.right(), slices.top(), deviceScaleFactor);
rects[BottomRightPiece] = snapRectToDevicePixels(inner.maxX(), inner.maxY(), slices.right(), slices.bottom(), deviceScaleFactor);
rects[RightPiece] = snapRectToDevicePixels(inner.maxX(), inner.y(), slices.right(), inner.height(), deviceScaleFactor);
rects[TopPiece] = snapRectToDevicePixels(inner.x(), outer.y(), inner.width(), slices.top(), deviceScaleFactor);
rects[BottomPiece] = snapRectToDevicePixels(inner.x(), inner.maxY(), inner.width(), slices.bottom(), deviceScaleFactor);
rects[MiddlePiece] = snapRectToDevicePixels(inner.x(), inner.y(), inner.width(), inner.height(), deviceScaleFactor);
return rects;
}