Exemple #1
0
QPixmap ColourChooser::createVPixmap()
{
    int height = 250;

    QImage im = QImage(20,height, QImage::Format_RGB32);
    int h,s,v;

    //Take the average
    h = (int)((float)(mainMax->hue()+mainMin->hue())/(float)2);
    s = (int)((float)(mainMax->saturation()+mainMin->saturation())/(float)2);
    v = (int)((float)(mainMax->value()+mainMin->value())/(float)2);
    QColor main = main.fromHsv(h,s,v);

    h = (int)((float)(altMax->hue()+altMin->hue())/(float)2);
    s = (int)((float)(altMax->saturation()+altMin->saturation())/(float)2);
    v = (int)((float)(altMax->value()+altMin->value())/(float)2);
    QColor alt = alt.fromHsv(h,s,v);

    QColor* c = new QColor(main);
    for(int i=0; i<height;i++)
    {
        if(!isConstant)
        {
            h = (int)(alt.hue()*(float)i/(float)height + main.hue()*(float)(height-i)/(float)height);
            s = (int)(alt.saturation()*(float)i/(float)height + main.saturation()*(float)(height-i)/(float)height);
            v = (int)(alt.value()*(float)i/(float)height + main.value()*(float)(height-i)/(float)height);
            *c = c->fromHsv(h,s,v);
        }

        for(int j=0; j< 20; j++)
            im.setPixel(j,i,c->rgb());
    }
    return QPixmap().fromImage(im);
}
Exemple #2
0
QColor* LeafTemplate::getRandColor(QColor* min, QColor* max)
{
    int i = qrand();
    int h = (int)(max->hue()*(float)i/(float)RAND_MAX + min->hue()*(float)(RAND_MAX-i)/(float)RAND_MAX);
    i = qrand();
    int s = (int)(max->saturation()*(float)i/(float)RAND_MAX + min->saturation()*(float)(RAND_MAX-i)/(float)RAND_MAX);
    i = qrand();
    int v = (int)(max->value()*(float)i/(float)RAND_MAX + min->value()*(float)(RAND_MAX-i)/(float)RAND_MAX);

    QColor *c = new QColor(Qt::black);
    *c = c->fromHsv(h,s,v);
    return c;
}
Exemple #3
0
QPixmap ColourChooser::createHPixmap(QColor* min, QColor* max)
{
    QImage im = QImage(150,20, QImage::Format_RGB32);
    QColor* c = new QColor(*min);
    int h,s,v;

    for(int i=0; i<150;i++)
    {
        h = (int)(max->hue()*(float)i/(float)150 + min->hue()*(float)(150-i)/(float)150);
        s = (int)(max->saturation()*(float)i/(float)150 + min->saturation()*(float)(150-i)/(float)150);
        v = (int)(max->value()*(float)i/(float)150 + min->value()*(float)(150-i)/(float)150);

        *c = c->fromHsv(h,s,v);
        for(int j=0; j< 20; j++)
            im.setPixel(i,j,c->rgb());
    }
    return QPixmap().fromImage(im);
}