当前位置: 首页>>代码示例>>C++>>正文


C++ QColor::hue方法代码示例

本文整理汇总了C++中QColor::hue方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::hue方法的具体用法?C++ QColor::hue怎么用?C++ QColor::hue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QColor的用法示例。


在下文中一共展示了QColor::hue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setColor

void KTColorPalette::setColor(const QBrush& brush)
{
	QColor color = brush.color();
	
	if(color.isValid())
	{
		if(m_type == Gradient)
		{
			m_gradientManager->setCurrentColor(color);
		}
		if(m_displayValueColor && m_outlineAndFillColors && m_colorPicker && m_nameColor && m_luminancePicker)
		{
			
			
			m_colorPicker->setCol(color.hue(), color.saturation ());
			if(m_type == Solid)
			{
				m_outlineAndFillColors->setCurrentColor(color);
			}
			m_nameColor->setText(color.name ());
			m_luminancePicker->setCol(color.hue(), color.saturation(), color.value());
			m_containerPalette->setColor( brush );
			m_displayValueColor->setColor(color);
		}
		
	}
	else if(brush.gradient())
	{
		
		QGradient gradient(*brush.gradient());
		changeBrushType(tr("Gradient"));

		m_containerPalette->setColor(gradient);
		m_outlineAndFillColors->setCurrentColor(gradient);
		if( sender () != m_gradientManager )
		{
			m_gradientManager->setGradient(gradient);
		}
		
	}
	emit brushChanged( m_outlineAndFillColors->foreground(),m_outlineAndFillColors->background() );
	
}
开发者ID:BackupTheBerlios,项目名称:ktoon-svn,代码行数:43,代码来源:ktcolorpalette.cpp

示例2: summarize

QString HrZones::summarize(int rnum, QVector<double> &time_in_zone) const
{
    assert(rnum < ranges.size());
    const HrZoneRange &range = ranges[rnum];
    if (time_in_zone.size() < range.zones.size()) return "";
    QString summary;
    if(range.lt > 0){
        summary += "<table align=\"center\" width=\"70%\" border=\"0\">";
        summary += "<tr><td align=\"center\">";
        summary += tr("Threshold (bpm): %1").arg(range.lt);
        summary += "</td></tr></table>";
    }
    summary += "<table align=\"center\" width=\"70%\" ";
    summary += "border=\"0\">";
    summary += "<tr>";
    summary += tr("<td align=\"center\">Zone</td>");
    summary += tr("<td align=\"center\">Description</td>");
    summary += tr("<td align=\"center\">Low (bpm)</td>");
    summary += tr("<td align=\"center\">High (bpm)</td>");
    summary += tr("<td align=\"center\">Time</td>");
    summary += tr("<td align=\"center\">%</td>");
    summary += "</tr>";
    QColor color = QApplication::palette().alternateBase().color();
    color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value());

    double duration = 0;
    foreach(double v, time_in_zone) { duration += v; }

    for (int zone = 0; zone < time_in_zone.size(); ++zone) {
        if (time_in_zone[zone] > 0.0) {
            QString name, desc;
            int lo, hi;
            double trimp;
            zoneInfo(rnum, zone, name, desc, lo, hi, trimp);
            if (zone % 2 == 0)
                summary += "<tr bgcolor='" + color.name() + "'>";
            else
                summary += "<tr>";
            summary += QString("<td align=\"center\">%1</td>").arg(name);
            summary += QString("<td align=\"center\">%1</td>").arg(desc);
            summary += QString("<td align=\"center\">%1</td>").arg(lo);
            if (hi == INT_MAX)
                summary += "<td align=\"center\">MAX</td>";
            else
                summary += QString("<td align=\"center\">%1</td>").arg(hi);
            summary += QString("<td align=\"center\">%1</td>")
                .arg(time_to_string((unsigned) round(time_in_zone[zone])));
            summary += QString("<td align=\"center\">%1</td>")
                .arg((double)time_in_zone[zone]/duration * 100, 0, 'f', 0);
            summary += "</tr>";
        }
    }
    summary += "</table>";
    return summary;
}
开发者ID:BryanF1947,项目名称:GoldenCheetah,代码行数:55,代码来源:HrZones.cpp

示例3: setColor

void ColorWheel::setColor(const QColor &color)
{
    if (color == m_currentColor)
    {
        return;
    }
    if (color.hue() != m_currentColor.hue())
    {
        hueChanged(color.hue());
    }

    if (color.saturation() != m_currentColor.saturation() ||
        color.value() != m_currentColor.value() )
    {
        svChanged(color);
    }

    update();
    emit colorSelected(color);
}
开发者ID:CandyFace,项目名称:pencil,代码行数:20,代码来源:colorwheel.cpp

示例4: mousePressEvent

void ColorWheel::mousePressEvent(QMouseEvent *event)
{
    lastPos = event->pos();
    if(wheelRegion.contains(lastPos)){
        inWheel = true;
        QColor color = posColor(lastPos);
        hueChanged(color.hue());
    }

    mouseDown = true;
}
开发者ID:nzhome,项目名称:lightcontroller,代码行数:11,代码来源:colorwheel.cpp

示例5: setSelectedIndex

void HueSatSelector::setSelectedIndex(QColor c)
{
	if (value != c.value())
	{
		value = c.value();
		for (int i = 0 ; i < 360 ; i++)
			for (int j = 0 ; j < 256 ; j++)
				background.setPixel(i, j, QColor::fromHsv(i, j, value).rgb());
	}
	ColorSelector::setSelectedIndex(QPoint(c.hue(),c.saturation()));
}
开发者ID:AlfredoCubitos,项目名称:qosmic,代码行数:11,代码来源:colordialog.cpp

示例6: setColor

void Group::setColor(const QColor &color)
{
    // Transform from RGB to Hue/Sat
    quint16 hue = color.hue() * 65535 / 360;
    quint8 sat = color.saturation();

    // Transform from RGB to XYZ
    QGenericMatrix<3, 3, qreal> rgb2xyzMatrix;
    rgb2xyzMatrix(0, 0) = 0.412453;    rgb2xyzMatrix(0, 1) = 0.357580;    rgb2xyzMatrix(0, 2) = 0.180423;
    rgb2xyzMatrix(1, 0) = 0.212671;    rgb2xyzMatrix(1, 1) = 0.715160;    rgb2xyzMatrix(1, 2) = 0.072169;
    rgb2xyzMatrix(2, 0) = 0.019334;    rgb2xyzMatrix(2, 1) = 0.119193;    rgb2xyzMatrix(2, 2) = 0.950227;

    QGenericMatrix<1, 3, qreal> rgbMatrix;
    rgbMatrix(0, 0) = 1.0 * color.red() / 255;
    rgbMatrix(1, 0) = 1.0 * color.green() / 255;
    rgbMatrix(2, 0) = 1.0 * color.blue() / 255;

    QGenericMatrix<1, 3, qreal> xyzMatrix = rgb2xyzMatrix * rgbMatrix;

    // transform from XYZ to CIELUV u' and v'
    qreal u = 4*xyzMatrix(0, 0) / (xyzMatrix(0, 0) + 15*xyzMatrix(1, 0) + 3*xyzMatrix(2, 0));
    qreal v = 9*xyzMatrix(1, 0) / (xyzMatrix(0, 0) + 15*xyzMatrix(1, 0) + 3*xyzMatrix(2, 0));

    // Transform from CIELUV to (x,y)
    qreal x = 27*u / (18*u - 48*v + 36);
    qreal y = 12*v / (18*u - 48*v + 36);

    qDebug() << "setting color" << color << x << y;
    if (m_busyStateChangeId == -1) {
        QVariantMap params;

        params.insert("hue", hue);
        params.insert("sat", sat);
        // FIXME: There is a bug in the API that it doesn't report back the set state of "sat"
        // Lets just assume it always succeeds
        m_sat = sat;

//        QVariantList xyList;
//        xyList << x << y;
//        params.insert("xy", xyList);


        params.insert("on", true);
        m_busyStateChangeId = HueBridgeConnection::instance()->put("groups/" + QString::number(m_id) + "/action", params, this, "setStateFinished");
        m_timeout.start();
    } else {
        m_dirtyHue = hue;
        m_hueDirty = true;
        m_dirtySat = sat;
        m_satDirty = true;
//        m_xyDirty = true;
//        m_dirtyXy = QPointF(x, y);
    }
}
开发者ID:MARIANI08,项目名称:shine,代码行数:54,代码来源:group.cpp

示例7: event

bool QgsColorButton::event( QEvent *e )
{
  if ( e->type() == QEvent::ToolTip )
  {
    QColor c = linkedProjectColor();
    bool isProjectColor = c.isValid();
    if ( !isProjectColor )
      c = mColor;

    QString name = c.name();
    int hue = c.hue();
    int value = c.value();
    int saturation = c.saturation();

    // create very large preview swatch
    int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 23 );
    int height = static_cast< int >( width / 1.61803398875 ); // golden ratio

    int margin = static_cast< int >( height * 0.1 );
    QImage icon = QImage( width + 2 * margin, height + 2 * margin, QImage::Format_ARGB32 );
    icon.fill( Qt::transparent );

    QPainter p;
    p.begin( &icon );

    //start with checkboard pattern
    QBrush checkBrush = QBrush( transparentBackground() );
    p.setPen( Qt::NoPen );
    p.setBrush( checkBrush );
    p.drawRect( margin, margin, width, height );

    //draw color over pattern
    p.setBrush( QBrush( c ) );

    //draw border
    p.setPen( QColor( 197, 197, 197 ) );
    p.drawRect( margin, margin, width, height );
    p.end();

    QByteArray data;
    QBuffer buffer( &data );
    icon.save( &buffer, "PNG", 100 );

    QString info = ( isProjectColor ? QStringLiteral( "<p>%1: %2</p>" ).arg( tr( "Linked color" ), mLinkedColorName ) : QString() )
                   + QStringLiteral( "<b>HEX</b> %1<br>"
                                     "<b>RGB</b> %2<br>"
                                     "<b>HSV</b> %3,%4,%5<p>"
                                     "<img src='data:image/png;base64, %0'>" ).arg( QString( data.toBase64() ), name,
                                         QgsSymbolLayerUtils::encodeColor( c ) )
                   .arg( hue ).arg( saturation ).arg( value );
    setToolTip( info );
  }
  return QToolButton::event( e );
}
开发者ID:dmarteau,项目名称:QGIS,代码行数:54,代码来源:qgscolorbutton.cpp

示例8: add

void ContinuousColorRange::add(const QVariant &v)
{
    if ( contains(v))
        return;
    QColor clr = toColor(v, defaultColorModel());
    if ( !clr.isValid())
        return;
    if ( defaultColorModel() == ColorRangeBase::cmRGBA){
        _limit1.setRed(std::min(_limit1.red(), clr.red()));
        _limit1.setGreen(std::min(_limit1.green(), clr.green()));
        _limit1.setBlue(std::min(_limit1.blue(), clr.blue()));
        _limit1.setAlpha(std::min(_limit1.alpha(), clr.alpha()));
        _limit2.setRed(std::max(_limit2.red(), clr.red()));
        _limit2.setGreen(std::max(_limit2.green(), clr.green()));
        _limit2.setBlue(std::max(_limit2.blue(), clr.blue()));
        _limit2.setAlpha(std::max(_limit2.alpha(), clr.alpha()));
    }else if (defaultColorModel() == ColorRangeBase::cmHSLA) {
        _limit1.setHsl(std::min(_limit1.hue(), clr.hue()),
                       std::min(_limit1.saturation(), clr.saturation()),
                       std::min(_limit1.lightness(), clr.lightness()));
        _limit1.setAlpha(std::min(_limit1.alpha(), clr.alpha()));
        _limit2.setHsl(std::max(_limit2.hue(), clr.hue()),
                       std::max(_limit2.saturation(), clr.saturation()),
                       std::max(_limit2.lightness(), clr.lightness()));
        _limit2.setAlpha(std::max(_limit2.alpha(), clr.alpha()));
    }
    else if ( defaultColorModel() == ColorRangeBase::cmCYMKA){
        _limit1.setCmyk(std::min(_limit1.cyan(), clr.cyan()),
                        std::min(_limit1.magenta(), clr.magenta()),
                        std::min(_limit1.yellow(), clr.yellow()),
                        std::min(_limit1.black(), clr.black()));
        _limit1.setAlpha(std::min(_limit1.alpha(), clr.alpha()));
        _limit2.setCmyk(std::max(_limit2.cyan(), clr.cyan()),
                        std::max(_limit2.magenta(), clr.magenta()),
                        std::max(_limit2.yellow(), clr.yellow()),
                        std::max(_limit2.black(), clr.black()));
        _limit2.setAlpha(std::max(_limit2.alpha(), clr.alpha()));

    }

}
开发者ID:VincentBeltman,项目名称:IlwisCore,代码行数:41,代码来源:colorrange.cpp

示例9: make_color_readable

// Make a color darker if it's too bright
QColor make_color_readable(QColor clr)
{
    // Gray
    if (clr.red() == clr.green() && clr.green() == clr.blue()) {
        return QColor("black");
    }
    clr = clr.toHsv();
    int value = MIN(clr.value(), 150);
    int saturation = 255;
    clr.setHsv(clr.hue(), saturation, value, 255);
    return clr.toRgb();
}
开发者ID:nppangband,项目名称:NPPAngband_QT,代码行数:13,代码来源:utilities.cpp

示例10: setColor

void QgsColorWidget::setColor( const QColor &color, const bool emitSignals )
{
  if ( color == mCurrentColor )
  {
    return;
  }

  mCurrentColor = color;

  //update recorded hue
  if ( color.hue() >= 0 )
  {
    mExplicitHue = color.hue();
  }

  if ( emitSignals )
  {
    emit colorChanged( mCurrentColor );
  }

  update();
}
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:22,代码来源:qgscolorwidgets.cpp

示例11: setColor

void ColorWheel::setColor(QColor color)
{
    // this is a UI updating function, never emit any signals
    // and don't call any functions that will emit signals

    color = color.toHsv();

    if (color == mCurrentColor)
    {
        return;
    }

    if (color.hue() == -1) // grayscale color, keep the current hue
    {
        color.setHsv(mCurrentColor.hue(), color.saturation(), color.value(), color.alpha());
    }

    mCurrentColor = color;

    drawSquareImage(color.hue());
    update();
}
开发者ID:chchwy,项目名称:pencil2d,代码行数:22,代码来源:colorwheel.cpp

示例12: setColor

void NQColorWheel::setColor(const QColor &color)
{
    int h = color.hue();
    int s = color.saturation();
    int v = color.value();

    currentColor_.setHsv(h, s, v);

    if (!isVisible()) return;

    initializeSquare(h);

    repaint();
}
开发者ID:Negusbuk,项目名称:MatDB,代码行数:14,代码来源:nqcolorwheel.cpp

示例13: setBaseColor

// We try to ensure that the actual color used are within
// reasonalbe bounds while generating the actual baseColor
// from the users request.
void StyleHelper::setBaseColor(const QColor& newcolor) {
  m_requestedBaseColor = newcolor;

  QColor color;
  color.setHsv(newcolor.hue(), newcolor.saturation() * 0.7,
               64 + newcolor.value() / 3);

  if (color.isValid() && color != m_baseColor) {
    m_baseColor = color;
    for (QWidget* w : QApplication::topLevelWidgets()) {
      w->update();
    }
  }
}
开发者ID:Aceler,项目名称:Clementine,代码行数:17,代码来源:stylehelper.cpp

示例14: mouseMoveEvent

void ColorWheel::mouseMoveEvent(QMouseEvent *event)
{
    QColor color;
    lastPos = event->pos();
    if( !pressDown ) return;
    if(wheelRegion.contains(lastPos) && selectedWheel){
        color = colorPosition(lastPos);
        onHueChanged(color.hue());
    }else if(squareRegion.contains(lastPos) && selected){
        color = colorPosition(lastPos);
        onSVChanged(color);
    }else{
    }
}
开发者ID:VanEuclid,项目名称:TheDirtybirdCS3505,代码行数:14,代码来源:colorwheel.cpp

示例15: summarize

QString Zones::summarize(int rnum, QVector<double> &time_in_zone) const
{
    assert(rnum < ranges.size());
    ZoneRange *range = ranges[rnum];
    assert(time_in_zone.size() == range->zones.size());
    QString summary;
    if(range->cp > 0){
        summary += "<table align=\"center\" width=\"70%\" border=\"0\">";
        summary += "<tr><td align=\"center\">";
        summary += tr("Critical Power: %1").arg(range->cp);
        summary += "</td></tr></table>";
    }
    summary += "<table align=\"center\" width=\"70%\" ";
    summary += "border=\"0\">";
    summary += "<tr>";
    summary += "<td align=\"center\">Zone</td>";
    summary += "<td align=\"center\">Description</td>";
    summary += "<td align=\"center\">Low</td>";
    summary += "<td align=\"center\">High</td>";
    summary += "<td align=\"center\">Time</td>";
    summary += "</tr>";
    QColor color = QApplication::palette().alternateBase().color();
    color = QColor::fromHsv(color.hue(), color.saturation() * 2, color.value());
    for (int zone = 0; zone < time_in_zone.size(); ++zone) {
        if (time_in_zone[zone] > 0.0) {
            QString name, desc;
            int lo, hi;
            zoneInfo(rnum, zone, name, desc, lo, hi);
            if (zone % 2 == 0)
                summary += "<tr bgcolor='" + color.name() + "'>";
            else
                summary += "<tr>";
            summary += QString("<td align=\"center\">%1</td>").arg(name);
            summary += QString("<td align=\"center\">%1</td>").arg(desc);
            summary += QString("<td align=\"center\">%1</td>").arg(lo);
            if (hi == INT_MAX)
                summary += "<td align=\"center\">MAX</td>";
            else
                summary += QString("<td align=\"center\">%1</td>").arg(hi);
            summary += QString("<td align=\"center\">%1</td>")
                .arg(time_to_string((unsigned) round(time_in_zone[zone])));
            summary += "</tr>";
        }
    }
    summary += "</table>";
    return summary;
}
开发者ID:mdherynk,项目名称:GoldenCheetah,代码行数:47,代码来源:Zones.cpp


注:本文中的QColor::hue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。