本文整理汇总了C++中KoPathShape::setFillRule方法的典型用法代码示例。如果您正苦于以下问题:C++ KoPathShape::setFillRule方法的具体用法?C++ KoPathShape::setFillRule怎么用?C++ KoPathShape::setFillRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoPathShape
的用法示例。
在下文中一共展示了KoPathShape::setFillRule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyFillStyle
//.........这里部分代码省略.........
} else if (gc->fillType == SvgGraphicsContext::Complex) {
// try to find referenced gradient
SvgGradientHelper *gradient = findGradient(gc->fillId);
if (gradient) {
// great, we have a gradient fill
QSharedPointer<KoGradientBackground> bg;
if (gradient->gradientUnits() == SvgGradientHelper::ObjectBoundingBox) {
bg = QSharedPointer<KoGradientBackground>(new KoGradientBackground(*gradient->gradient()));
bg->setTransform(gradient->transform());
} else {
QGradient *convertedGradient = SvgGradientHelper::convertGradient(gradient->gradient(), shape->size());
bg = QSharedPointer<KoGradientBackground>(new KoGradientBackground(convertedGradient));
QTransform invShapematrix = shape->transformation().inverted();
bg->setTransform(gradient->transform() * gc->matrix * invShapematrix);
}
shape->setBackground(bg);
} else {
// try to find referenced pattern
SvgPatternHelper *pattern = findPattern(gc->fillId);
KoImageCollection *imageCollection = m_documentResourceManager->imageCollection();
if (pattern && imageCollection) {
// great we have a pattern fill
QRectF objectBound = QRectF(QPoint(), shape->size());
QRectF currentBoundbox = gc->currentBoundbox;
// properties from the object are not inherited
// so we are creating a new context without copying
SvgGraphicsContext *gc = m_context.pushGraphicsContext(pattern->content(), false);
// the pattern establishes a new coordinate system with its
// origin at the patterns x and y attributes
gc->matrix = QTransform();
// object bounding box units are relative to the object the pattern is applied
if (pattern->patternContentUnits() == SvgPatternHelper::ObjectBoundingBox) {
gc->currentBoundbox = objectBound;
gc->forcePercentage = true;
} else {
// inherit the current bounding box
gc->currentBoundbox = currentBoundbox;
}
applyStyle(0, pattern->content());
// parse the pattern content elements
QList<KoShape*> patternContent = parseContainer(pattern->content());
// generate the pattern image from the shapes and the object bounding rect
QImage image = pattern->generateImage(objectBound, patternContent);
m_context.popGraphicsContext();
// delete the shapes created from the pattern content
qDeleteAll(patternContent);
if (!image.isNull()) {
QSharedPointer<KoPatternBackground> bg(new KoPatternBackground(imageCollection));
bg->setPattern(image);
QPointF refPoint = shape->documentToShape(pattern->position(objectBound));
QSizeF tileSize = pattern->size(objectBound);
bg->setPatternDisplaySize(tileSize);
if (pattern->patternUnits() == SvgPatternHelper::ObjectBoundingBox) {
if (tileSize == objectBound.size())
bg->setRepeat(KoPatternBackground::Stretched);
}
// calculate pattern reference point offset in percent of tileSize
// and relative to the topleft corner of the shape
qreal fx = refPoint.x() / tileSize.width();
qreal fy = refPoint.y() / tileSize.height();
if (fx < 0.0)
fx = floor(fx);
else if (fx > 1.0)
fx = ceil(fx);
else
fx = 0.0;
if (fy < 0.0)
fy = floor(fy);
else if (fx > 1.0)
fy = ceil(fy);
else
fy = 0.0;
qreal offsetX = 100.0 * (refPoint.x() - fx * tileSize.width()) / tileSize.width();
qreal offsetY = 100.0 * (refPoint.y() - fy * tileSize.height()) / tileSize.height();
bg->setReferencePointOffset(QPointF(offsetX, offsetY));
shape->setBackground(bg);
}
} else {
// no referenced fill found, use fallback color
shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(gc->fillColor)));
}
}
}
KoPathShape *path = dynamic_cast<KoPathShape*>(shape);
if (path)
path->setFillRule(gc->fillRule);
}