@@ -11,9 +11,8 @@ namespace animation
1111namespace smoothing
1212{
1313/* *
14- * A smooth function is a function which takes a double in [0, 1] and returns
15- * another double in R. Both ranges represent percentage of a progress of
16- * an animation.
14+ * A smooth function is a function which takes a double in [0, 1] and returns another double in R. Both ranges
15+ * represent percentage of a progress of an animation.
1716 */
1817using smooth_function = std::function<double (double )>;
1918
@@ -23,6 +22,8 @@ extern smooth_function linear;
2322extern smooth_function circle;
2423/* * "sigmoid" smoothing function, i.e x -> 1.0 / (1 + exp(-12 * x + 6)) */
2524extern smooth_function sigmoid;
25+ /* * custom cubic-bezier as in CSS */
26+ extern smooth_function get_cubic_bezier (double x1, double y1, double x2, double y2);
2627
2728std::vector<std::string> get_available_smooth_functions ();
2829}
@@ -34,10 +35,7 @@ struct animation_description_t
3435 animation::smoothing::smooth_function easing;
3536 std::string easing_name;
3637
37- bool operator ==(const animation_description_t & other) const
38- {
39- return (length_ms == other.length_ms ) && (easing_name == other.easing_name );
40- }
38+ bool operator ==(const animation_description_t & other) const ;
4139};
4240
4341namespace option_type
@@ -66,15 +64,13 @@ struct transition_t
6664};
6765
6866/* *
69- * duration_t is a class which can be used to track progress over a specific
70- * time interval.
67+ * duration_t is a class which can be used to track progress over a specific time interval.
7168 */
7269class duration_t
7370{
7471 public:
7572 /* *
76- * Construct a new duration.
77- * Initially, the duration is not running and its progress is 1.
73+ * Construct a new duration. Initially, the duration is not running and its progress is 1.
7874 *
7975 * @param length The length of the duration in milliseconds.
8076 * @param smooth The smoothing function for transitions.
@@ -95,40 +91,36 @@ class duration_t
9591 duration_t & operator =(duration_t && other) = default ;
9692
9793 /* *
98- * Start the duration.
99- * This means that the progress will get reset to 0.
94+ * Start the duration. This means that the progress will get reset to 0.
10095 */
10196 void start ();
10297
10398 /* *
104- * Get the progress of the duration in percentage.
105- * The progress will be smoothed using the smoothing function.
99+ * Get the progress of the duration in percentage. The progress will be smoothed using the smoothing
100+ * function.
106101 *
107- * @return The current progress after smoothing. It is guaranteed that when
108- * the duration starts, progress will be close to 0, and when it is
109- * finished, it will be close to 1.
102+ * @return The current progress after smoothing. It is guaranteed that when the duration starts, progress
103+ * will be close to 0, and when it is finished, it will be close to 1.
110104 */
111105 double progress () const ;
112106
113107 /* *
114- * Check if the duration is still running.
115- * Note that even when the duration first finishes, this function will
116- * still return that the function is running one time.
108+ * Check if the duration is still running. Note that even when the duration first finishes, this function
109+ * will still return that the function is running one time.
117110 *
118111 * @return Whether the duration still has not elapsed.
119112 */
120113 bool running ();
121114
122115 /* *
123- * Reverse the duration. The progress will remain the same but the
124- * direction will reverse toward the opposite start or end point.
116+ * Reverse the duration. The progress will remain the same but the direction will reverse toward the
117+ * opposite start or end point.
125118 */
126119 void reverse ();
127120
128121 /* *
129122 * Get duration direction.
130- * 0: reverse
131- * 1: forward
123+ * 0: reverse 1: forward
132124 */
133125 int get_direction ();
134126
@@ -138,17 +130,14 @@ class duration_t
138130};
139131
140132/* *
141- * A timed transition is a transition between two states which happens
142- * over a period of time.
133+ * A timed transition is a transition between two states which happens over a period of time.
143134 *
144- * During the transition, the current state is smoothly interpolated between
145- * start and end.
135+ * During the transition, the current state is smoothly interpolated between start and end.
146136 */
147137struct timed_transition_t : public transition_t
148138{
149139 /* *
150- * Construct a new timed transition using the given duration to measure
151- * progress.
140+ * Construct a new timed transition using the given duration to measure progress.
152141 *
153142 * @duration The duration to use for time measurement
154143 * @start The start state.
@@ -204,14 +193,12 @@ class simple_animation_t : public duration_t, public timed_transition_t
204193 void animate (double start, double end);
205194
206195 /* *
207- * Animate from the current progress to the given end, and start the
208- * duration.
196+ * Animate from the current progress to the given end, and start the duration.
209197 */
210198 void animate (double end);
211199
212200 /* *
213- * Animate from the current progress to the current end, and start the
214- * duration.
201+ * Animate from the current progress to the current end, and start the duration.
215202 */
216203 void animate ();
217204};
0 commit comments