]> git.sesse.net Git - kdenlive/commitdiff
Bézier spline:
authorTill Theato <root@ttill.de>
Fri, 31 Dec 2010 19:38:00 +0000 (19:38 +0000)
committerTill Theato <root@ttill.de>
Fri, 31 Dec 2010 19:38:00 +0000 (19:38 +0000)
- calculate some more points
- update default values
- fix handles drawn slightly off target

svn path=/trunk/kdenlive/; revision=5227

effects/frei0r_bezier_curves.xml
src/beziercurve/beziersplinewidget.cpp
src/beziercurve/cubicbezierspline.cpp

index 07d9a69223fc38c323984f67cf164e78eae8dc09..8a4bfb5172048ad36585efa9549324d3be347ffa 100644 (file)
@@ -2,7 +2,7 @@
 <effect tag="frei0r.curves" id="frei0r.bezier_curves">
         <name>Bézier Curves</name>
         <description>Color curves adjustment</description>
-        <author>Maksim Golovkin, Till Theato</author>
+        <author>Till Theato, Maksim Golovkin</author>
 
         <parameter type="list" name="Channel" default="0" paramlist="0,1,2,3" paramlistdisplay="Red,Green,Blue,Luma">
                 <name>Channel</name>
@@ -12,7 +12,7 @@
                 <name>Luma formula</name>
         </parameter>
 
-        <parameter type="bezier_spline" name="Bézier spline" depends="Channel" default="0;0#0;0#0;0.5|1;0.5#1;1#1;1">
+        <parameter type="bezier_spline" name="Bézier spline" depends="Channel" default="-1;-1#0;0#0.1;0.1|0.9;0.9#1;1#2;2">
                 <name>Bézier Curve(Spline) Widget</name>
         </parameter>
 </effect>
index 8cfab9867912d8ddb3325e2033ecf9da0822b98b..3ace2c422a71fb00c5fc56371deed049db720c1c 100644 (file)
@@ -28,7 +28,6 @@ BezierSplineWidget::BezierSplineWidget(QWidget* parent) :
         m_mode(ModeNormal),
         m_currentPointIndex(-1)
 {
-    //m_spline.setPrecision(width());
     setMouseTracking(true);
     setAutoFillBackground(false);
     setAttribute(Qt::WA_OpaquePaintEvent);
@@ -58,7 +57,9 @@ void BezierSplineWidget::paintEvent(QPaintEvent* event)
     int    wWidth = width() - 1;
     int    wHeight = height() - 1;
 
-    // Draw curve.
+    /*
+     * Spline
+     */
     double prevY = wHeight - m_spline.value(0.) * wHeight;
     double prevX = 0.;
     double curY;
@@ -70,7 +71,7 @@ void BezierSplineWidget::paintEvent(QPaintEvent* event)
         normalizedX = x / (double)wWidth;
         curY = wHeight - m_spline.value(normalizedX, true) * wHeight;
         
-        /**
+        /*
          * Keep in mind that QLineF rounds doubles
          * to ints mathematically, not just rounds down
          * like in C
@@ -82,25 +83,27 @@ void BezierSplineWidget::paintEvent(QPaintEvent* event)
     }
     p.drawLine(QLineF(prevX, prevY ,
                       x, wHeight - m_spline.value(1.0, true) * wHeight));
-    
-    // Drawing curve handles.
+
+    /*
+     * Points + Handles
+     */
     p.setPen(QPen(Qt::red, 1, Qt::SolidLine));
     BPoint point;
     QPolygon handle(4);
     handle.setPoints(4,
-                     0,  0,
-                     3,  3,
-                     0,  6,
-                     -3, 3);
+                     1,  -2,
+                     4,  1,
+                     1,  4,
+                     -2, 1);
     for (int i = 0; i < m_spline.points().count(); ++i) {
         point = m_spline.points().at(i);
         if (i == m_currentPointIndex)
             p.setBrush(QBrush(QColor(Qt::red), Qt::SolidPattern));
 
-        p.drawPolygon(handle.translated(point.h1.x() * wWidth, wHeight - point.h1.y() * wHeight));
+        p.drawConvexPolygon(handle.translated(point.h1.x() * wWidth, wHeight - point.h1.y() * wHeight));
         p.drawEllipse(QRectF(point.p.x() * wWidth - 3,
                             wHeight - 3 - point.p.y() * wHeight, 6, 6));
-        p.drawPolygon(handle.translated(point.h2.x() * wWidth, wHeight - point.h2.y() * wHeight));
+        p.drawConvexPolygon(handle.translated(point.h2.x() * wWidth, wHeight - point.h2.y() * wHeight));
 
         if ( i == m_currentPointIndex)
             p.setBrush(QBrush(Qt::NoBrush));
index c6d031f80869ef4379d258ea738804e3db2a3fbb..0671f72ba05bf05780a5b5bbe64a969f07f05e3e 100644 (file)
@@ -216,7 +216,7 @@ void CubicBezierSpline::update()
                 << m_points.at(i+1).h1
                 << m_points.at(i+1).p;
 
-        int numberOfValues = (int)((points[3].x() - points[0].x()) * m_precision);
+        int numberOfValues = (int)((points[3].x() - points[0].x()) * m_precision * 2);
         if (numberOfValues == 0)
             numberOfValues = 1;
         double step = 1 / (double)numberOfValues;