本文整理汇总了C++中QVectorPath::hasWindingFill方法的典型用法代码示例。如果您正苦于以下问题:C++ QVectorPath::hasWindingFill方法的具体用法?C++ QVectorPath::hasWindingFill怎么用?C++ QVectorPath::hasWindingFill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVectorPath
的用法示例。
在下文中一共展示了QVectorPath::hasWindingFill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: factory
static ComPtr<ID2D1PathGeometry1> vectorPathToID2D1PathGeometry(const QVectorPath &path, bool alias)
{
ComPtr<ID2D1PathGeometry1> pathGeometry;
HRESULT hr = factory()->CreatePathGeometry(pathGeometry.GetAddressOf());
if (FAILED(hr)) {
qWarning("%s: Could not create path geometry: %#x", __FUNCTION__, hr);
return NULL;
}
if (path.isEmpty())
return pathGeometry;
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]));
}
//.........这里部分代码省略.........