本文整理汇总了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() );
}
示例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;
}
示例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);
}
示例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;
}
示例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()));
}
示例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);
}
}
示例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 );
}
示例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()));
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
}
示例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{
}
}
示例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;
}