Logo Search packages:      
Sourcecode: kdenlive version File versions  Download package

QImage ColorTools::hsvCurvePlane ( const QSize &  size,
const QColor &  baseColor,
const ComponentsHSV &  xVariant,
const ComponentsHSV &  yVariant,
const bool &  shear = false,
const float  offsetY = 0 
) [static]

Basic HSV plane with two components varying on the x and y axis. If both components are the same, then the y axis will be considered. MIN/MAX give the minimum/maximum saturation, usually 0..255. Missing colour components will be taken from baseColor. For shear == true, the image will be sheared such that the x axis goes through (0,0) and (1,1). offsetY can additionally shift the whole x axis vertically.

Definition at line 288 of file colortools.cpp.

Referenced by BezierSplineWidget::slotShowPixmap().

{
    Q_ASSERT(size.width() > 0);
    Q_ASSERT(size.height() > 0);

    /*int xMax, yMax;

    switch(xVariant) {
    case COM_H:
        xMax = 360;
        break;
    case COM_S:
    case COM_V:
        xMax = 256;
        break;
    }

    switch (yVariant) {
    case COM_H:
        yMax = 360;
        break;
    case COM_S:
    case COM_V:
        yMax = 256;
        break;
    }*/


    QImage plane(size, QImage::Format_ARGB32);

    QColor col(0, 0, 0);

    float hue, sat, val;
    hue = baseColor.hueF();
    sat = baseColor.saturationF();
    val = baseColor.valueF();

    for (int x = 0; x < size.width(); x++) {
        switch (xVariant) {
        case COM_H:
            hue = x / (size.width()-1.0);
            break;
        case COM_S:
            sat = x / (size.width()-1.0);
            break;
        case COM_V:
            val = x / (size.width()-1.0);
            break;
        }
        for (int y = 0; y < size.height(); y++) {
            switch (yVariant) {
            case COM_H:
                hue = 1.0 - y / (size.height()-1.0);
                break;
            case COM_S:
                sat = 1.0 - y / (size.height()-1.0);
                break;
            case COM_V:
                val = 1.0 - y / (size.height()-1.0);
                break;
            }

            col.setHsvF(hue, sat, val);

            if (!shear) {
                plane.setPixel(x, y, col.rgba());
            } else {
                plane.setPixel(x, int(2*size.height() + y - x*size.width()/size.height() - offsetY * size.height()) % size.height(), col.rgba());
            }
        }
    }

    return plane;

}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index