Пример #1
0
QGradientStops QQuickGradient::gradientStops() const
{
    QGradientStops stops;
    for (int i = 0; i < m_stops.size(); ++i){
        int j = 0;
        while (j < stops.size() && stops.at(j).first < m_stops[i]->position())
            j++;
        stops.insert(j, QGradientStop(m_stops.at(i)->position(), m_stops.at(i)->color()));
    }
    return stops;
}
Пример #2
0
QGradientStops QQuickPathGradient::sortedGradientStops() const
{
    QGradientStops result;
    for (int i = 0; i < m_stops.count(); ++i) {
        QQuickPathGradientStop *s = static_cast<QQuickPathGradientStop *>(m_stops[i]);
        int j = 0;
        while (j < result.count() && result[j].first < s->position())
            ++j;
        result.insert(j, QGradientStop(s->position(), s->color()));
    }
    return result;
}
Пример #3
0
QSGNode *QQuickRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
{
    Q_UNUSED(data);
    Q_D(QQuickRectangle);

    if (width() <= 0 || height() <= 0
            || (d->color.alpha() == 0 && (!d->pen || d->pen->width() == 0 || d->pen->color().alpha() == 0))) {
        delete oldNode;
        return 0;
    }

    QSGRectangleNode *rectangle = static_cast<QSGRectangleNode *>(oldNode);
    if (!rectangle) rectangle = d->sceneGraphContext()->createRectangleNode();

    rectangle->setRect(QRectF(0, 0, width(), height()));
    rectangle->setColor(d->color);

    if (d->pen && d->pen->isValid()) {
        rectangle->setPenColor(d->pen->color());
        rectangle->setPenWidth(d->pen->width());
        rectangle->setAligned(d->pen->pixelAligned());
    } else {
        rectangle->setPenWidth(0);
    }

    rectangle->setRadius(d->radius);
    rectangle->setAntialiasing(d->antialiasing);

    QGradientStops stops;
    if (d->gradient) {
        QList<QQuickGradientStop *> qxstops = d->gradient->m_stops;
        for (int i = 0; i < qxstops.size(); ++i){
            int j = 0;
            while (j < stops.size() && stops.at(j).first < qxstops[i]->position())
                j++;
            stops.insert(j, QGradientStop(qxstops.at(i)->position(), qxstops.at(i)->color()));
        }
    }
    rectangle->setGradientStops(stops);

    rectangle->update();

    return rectangle;
}