本文整理汇总了C++中Gradient::addColorStop方法的典型用法代码示例。如果您正苦于以下问题:C++ Gradient::addColorStop方法的具体用法?C++ Gradient::addColorStop怎么用?C++ Gradient::addColorStop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gradient
的用法示例。
在下文中一共展示了Gradient::addColorStop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createGradient
Gradient* CSSGradientValue::createGradient(RenderObject* renderer, const IntSize& size)
{
ASSERT(!size.isEmpty());
float zoomFactor = renderer->style()->effectiveZoom();
FloatPoint firstPoint = resolvePoint(m_firstX.get(), m_firstY.get(), size, zoomFactor);
FloatPoint secondPoint = resolvePoint(m_secondX.get(), m_secondY.get(), size, zoomFactor);
Gradient* gradient = 0;
if (m_type == CSSLinearGradient)
gradient = new Gradient(firstPoint, secondPoint);
else {
float firstRadius = resolveRadius(m_firstRadius.get(), zoomFactor);
float secondRadius = resolveRadius(m_secondRadius.get(), zoomFactor);
gradient = new Gradient(firstPoint, firstRadius, secondPoint, secondRadius);
}
// Now add the stops.
sortStopsIfNeeded();
// We have to resolve colors.
for (unsigned i = 0; i < m_stops.size(); i++) {
Color color = renderer->document()->styleSelector()->getColorFromPrimitiveValue(m_stops[i].m_color.get());
gradient->addColorStop(m_stops[i].m_stop, color);
}
// The back end already sorted the stops.
gradient->setStopsSorted(true);
return gradient;
}