本文整理汇总了C++中LinearGradientAttributes::x2方法的典型用法代码示例。如果您正苦于以下问题:C++ LinearGradientAttributes::x2方法的具体用法?C++ LinearGradientAttributes::x2怎么用?C++ LinearGradientAttributes::x2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearGradientAttributes
的用法示例。
在下文中一共展示了LinearGradientAttributes::x2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateStartEndPoints
void SVGLinearGradientElement::calculateStartEndPoints(const LinearGradientAttributes& attributes, FloatPoint& startPoint, FloatPoint& endPoint)
{
// Determine gradient start/end points
if (attributes.boundingBoxMode()) {
startPoint = FloatPoint(attributes.x1().valueAsPercentage(), attributes.y1().valueAsPercentage());
endPoint = FloatPoint(attributes.x2().valueAsPercentage(), attributes.y2().valueAsPercentage());
} else {
startPoint = FloatPoint(attributes.x1().value(this), attributes.y1().value(this));
endPoint = FloatPoint(attributes.x2().value(this), attributes.y2().value(this));
}
}
示例2: buildGradient
void SVGLinearGradientElement::buildGradient() const
{
LinearGradientAttributes attributes = collectGradientProperties();
RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource);
FloatPoint startPoint;
FloatPoint endPoint;
if (attributes.boundingBoxMode()) {
startPoint = FloatPoint(attributes.x1().valueAsPercentage(), attributes.y1().valueAsPercentage());
endPoint = FloatPoint(attributes.x2().valueAsPercentage(), attributes.y2().valueAsPercentage());
} else {
startPoint = FloatPoint(attributes.x1().value(this), attributes.y1().value(this));
endPoint = FloatPoint(attributes.x2().value(this), attributes.y2().value(this));
}
RefPtr<Gradient> gradient = Gradient::create(startPoint, endPoint);
gradient->setSpreadMethod(attributes.spreadMethod());
Vector<SVGGradientStop> m_stops = attributes.stops();
float previousOffset = 0.0f;
for (unsigned i = 0; i < m_stops.size(); ++i) {
float offset = std::min(std::max(previousOffset, m_stops[i].first), 1.0f);
previousOffset = offset;
gradient->addColorStop(offset, m_stops[i].second);
}
linearGradient->setGradient(gradient);
if (attributes.stops().isEmpty())
return;
// This code should go away. PaintServers should go away too.
// Only this code should care about bounding boxes
linearGradient->setBoundingBoxMode(attributes.boundingBoxMode());
linearGradient->setGradientStops(attributes.stops());
// These should possibly be supported on Gradient
linearGradient->setGradientTransform(attributes.gradientTransform());
linearGradient->setGradientStart(startPoint);
linearGradient->setGradientEnd(endPoint);
}
示例3: buildGradient
void SVGLinearGradientElement::buildGradient() const
{
LinearGradientAttributes attributes = collectGradientProperties();
// If we didn't find any gradient containing stop elements, ignore the request.
if (attributes.stops().isEmpty())
return;
RefPtr<SVGPaintServerLinearGradient> linearGradient = WTF::static_pointer_cast<SVGPaintServerLinearGradient>(m_resource);
linearGradient->setGradientStops(attributes.stops());
linearGradient->setBoundingBoxMode(attributes.boundingBoxMode());
linearGradient->setGradientSpreadMethod(attributes.spreadMethod());
linearGradient->setGradientTransform(attributes.gradientTransform());
linearGradient->setGradientStart(FloatPoint::narrowPrecision(attributes.x1(), attributes.y1()));
linearGradient->setGradientEnd(FloatPoint::narrowPrecision(attributes.x2(), attributes.y2()));
}