⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qbrush.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    \sa spread()*//*!    \fn QGradient::Spread QGradient::spread() const    Returns the spread method use by this gradient. The default is    PadSpread.    \sa setSpread()*//*!    \fn QGradient::Type QGradient::type() const    Returns the type of gradient.*//*!    \fn void QGradient::setColorAt(qreal position, const QColor &color)    Creates a stop point at the given \a position with the given \a    color. The given \a position must be in the range 0 to 1.    \sa setStops(), stops()*/void QGradient::setColorAt(qreal pos, const QColor &color){    if (pos > 1 || pos < 0) {        qWarning("QGradient::setColorAt(), colors positions must be specified in the range 0 to 1");        return;    }    int index = 0;    while (index < m_stops.size() && m_stops.at(index).first < pos) ++index;    m_stops.insert(index, QGradientStop(pos, color));}/*!    \fn void QGradient::setStops(const QGradientStops &stopPoints)    Replaces the current set of stop points with the given \a    stopPoints. The positions of the points must be in the range 0 to    1, and must be sorted with the lowest point first.    \sa setColorAt(), stops()*/void QGradient::setStops(const QGradientStops &stops){    m_stops.clear();    for (int i=0; i<stops.size(); ++i)        setColorAt(stops.at(i).first, stops.at(i).second);}/*!    Returns the stop points for this gradient.    If no stop points have been specified, a gradient of black at 0 to white    at 1 is used.    \sa setStops(), setColorAt()*/QGradientStops QGradient::stops() const{    if (m_stops.isEmpty()) {        QGradientStops tmp;        tmp << QGradientStop(0, Qt::black) << QGradientStop(1, Qt::white);        return tmp;    }    return m_stops;}/*!    \internal*/bool QGradient::operator==(const QGradient &gradient) const{    if (gradient.m_type != m_type || gradient.m_spread != m_spread) return false;    if (m_type == LinearGradient) {        if (m_data.linear.x1 != gradient.m_data.linear.x1            || m_data.linear.y1 != gradient.m_data.linear.y1            || m_data.linear.x2 != gradient.m_data.linear.x2            || m_data.linear.y2 != gradient.m_data.linear.y2)            return false;    } else if (m_type == RadialGradient) {        if (m_data.radial.cx != gradient.m_data.radial.cx            || m_data.radial.cy != gradient.m_data.radial.cy            || m_data.radial.fx != gradient.m_data.radial.fx            || m_data.radial.fy != gradient.m_data.radial.fy            || m_data.radial.radius != gradient.m_data.radial.radius)            return false;    } else { // m_type == ConicalGradient        if (m_data.conical.cx != gradient.m_data.conical.cx            || m_data.conical.cy != gradient.m_data.conical.cy            || m_data.conical.angle != gradient.m_data.conical.angle)            return false;    }    return stops() == gradient.stops();}/*!    Returns true if the gradient is the same as the other \a gradient    specified; otherwise returns false.*/bool QGradient::operator==(const QGradient &gradient){    return const_cast<const QGradient *>(this)->operator==(gradient);}/*!    \class QLinearGradient    \ingroup multimedia    \brief The QLinearGradient class is used in combination with QBrush to    specify a linear gradient brush.    Linear gradients interpolate colors between start and end    points. Outside these points the gradient is either padded,    reflected or repeated depending on the currently set \l    {QGradient::Spread}{spread} method:    \table    \row    \o \inlineimage qlineargradient-pad.png    \o \inlineimage qlineargradient-reflect.png    \o \inlineimage qlineargradient-repeat.png    \row    \o \l {QGradient::PadSpread}{PadSpread} (default)    \o \l {QGradient::ReflectSpread}{ReflectSpread}    \o \l {QGradient::RepeatSpread}{RepeatSpread}    \endtable    The colors in a gradient is defined using stop points of the    QGradientStop type, i.e. a position and a color. Use the    QGradient::setColorAt() or the QGradient::setStops() function to    define the stop points. It is the gradient's complete set of stop    points that describes how the gradient area should be filled. If    no stop points have been specified, a gradient of black at 0 to    white at 1 is used.    In addition to the functions inherited from QGradient, the    QLinearGradient class provides the finalStop() function which    returns the final stop point of the gradient, and the start()    function returning the start point of the gradient.    \sa QRadialGradient, QConicalGradient, {demos/gradients}{The    Gradients Demo}*//*!    Constructs a linear gradient with interpolation area between the    given \a start point and \a finalStop.    \sa QGradient::setColorAt(), QGradient::setStops()*/QLinearGradient::QLinearGradient(const QPointF &start, const QPointF &finalStop){    m_type = LinearGradient;    m_spread = PadSpread;    m_data.linear.x1 = start.x();    m_data.linear.y1 = start.y();    m_data.linear.x2 = finalStop.x();    m_data.linear.y2 = finalStop.y();}/*!    \fn QLinearGradient::QLinearGradient(qreal x1, qreal y1, qreal x2, qreal y2)    Constructs a linear gradient with interpolation area between (\a    x1, \a y1) and (\a x2, \a y2).    \sa QGradient::setColorAt(), QGradient::setStops()*/QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop){    m_type = LinearGradient;    m_spread = PadSpread;    m_data.linear.x1 = xStart;    m_data.linear.y1 = yStart;    m_data.linear.x2 = xFinalStop;    m_data.linear.y2 = yFinalStop;}/*!    Returns the start point of this linear gradient in logical coordinates.    \sa QGradient::stops()*/QPointF QLinearGradient::start() const{    Q_ASSERT(m_type == LinearGradient);    return QPointF(m_data.linear.x1, m_data.linear.y1);}/*!    Returns the final stop point of this linear gradient in logical coordinates.    \sa QGradient::stops()*/QPointF QLinearGradient::finalStop() const{    Q_ASSERT(m_type == LinearGradient);    return QPointF(m_data.linear.x2, m_data.linear.y2);}/*!    \class QRadialGradient    \ingroup multimedia    \brief The QRadialGradient class is used in combination with QBrush to    specify a radial gradient brush.    Radial gradients interpolate colors between a focal point and end    points on a circle surrounding it. Outside the end points the    gradient is either padded, reflected or repeated depending on the    currently set \l {QGradient::Spread}{spread} method:    \table    \row    \o \inlineimage qradialgradient-pad.png    \o \inlineimage qradialgradient-reflect.png    \o \inlineimage qradialgradient-repeat.png    \row    \o \l {QGradient::PadSpread}{PadSpread} (default)    \o \l {QGradient::ReflectSpread}{ReflectSpread}    \o \l {QGradient::RepeatSpread}{RepeatSpread}    \endtable    The colors in a gradient is defined using stop points of the    QGradientStop type, i.e. a position and a color. Use the    QGradient::setColorAt() or the QGradient::setStops() function to    define the stop points. It is the gradient's complete set of stop    points that describes how the gradient area should be filled.  If    no stop points have been specified, a gradient of black at 0 to    white at 1 is used.    In addition to the functions inherited from QGradient, the    QRadialGradient class provides the center(), focalPoint() and    radius() functions returning the gradient's center, focal point    and radius respectively.    \sa QLinearGradient, QConicalGradient, {demos/gradients}{The    Gradients Demo}*/static QPointF qt_radial_gradient_adapt_focal_point(const QPointF &center,                                                    qreal radius,                                                    const QPointF &focalPoint){    // We have a one pixel buffer zone to avoid numerical instability on the    // circle border    const qreal compensated_radius = radius - 1;    QLineF line(center, focalPoint);    if (line.length() >= (compensated_radius))        line.setLength(compensated_radius);    return line.p2();}/*!    Constructs a radial gradient with the given \a center, \a    radius and \a focalPoint.    The default focalPoint is the circle center. If the \a focalPoint    is outside the circle defined by the given \a center and \a    radius, it is clamped to the circle's boundary.    \sa QGradient::setColorAt(), QGradient::setStops()*/QRadialGradient::QRadialGradient(const QPointF &center, qreal radius, const QPointF &focalPoint){    m_type = RadialGradient;    m_spread = PadSpread;    m_data.radial.cx = center.x();    m_data.radial.cy = center.y();    m_data.radial.radius = radius;    QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(center, radius, focalPoint);    m_data.radial.fx = adapted_focal.x();    m_data.radial.fy = adapted_focal.y();}/*!    Constructs a radial gradient with the given center (\a cx, \a cy),    \a radius and focal point (\a fx, \a fy).    The default focal point is the circle center. If the focal point    is outside the circle defined by the given center and \a radius,    it is clamped to the circle's boundary.    \sa QGradient::setColorAt(), QGradient::setStops()*/QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy){    m_type = RadialGradient;    m_spread = PadSpread;    m_data.radial.cx = cx;    m_data.radial.cy = cy;    m_data.radial.radius = radius;    QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy),                                                                 radius,                                                                 QPointF(fx, fy));    m_data.radial.fx = adapted_focal.x();    m_data.radial.fy = adapted_focal.y();}/*!    Returns the center of this radial gradient in logical coordinates.    \sa QGradient::stops()*/QPointF QRadialGradient::center() const{    Q_ASSERT(m_type == RadialGradient);    return QPointF(m_data.radial.cx, m_data.radial.cy);}/*!    Returns the radius of the radial gradient in logical coordinates.    \sa QGradient::stops()*/qreal QRadialGradient::radius() const{    Q_ASSERT(m_type == RadialGradient);    return m_data.radial.radius;}/*!    Returns the focal point of this radial gradient in logical    coordinates.    \sa QGradient::stops()*/QPointF QRadialGradient::focalPoint() const{    Q_ASSERT(m_type == RadialGradient);    return QPointF(m_data.radial.fx, m_data.radial.fy);}/*!    \class QConicalGradient    \ingroup multimedia    \brief The QConicalGradient class is used in combination with QBrush to    specify a conical gradient brush.    Conical gradients interpolate interpolate colors counter-clockwise    around a center point.    \image qconicalgradient    The colors in a gradient is defined using stop points of the    QGradientStop type, i.e. a position and a color. Use the    QGradient::setColorAt() or the QGradient::setStops() function to    define the stop points. It is the gradient's complete set of stop    points that describes how the gradient area should be filled. If    no stop points have been specified, a gradient of black at 0 to    white at 1 is used.    In addition to the functions inherited from QGradient, the    QConicalGradient class provides the angle() and center() functions    returning the start angle and center of the gradient.    Note that the setSpread() function has no effect for conical    gradients. The reason is that the conical gradient is closed by    definition, i.e. the conical gradient fills the entire circle from    0 - 360 degrees, while the boundary of a radial or a linear    gradient can be specified through its radius or final stop points,    respectively.    \sa QLinearGradient, QRadialGradient, {demos/gradients}{The    Gradients Demo}*//*!    Constructs a conical with the given \a center, starting the    interpolation at the given \a angle. The \a angle must be specified in    degrees between 0 and 360.    \sa setColorAt(), setStops()*/QConicalGradient::QConicalGradient(const QPointF &center, qreal angle){    m_type = ConicalGradient;    m_spread = PadSpread;    m_data.conical.cx = center.x();    m_data.conical.cy = center.y();    m_data.conical.angle = angle;}/*!    Constructs a conical with the given center (\a cx, \a cy),    starting the interpolation at the given \a angle. The angle must    be specified in degrees between 0 and 360.    \sa setColorAt(), setStops()*/QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle){    m_type = ConicalGradient;    m_spread = PadSpread;    m_data.conical.cx = cx;    m_data.conical.cy = cy;    m_data.conical.angle = angle;}/*!    Returns the center of the conical gradient in logical coordinates    \sa stops()*/QPointF QConicalGradient::center() const{    Q_ASSERT(m_type == ConicalGradient);    return QPointF(m_data.conical.cx, m_data.conical.cy);}/*!    Returns the start angle of the conical gradient in logical coordinates    \sa stops()*/qreal QConicalGradient::angle() const{    Q_ASSERT(m_type == ConicalGradient);    return m_data.conical.angle;}/*!    \typedef QGradientStop    \relates QGradient    Typedef for QPair<\l qreal, QColor>.*//*!    \typedef QGradientStops    \relates QGradient    Typedef for QVector<QGradientStop>.*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -