本文整理汇总了C++中SVGNumberList::numberOfItems方法的典型用法代码示例。如果您正苦于以下问题:C++ SVGNumberList::numberOfItems方法的具体用法?C++ SVGNumberList::numberOfItems怎么用?C++ SVGNumberList::numberOfItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SVGNumberList
的用法示例。
在下文中一共展示了SVGNumberList::numberOfItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kernelMatrix
PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder)
{
FilterEffect* input1 = filterBuilder->getEffectById(in1());
if (!input1)
return 0;
Vector<float> kernelMatrixValues;
SVGNumberList* numbers = kernelMatrix();
ExceptionCode ec = 0;
int numberOfItems = numbers->numberOfItems();
for (int i = 0; i < numberOfItems; ++i)
kernelMatrixValues.append(numbers->getItem(i, ec));
int orderXValue = orderX();
int orderYValue = orderY();
if (!hasAttribute(SVGNames::orderAttr)) {
orderXValue = 3;
orderYValue = 3;
}
// The spec says this is a requirement, and should bail out if fails
if (orderXValue * orderYValue != numberOfItems)
return 0;
int targetXValue = targetX();
int targetYValue = targetY();
if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue >= orderXValue))
return 0;
// The spec says the default value is: targetX = floor ( orderX / 2 ))
if (!hasAttribute(SVGNames::targetXAttr))
targetXValue = static_cast<int>(floorf(orderXValue / 2));
if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue >= orderYValue))
return 0;
// The spec says the default value is: targetY = floor ( orderY / 2 ))
if (!hasAttribute(SVGNames::targetYAttr))
targetYValue = static_cast<int>(floorf(orderYValue / 2));
float divisorValue = divisor();
if (hasAttribute(SVGNames::divisorAttr) && !divisorValue)
return 0;
if (!hasAttribute(SVGNames::divisorAttr)) {
for (int i = 0; i < numberOfItems; ++i)
divisorValue += kernelMatrixValues[i];
if (!divisorValue)
divisorValue = 1;
}
RefPtr<FilterEffect> effect = FEConvolveMatrix::create(
IntSize(orderXValue, orderYValue), divisorValue,
bias(), IntPoint(targetXValue, targetYValue), static_cast<EdgeModeType>(edgeMode()),
FloatPoint(kernelUnitLengthX(), kernelUnitLengthX()), preserveAlpha(), kernelMatrixValues);
effect->inputEffects().append(input1);
return effect.release();
}
示例2: build
bool SVGFEColorMatrixElement::build(SVGResourceFilter* filterResource)
{
FilterEffect* input1 = filterResource->builder()->getEffectById(in1());
if (!input1)
return false;
Vector<float> filterValues;
SVGNumberList* numbers = values();
const ColorMatrixType filterType(static_cast<const ColorMatrixType>(type()));
// Use defaults if values is empty (SVG 1.1 15.10).
if (!hasAttribute(SVGNames::valuesAttr)) {
switch (filterType) {
case FECOLORMATRIX_TYPE_MATRIX:
for (size_t i = 0; i < 20; i++)
filterValues.append((i % 6) ? 0.0f : 1.0f);
break;
case FECOLORMATRIX_TYPE_HUEROTATE:
filterValues.append(0.0f);
break;
case FECOLORMATRIX_TYPE_SATURATE:
filterValues.append(1.0f);
break;
default:
break;
}
} else {
size_t size = numbers->numberOfItems();
for (size_t i = 0; i < size; i++) {
ExceptionCode ec = 0;
filterValues.append(numbers->getItem(i, ec));
}
size = filterValues.size();
if ((filterType == FECOLORMATRIX_TYPE_MATRIX && size != 20)
|| (filterType == FECOLORMATRIX_TYPE_HUEROTATE && size != 1)
|| (filterType == FECOLORMATRIX_TYPE_SATURATE && (size != 1
|| filterValues[0] < 0.0f || filterValues[0] > 1.0f)))
return false;
}
RefPtr<FilterEffect> effect = FEColorMatrix::create(input1, filterType, filterValues);
filterResource->addFilterEffect(this, effect.release());
return true;
}
示例3: transferFunction
ComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const
{
ComponentTransferFunction func;
func.type = (ComponentTransferType) type();
func.slope = slope();
func.intercept = intercept();
func.amplitude = amplitude();
func.exponent = exponent();
func.offset = offset();
SVGNumberList* numbers = tableValues();
ExceptionCode ec = 0;
unsigned int nr = numbers->numberOfItems();
for (unsigned int i = 0; i < nr; i++)
func.tableValues.append(numbers->getItem(i, ec));
return func;
}
示例4: build
bool SVGFEColorMatrixElement::build(FilterBuilder* builder)
{
FilterEffect* input1 = builder->getEffectById(in1());
if(!input1)
return false;
Vector<float> _values;
SVGNumberList* numbers = values();
ExceptionCode ec = 0;
unsigned int nr = numbers->numberOfItems();
for (unsigned int i = 0;i < nr;i++)
_values.append(numbers->getItem(i, ec));
builder->add(result(), FEColorMatrix::create(input1, static_cast<ColorMatrixType> (type()), _values));
return true;
}