diff options
author | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2011-11-02 12:33:30 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-02 17:10:00 +0100 |
commit | b9f0bde16e85161666d5090952955bebacc40f89 (patch) | |
tree | 566c4f9d93a3d8a0cb0f74c04e65a32f1e174059 /src/corelib/tools/qeasingcurve.h | |
parent | 7d560240fae18afa385b868f17121f80f33bfbb2 (diff) |
Adding custom bezier easing curves to QEasingCurve
I added the possibilty to define Bezier/TCB splines and use them
as custom easing curves.
Note:
Splines have a parametric definition. This means we have a
function/polynom of t that evalutes to x and y. x/y = f(t).
For our purpose we actually need the function y = f(x).
So as a first step we have to solve the solution x = f(t) for a given
t and then in a second step we evaluate y = f(t).
f(t) is a cubic polynom so we use cardanos formula to solve this equation
directly.
For the casus irreducibilis we need 3 functions that are a combination of
arcos and cos. Instead of evaluating arcos and cos we approximate these
functions directly.
TCB splines are converted into the corresponding cubic bezier spline.
Change-Id: Id2afc15efac92e494d6358dc2e11f94e8c524da1
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/corelib/tools/qeasingcurve.h')
-rw-r--r-- | src/corelib/tools/qeasingcurve.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h index 2deda2cd1e..a1c11ceba4 100644 --- a/src/corelib/tools/qeasingcurve.h +++ b/src/corelib/tools/qeasingcurve.h @@ -52,6 +52,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) class QEasingCurvePrivate; +class QPointF; class Q_CORE_EXPORT QEasingCurve { Q_GADGET @@ -70,7 +71,7 @@ public: InBack, OutBack, InOutBack, OutInBack, InBounce, OutBounce, InOutBounce, OutInBounce, InCurve, OutCurve, SineCurve, CosineCurve, - Custom, NCurveTypes + BezierSpline, TCBSpline, Custom, NCurveTypes }; QEasingCurve(Type type = Linear); @@ -91,6 +92,9 @@ public: qreal overshoot() const; void setOvershoot(qreal overshoot); + void addCubicBezierSegment(const QPointF & c1, const QPointF & c2, const QPointF & endPoint); + void addTCBSegment(const QPointF &nextPoint, qreal t, qreal c, qreal b); + Type type() const; void setType(Type type); typedef qreal (*EasingFunction)(qreal progress); |