2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG (www.casparcg.com).
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
19 * Author: Robert Nagy, ronag89@gmail.com
\r
24 #include <functional>
\r
27 namespace caspar { namespace core {
\r
30 * A tweener can be used for creating any kind of (image position, image fade
\r
31 * in/out, audio volume etc) transition, by invoking it for each temporal
\r
32 * timepoint when a tweened value is needed.
\r
34 * For video the temporal resolution will usually be each frame or field (for
\r
35 * interlaced material).
\r
37 * For audio the smoothest transitions will be generated by using the samplerate
\r
38 * as temporal resolution, but using the video frame/field rate is probably fine
\r
39 * most of the times and much less time consuming.
\r
47 * @param name The name of the tween function to use.
\r
49 tweener(const std::wstring& name = L"linear");
\r
50 tweener(const wchar_t* name);
\r
53 * @return The possible tween function names. Some of them may also support
\r
54 * additional parameters appended to the name.
\r
56 static const std::vector<std::wstring>& names();
\r
59 * Calculate a tweened value given a timepoint within the total duration
\r
60 * and the starting value and the destination delta value.
\r
62 * Usually b, c and d remains constant during a transition, while t changes
\r
63 * for each temporal tweened value.
\r
65 * @param t The timepoint within the total duration (0 <= n <= d).
\r
66 * @param b The starting value.
\r
67 * @param c The destination value delta from the starting value
\r
68 * (absolute destination value - b).
\r
69 * @param d The total duration (when t = d, the destination value should
\r
70 * have been reached).
\r
72 * @return The tweened value for the given timepoint. Can sometimes be less
\r
73 * than b or greater than b + c for some tweener functions.
\r
75 double operator()(double t, double b , double c, double d) const;
\r
77 std::function<double(double, double, double, double)> func_;
\r