本文整理汇总了C++中QVectorPath::hasImplicitClose方法的典型用法代码示例。如果您正苦于以下问题:C++ QVectorPath::hasImplicitClose方法的具体用法?C++ QVectorPath::hasImplicitClose怎么用?C++ QVectorPath::hasImplicitClose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVectorPath
的用法示例。
在下文中一共展示了QVectorPath::hasImplicitClose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stroke
//.........这里部分代码省略.........
// ### Perspective Xforms are currently not supported...
if (!pen.isCosmetic()) {
// We include cosmetic pens in this case to avoid having to
// change the current transform. Normal transformed,
// non-cosmetic pens will be transformed as part of fill
// later, so they are also covered here..
d->activeStroker->setCurveThresholdFromTransform(state()->matrix);
d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
switch (*types) {
case QPainterPath::MoveToElement:
d->activeStroker->moveTo(points[0], points[1]);
points += 2;
++types;
break;
case QPainterPath::LineToElement:
d->activeStroker->lineTo(points[0], points[1]);
points += 2;
++types;
break;
case QPainterPath::CurveToElement:
d->activeStroker->cubicTo(points[0], points[1],
points[2], points[3],
points[4], points[5]);
points += 6;
types += 3;
flags |= QVectorPath::CurvedShapeMask;
break;
default:
break;
}
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(path.points()[0], path.points()[1]);
} else {
d->activeStroker->moveTo(points[0], points[1]);
points += 2;
while (points < lastPoint) {
d->activeStroker->lineTo(points[0], points[1]);
points += 2;
}
if (path.hasImplicitClose())
d->activeStroker->lineTo(path.points()[0], path.points()[1]);
}
d->activeStroker->end();
if (!d->strokeHandler->types.size()) // an empty path...
return;
QVectorPath strokePath(d->strokeHandler->pts.data(),
d->strokeHandler->types.size(),
d->strokeHandler->types.data(),
flags);
fill(strokePath, pen.brush());
} else {
// For cosmetic pens we need a bit of trickery... We to process xform the input points
if (state()->matrix.type() >= QTransform::TxProject) {
QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath());
d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform());
} else {
d->activeStroker->setCurveThresholdFromTransform(QTransform());
d->activeStroker->begin(d->strokeHandler);
if (types) {
while (points < lastPoint) {
示例2: factory
//.........这里部分代码省略.........
ComPtr<ID2D1GeometrySink> sink;
hr = pathGeometry->Open(sink.GetAddressOf());
if (FAILED(hr)) {
qWarning("%s: Could not create geometry sink: %#x", __FUNCTION__, hr);
return NULL;
}
sink->SetFillMode(path.hasWindingFill() ? D2D1_FILL_MODE_WINDING
: D2D1_FILL_MODE_ALTERNATE);
bool inFigure = false;
const QPainterPath::ElementType *types = path.elements();
const int count = path.elementCount();
const qreal *points = 0;
QScopedArrayPointer<qreal> rounded_points;
if (alias) {
// Aliased painting, round to whole numbers
rounded_points.reset(new qreal[count * 2]);
points = rounded_points.data();
for (int i = 0; i < (count * 2); i++)
rounded_points[i] = qRound(path.points()[i]);
} else {
// Antialiased painting, keep original numbers
points = path.points();
}
Q_ASSERT(points);
if (types) {
qreal x, y;
for (int i = 0; i < count; i++) {
x = points[i * 2];
y = points[i * 2 + 1];
switch (types[i]) {
case QPainterPath::MoveToElement:
if (inFigure)
sink->EndFigure(D2D1_FIGURE_END_OPEN);
sink->BeginFigure(D2D1::Point2F(x, y), D2D1_FIGURE_BEGIN_FILLED);
inFigure = true;
break;
case QPainterPath::LineToElement:
sink->AddLine(D2D1::Point2F(x, y));
break;
case QPainterPath::CurveToElement:
{
Q_ASSERT((i + 2) < count);
Q_ASSERT(types[i+1] == QPainterPath::CurveToDataElement);
Q_ASSERT(types[i+2] == QPainterPath::CurveToDataElement);
i++;
const qreal x2 = points[i * 2];
const qreal y2 = points[i * 2 + 1];
i++;
const qreal x3 = points[i * 2];
const qreal y3 = points[i * 2 + 1];
D2D1_BEZIER_SEGMENT segment = {
D2D1::Point2F(x, y),
D2D1::Point2F(x2, y2),
D2D1::Point2F(x3, y3)
};
sink->AddBezier(segment);
}
break;
case QPainterPath::CurveToDataElement:
qWarning("%s: Unhandled Curve Data Element", __FUNCTION__);
break;
}
}
} else {
sink->BeginFigure(D2D1::Point2F(points[0], points[1]), D2D1_FIGURE_BEGIN_FILLED);
inFigure = true;
for (int i = 1; i < count; i++)
sink->AddLine(D2D1::Point2F(points[i * 2], points[i * 2 + 1]));
}
if (inFigure) {
if (path.hasImplicitClose())
sink->AddLine(D2D1::Point2F(points[0], points[1]));
sink->EndFigure(D2D1_FIGURE_END_OPEN);
}
sink->Close();
return pathGeometry;
}