本文整理汇总了C++中FloatRect::extend方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatRect::extend方法的具体用法?C++ FloatRect::extend怎么用?C++ FloatRect::extend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatRect
的用法示例。
在下文中一共展示了FloatRect::extend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bounds
PassOwnPtr<ExclusionShape> ExclusionShape::createExclusionShape(const BasicShape* basicShape, float logicalBoxWidth, float logicalBoxHeight, WritingMode writingMode)
{
ASSERT(basicShape);
bool horizontalWritingMode = isHorizontalWritingMode(writingMode);
float boxWidth = horizontalWritingMode ? logicalBoxWidth : logicalBoxHeight;
float boxHeight = horizontalWritingMode ? logicalBoxHeight : logicalBoxWidth;
OwnPtr<ExclusionShape> exclusionShape;
switch (basicShape->type()) {
case BasicShape::BASIC_SHAPE_RECTANGLE: {
const BasicShapeRectangle* rectangle = static_cast<const BasicShapeRectangle*>(basicShape);
FloatRect bounds(
floatValueForLength(rectangle->x(), boxWidth),
floatValueForLength(rectangle->y(), boxHeight),
floatValueForLength(rectangle->width(), boxWidth),
floatValueForLength(rectangle->height(), boxHeight));
Length radiusXLength = rectangle->cornerRadiusX();
Length radiusYLength = rectangle->cornerRadiusY();
FloatSize cornerRadii(
radiusXLength.isUndefined() ? 0 : floatValueForLength(radiusXLength, boxWidth),
radiusYLength.isUndefined() ? 0 : floatValueForLength(radiusYLength, boxHeight));
FloatRect logicalBounds = physicalRectToLogical(bounds, logicalBoxHeight, writingMode);
exclusionShape = createExclusionRectangle(logicalBounds, physicalSizeToLogical(cornerRadii, writingMode));
exclusionShape->m_boundingBox = logicalBounds;
break;
}
case BasicShape::BASIC_SHAPE_CIRCLE: {
const BasicShapeCircle* circle = static_cast<const BasicShapeCircle*>(basicShape);
float centerX = floatValueForLength(circle->centerX(), boxWidth);
float centerY = floatValueForLength(circle->centerY(), boxHeight);
float radius = floatValueForLength(circle->radius(), std::max(boxHeight, boxWidth));
FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, centerY), logicalBoxHeight, writingMode);
exclusionShape = createExclusionCircle(logicalCenter, radius);
exclusionShape->m_boundingBox = FloatRect(logicalCenter.x() - radius, logicalCenter.y() - radius, radius * 2, radius * 2);
break;
}
case BasicShape::BASIC_SHAPE_ELLIPSE: {
const BasicShapeEllipse* ellipse = static_cast<const BasicShapeEllipse*>(basicShape);
float centerX = floatValueForLength(ellipse->centerX(), boxWidth);
float centerY = floatValueForLength(ellipse->centerY(), boxHeight);
float radiusX = floatValueForLength(ellipse->radiusX(), boxWidth);
float radiusY = floatValueForLength(ellipse->radiusY(), boxHeight);
FloatPoint logicalCenter = physicalPointToLogical(FloatPoint(centerX, centerY), logicalBoxHeight, writingMode);
FloatSize logicalRadii = physicalSizeToLogical(FloatSize(radiusX, radiusY), writingMode);
exclusionShape = createExclusionEllipse(logicalCenter, logicalRadii);
exclusionShape->m_boundingBox = FloatRect(logicalCenter - logicalRadii, logicalRadii + logicalRadii);
break;
}
case BasicShape::BASIC_SHAPE_POLYGON: {
const BasicShapePolygon* polygon = static_cast<const BasicShapePolygon*>(basicShape);
const Vector<Length>& values = polygon->values();
size_t valuesSize = values.size();
ASSERT(!(valuesSize % 2));
FloatRect boundingBox;
Vector<FloatPoint>* vertices = new Vector<FloatPoint>(valuesSize / 2);
for (unsigned i = 0; i < valuesSize; i += 2) {
FloatPoint vertex(
floatValueForLength(values.at(i), boxWidth),
floatValueForLength(values.at(i + 1), boxHeight));
(*vertices)[i / 2] = physicalPointToLogical(vertex, logicalBoxHeight, writingMode);
if (!i)
boundingBox.setLocation(vertex);
else
boundingBox.extend(vertex);
}
exclusionShape = createExclusionPolygon(adoptPtr(vertices), polygon->windRule());
exclusionShape->m_boundingBox = boundingBox;
break;
}
default:
ASSERT_NOT_REACHED();
}
exclusionShape->m_logicalBoxWidth = logicalBoxWidth;
exclusionShape->m_logicalBoxHeight = logicalBoxHeight;
exclusionShape->m_writingMode = writingMode;
return exclusionShape.release();
}