]> git.sesse.net Git - kdenlive/blobdiff - src/colortools.cpp
Fix indent
[kdenlive] / src / colortools.cpp
index d42d12b3e1cda8a53caa13645beb7d025b249cf5..7f513a701e2dd5ae211bdcae2ca098753878c87a 100644 (file)
@@ -268,8 +268,8 @@ QImage ColorTools::hsvHueShiftPlane(const QSize &size, const uint &S, const uint
     float hue, huediff;
     int newhue;
     for (int x = 0; x < size.width(); x++) {
+        hue = x/(size.width() - 1.0) * 359;
         for (int y = 0; y < size.height(); y++) {
-            hue = x/(size.width() - 1.0) * 359;
             huediff = (1.0f - y/(size.height() - 1.0)) * hueValues + MIN;
 //            qDebug() << "hue: " << hue << ", huediff: " << huediff;
 
@@ -285,6 +285,84 @@ QImage ColorTools::hsvHueShiftPlane(const QSize &size, const uint &S, const uint
 
 }
 
+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);
+
+    /*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;
+
+}
+
+
 
 
 
@@ -292,3 +370,4 @@ QImage ColorTools::hsvHueShiftPlane(const QSize &size, const uint &S, const uint
 
 
 
+#include "colortools.moc"