X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcolortools.cpp;h=7f513a701e2dd5ae211bdcae2ca098753878c87a;hb=c3302003093710ee247ad84c0fe2ef3c579d417f;hp=a1df69ed208a6214d7f9e60358d3da8edf0e07e5;hpb=a0782da90d2e491e2f1ec9ad8a114883fb2e02b4;p=kdenlive diff --git a/src/colortools.cpp b/src/colortools.cpp index a1df69ed..7f513a70 100644 --- a/src/colortools.cpp +++ b/src/colortools.cpp @@ -285,31 +285,81 @@ QImage ColorTools::hsvHueShiftPlane(const QSize &size, const uint &S, const uint } -QImage ColorTools::hsvSaturationPlane(const QSize &size, const uint &V, const int &MIN, const int &MAX) +QImage ColorTools::hsvCurvePlane(const QSize &size, const QColor &baseColor, + const ComponentsHSV &xVariant, const ComponentsHSV &yVariant, const bool &shear, const float offsetY) { Q_ASSERT(size.width() > 0); Q_ASSERT(size.height() > 0); - Q_ASSERT(MAX > MIN); - Q_ASSERT(MIN >= 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; + float hue, sat, val; + hue = baseColor.hueF(); + sat = baseColor.saturationF(); + val = baseColor.valueF(); for (int x = 0; x < size.width(); x++) { - hue = 359 * x / (size.width()-1.0); + 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++) { - sat = (1 - y/(size.height()-1.0)) * (MAX-MIN) + MIN; + 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.setHsv(hue, sat, V); + col.setHsvF(hue, sat, val); - plane.setPixel(x, y, col.rgba()); + 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; + } @@ -319,3 +369,5 @@ QImage ColorTools::hsvSaturationPlane(const QSize &size, const uint &V, const in + +#include "colortools.moc"