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