本文整理汇总了C++中QColor::setHsvF方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setHsvF方法的具体用法?C++ QColor::setHsvF怎么用?C++ QColor::setHsvF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setHsvF方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void MainWindow::update(){
// we draw by using a QImage - turn it into a Pixmap, then put it on a label
QImage img(200, 200, QImage::Format_RGB32);
bool display;
/* Our color wheel has a radius of 100. Loop through the rectangle
looking for pixels within that radius. For good pixels we calculate
the H value based on the angle from the origin. The S value is
set according to the distance / radius, and the V is fixed (but
settable by a slider).
*/
for (int i = 0; i < 200; i++)
{
for (int j = 0; j < 200; j++)
{
float dist = sqrt((i - 100) * (i - 100) + (j - 100) * (j - 100));
if (dist < 100.0)
{
display = true;
float s = dist / 100.0f;
float h = atan2(i - 100, j - 100) / (2.0f * 3.14156);
if (h < 0)
{
h = 1.0f + h;
}
// Since H is an angle the math is modulo.
if (hMax > hMin)
{
if (hMin > h || hMax < h)
{
display = false;
}
} else if (hMin > h && hMax < h )
{
display = false;
}
if (s < sMin || s > sMax)
{
display = false;
}
QColor c;
if (display)
{
c.setHsvF(h, s, zValue);
} else{
c.setHsvF(0.0, 0.0, 1.0f);
}
img.setPixel(i, j, c.rgb());
}
}
}
QPixmap pix;
pix.convertFromImage(img);
ui->colwheel->setPixmap(pix);
ui->colwheel->repaint();
}
示例2: paintEvent
void ColorSpace::paintEvent(QPaintEvent * event)
{
int w = width();
int h = height();
if (!pix || pix->height() != h || pix->width() != w) {
delete pix;
QImage img(w, h, QImage::Format_RGB32);
unsigned int * pixel = (unsigned int*)img.scanLine(0);
for (int y = 0; y < h; y++) {
const unsigned int * end = pixel + w;
int x = 0;
while (pixel < end) {
QColor c;
float sat = float(x) / float(w);
float val = 1.0f - float(y) / float(h);
c.setHsvF(hue, sat, val);
*pixel = c.rgb();
pixel++;
x++;
}
}
pix = new QPixmap(QPixmap::fromImage(img));
}
QPainter p(this);
p.drawPixmap(0, 0, *pix);
int p_x = int(sat * w);
int p_y = int((1.0f - val) * h);
draw_pointer(p_x, p_y, p);
}
示例3: computeAverageColor
QColor ImageUtilities::computeAverageColor(const QImage& image)
{
long int rtotal = 0, gtotal = 0, btotal = 0;
float total = 0.0f;
// always sample 100x100 pixels
int samplePoints = 100;
int stepX = std::max(image.width() / samplePoints, 1);
int stepY = std::max(image.height() / samplePoints, 1);
for (int y = 0; y < image.height(); y += stepY) {
for (int x = 0; x < image.width(); x += stepX) {
QColor color = QColor::fromRgba(image.pixel(x, y));
float saturation = (qMax (color.red(), qMax (color.green(), color.blue())) -
qMin (color.red(), qMin (color.green(), color.blue()))) / 255.0f;
float relevance = .1 + .9 * (color.alpha() / 255.0f) * saturation;
rtotal += (unsigned char) (color.red() * relevance);
gtotal += (unsigned char) (color.green() * relevance);
btotal += (unsigned char) (color.blue() * relevance);
total += relevance * 255;
}
}
QColor hsv = QColor::fromRgbF(rtotal / total, gtotal / total, btotal / total).toHsv();
/* Background color is the base color with 0.90f HSV value */
hsv.setHsvF(hsv.hueF(),
(hsv.saturationF() > .15f) ? 0.65f : hsv.saturationF(),
0.90f);
return hsv;
}
示例4: ReceiveObstacleMap
void MapOverview::ReceiveObstacleMap(std::vector<Eigen::Vector2d> points)
{
if(mCore != nullptr)
delete mCore;
mCore = new QGraphicsItemGroup();
mCore->setPos(mRobotInstance->pos());
mCore->setRotation(mRobotInstance->rotation());
int id = 0;
for(const auto& imagePt : points)
{
QColor color;
color.setHsvF( (static_cast<double>(id)/points.size()) , 1.0, 1.0);
auto rect = new QGraphicsRectItem(imagePt.x(), imagePt.y(), 5.0 / 512.0, 5.0 / 512.0);
rect->setPen(QPen(color, 0));
mCore->addToGroup(rect);
id++;
}
//std::cout << "Receiving obstacle list with " << id << " items.\n";
//mCore->setPos(mRobotInstance->pos());
//mCore->setRotation(mRobotInstance->rotation());
scene.addItem(mCore);
}
示例5: MinoAnimation
MinaCurve::MinaCurve(QObject *object) :
MinoAnimation(object)
{
_generatorCurve = new MinoPropertyEasingCurve(this, true);
_generatorCurve->setObjectName("curve");
_generatorCurve->setLabel("Curve");
_generatorAccel = new MinoPropertyEasingCurve(this);
_generatorAccel->setObjectName("acceleration");
_generatorAccel->setLabel("Accel.");
// Please note that curve have not been tested with all parameters:
// Theses following lines are here to show how to add curve type to selector
_generatorAccel->addEasingCurveType(QEasingCurve::Linear);
_generatorAccel->addEasingCurveType(QEasingCurve::OutInBack);
_generatorAccel->addEasingCurveType(QEasingCurve::InOutBounce);
_generatorAccel->addEasingCurveType(QEasingCurve::InOutQuart);
_generatorAccel->setEasingCurveType(QEasingCurve::Linear);
QColor color;
color.setHsvF(0.4, 1.0, 1.0);
for (int i=0;i<_boundingRect.width();i++)
{
_items.append(_scene->addLine(i,_boundingRect.height(),i,5,QPen(color)));
_itemGroup.addToGroup(_items[i]);
}
QGraphicsBlurEffect *blur = new QGraphicsBlurEffect(this);
blur->setBlurRadius(1.1);
_itemGroup.setGraphicsEffect(blur);
_itemGroup.setVisible(false);
}
示例6: darkShade
static QColor darkShade(QColor c)
{
qreal contrast = 0.7; // taken from kcolorscheme for the dark shade
qreal darkAmount;
if (c.lightnessF() < 0.006)
{
/* too dark */
darkAmount = 0.02 + 0.40 * contrast;
}
else if (c.lightnessF() > 0.93)
{
/* too bright */
darkAmount = -0.06 - 0.60 * contrast;
}
else
{
darkAmount = (-c.lightnessF()) * (0.55 + contrast * 0.35);
}
qreal v = c.lightnessF() + darkAmount;
v = v > 0.0 ? (v < 1.0 ? v : 1.0) : 0.0;
c.setHsvF(c.hslHueF(), c.hslSaturationF(), v);
return c;
}
示例7: interpolateHSV
QColor Function::interpolateHSV(double delta, QColor const& col1, QColor const& col2) const
{
if (delta <= 0.0) return col1;
if (delta >= 1.0) return col2;
double h1, h2, s1, s2, v1, v2;
col1.getHsvF(&h1, &s1, &v1);
col2.getHsvF(&h2, &s2, &v2);
if (h1 < 0.0) h1 = h2;
if (h2 < 0.0) h2 = h1;
if (h1 < 0.0 && h2 < 0.0) { h1 = 0.0; h2 = 0.0; }
s1 += delta*(s2-s1);
v1 += delta*(v2-v1);
// For hue we need to work out which direction we are going on the wheel.
double dh(h2-h1);
if (dh > 0.5) {
dh -= 1.0;
}else if(dh < -0.5) {
dh += 1.0;
}
h1 += delta*dh;
if (h1 > 1.0) h1 -= 1.0;
if (h1 < 0.0) h1 += 1.0;
QColor color;
color.setHsvF(h1, s1, v1);
return color;
}
示例8: color
QColor ClassItem::color() const
{
auto dt = data();
int hue = dt.firstCode() % 100;
QColor c;
c.setHsvF(hue / 100., 1, 1);
return c;
}
示例9: slotChangeAlpha
void QtGradientStopsControllerPrivate::slotChangeAlpha(int color)
{
QColor c = m_ui->alphaColorLine->color();
if (m_ui->hsvRadioButton->isChecked())
c.setHsvF(c.hueF(), c.saturationF(), c.valueF(), (qreal)color / 255);
else
c.setAlpha(color);
slotChangeAlpha(c);
}
示例10: slotChangeHue
void QtGradientStopsControllerPrivate::slotChangeHue(int color)
{
QColor c = m_ui->hueColorLine->color();
if (m_ui->hsvRadioButton->isChecked())
c.setHsvF((qreal)color / 360.0, c.saturationF(), c.valueF(), c.alphaF());
else
c.setRed(color);
slotChangeHue(c);
}
示例11: run
void Worker::run()
{
// Note: this is never called directly. It is called by Qt once the
// thread environment has been set up
// random.seed();
int n = stars;
int m_width = m_size.width();
int m_height= m_size.height();
do {
QImage image = QImage(outerRadius * 2, outerRadius * 2, QImage::Format_ARGB32);
image.fill(qRgba(255, 255, 256, 0));
int x = GetRNDValue(0, m_width);
int y = GetRNDValue(0, m_height);
int angle = GetRNDValue(0, 360);
int red = GetRNDValue(0, 256);
int green = GetRNDValue(0, 256);
int blue = GetRNDValue(0, 256);
int alpha = GetRNDValue(0, 256);
/*
QPainter *painter = new QPainter();
painter->begin(&image);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(red, green, blue, alpha));
painter->translate(outerRadius, outerRadius);
painter->rotate(angle);
painter->drawPath(path);
painter->end();
*/
//-----------
QImage myQImage(60, 60, QImage::Format_RGB32);
QPainter painter1(&myQImage);
for (int i=0; i<60; i++)
{
for (int j=0; j<60; j++)
{
double hue = (double)(i + j + i*j)/361200.0;
QColor myColor;
myColor.setHsvF(hue, 1.0, 1.0, 1.0);
painter1.setPen(myColor);
painter1.drawPoint(i, j);
}
}
//-----------
emit output (QRect(x - outerRadius, y - outerRadius, outerRadius * 2, outerRadius * 2), myQImage);
sleep(0.01);
n --;
qDebug("Iteration number %d\n", n);
} while ((!exiting) && (n > 0));
}
示例12: neighbourhoodLegendEntry
void Plotter::neighbourhoodLegendEntry(int id, QString name)
{
neighbourhoodPlotter->addGraph(neighbourhoodPlotter->xAxis, neighbourhoodPlotter->yAxis);
QColor color;
double hue = id / 10.0;
color.setHsvF(hue, 1, 1);
neighbourhoodPlotter->graph(id)->setPen(QPen(color));
neighbourhoodPlotter->graph(id)->setName(name);
}
示例13: paint
void Line::paint(QPainter *qp) {
QColor qc;
double r,E;
r=findR(*_iP_lne[0],*_iP_lne[1]);
E=(_length-r)*fabs(_length-r)/1000;//-1,+1
if(E>1) E=1;
else if(E<-1) E=-1;
qc.setHsvF(0.5 + 0.4*E,fabs(E),1.0);
qp->setPen(QPen(qc));
qp->drawLine((*_iP_lne[0])->getX(0),(*_iP_lne[0])->getX(1),(*_iP_lne[1])->getX(0),(*_iP_lne[1])->getX(1));
}
示例14: Desaturate
QColor PrefDialog::Desaturate(QColor c)
{
qreal h;
qreal s;
qreal v;
qreal a;
c.getHsvF(&h, &s, &v, &a);
v = qMin((0.8 + v * 0.2), 1.0);
c.setHsvF(h, (s * 0.2), v, 1.0);
return c;
}
示例15: drawCTU
bool BitDisplayFilter::drawCTU (FilterContext *pcContext, QPainter *pcPainter,
ComCU *pcCTU, double dScale, QRect *pcScaledArea)
{
int iClip = VALUE_CLIP(0,240,pcCTU->getBitCount());
QColor cFill;
double dHue = (240-iClip)/360.0;
cFill.setHsvF(dHue, 1.0, 1.0, 0.6);
pcPainter->setBrush(QBrush(cFill));
pcPainter->setPen(Qt::NoPen);
pcPainter->drawRect(*pcScaledArea);
return true;
}