@@ -63,37 +63,12 @@ namespace openshot {
6363 */
6464 class Keyframe {
6565 private:
66- bool needs_update;
67- double FactorialLookup[4 ];
68-
69- /*
70- * Because points can be added in any order, we need to reorder them
71- * in ascending order based on the point.co.X value. This simplifies
72- * processing the curve, due to all the points going from left to right.
73- */
74- void ReorderPoints ();
75-
76- // Process an individual segment
77- void ProcessSegment (int Segment, Point p1, Point p2);
78-
79- // create lookup table for fast factorial calculation
80- void CreateFactorialTable ();
81-
82- // Get a factorial for a coordinate
83- double Factorial (int64_t n);
84-
85- // Calculate the factorial function for Bernstein basis
86- double Ni (int64_t n, int64_t i);
87-
88- // Calculate Bernstein Basis
89- double Bernstein (int64_t n, int64_t i, double t);
66+ std::vector<Point> Points; // /< Vector of all Points
9067
9168 public:
92- std::vector<Point> Points; // /< Vector of all Points
93- std::vector<Coordinate> Values; // /< Vector of all Values (i.e. the processed coordinates from the curve)
9469
9570 // / Default constructor for the Keyframe class
96- Keyframe ();
71+ Keyframe () = default ;
9772
9873 // / Constructor which sets the default point & coordinate at X=1
9974 Keyframe (double value);
@@ -108,68 +83,60 @@ namespace openshot {
10883 void AddPoint (double x, double y, InterpolationType interpolate);
10984
11085 // / Does this keyframe contain a specific point
111- bool Contains (Point p);
86+ bool Contains (Point p) const ;
11287
11388 // / Flip all the points in this openshot::Keyframe (useful for reversing an effect or transition, etc...)
11489 void FlipPoints ();
11590
11691 // / Get the index of a point by matching a coordinate
117- int64_t FindIndex (Point p);
92+ int64_t FindIndex (Point p) const ;
11893
11994 // / Get the value at a specific index
120- double GetValue (int64_t index);
95+ double GetValue (int64_t index) const ;
12196
12297 // / Get the rounded INT value at a specific index
123- int GetInt (int64_t index);
98+ int GetInt (int64_t index) const ;
12499
125100 // / Get the rounded LONG value at a specific index
126- int64_t GetLong (int64_t index);
101+ int64_t GetLong (int64_t index) const ;
127102
128103 // / Get the fraction that represents how many times this value is repeated in the curve
129- Fraction GetRepeatFraction (int64_t index);
104+ Fraction GetRepeatFraction (int64_t index) const ;
130105
131106 // / Get the change in Y value (from the previous Y value)
132- double GetDelta (int64_t index);
107+ double GetDelta (int64_t index) const ;
133108
134109 // / Get a point at a specific index
135- Point& GetPoint (int64_t index);
110+ Point const & GetPoint (int64_t index) const ;
136111
137112 // / Get current point (or closest point to the right) from the X coordinate (i.e. the frame number)
138- Point GetClosestPoint (Point p);
113+ Point GetClosestPoint (Point p) const ;
139114
140115 // / Get current point (or closest point) from the X coordinate (i.e. the frame number)
141116 // / Either use the closest left point, or right point
142- Point GetClosestPoint (Point p, bool useLeft);
117+ Point GetClosestPoint (Point p, bool useLeft) const ;
143118
144119 // / Get previous point (
145- Point GetPreviousPoint (Point p);
120+ Point GetPreviousPoint (Point p) const ;
146121
147122 // / Get max point (by Y coordinate)
148- Point GetMaxPoint ();
123+ Point GetMaxPoint () const ;
149124
150125 // Get the number of values (i.e. coordinates on the X axis)
151- int64_t GetLength ();
126+ int64_t GetLength () const ;
152127
153128 // / Get the number of points (i.e. # of points)
154- int64_t GetCount ();
129+ int64_t GetCount () const ;
155130
156131 // / Get the direction of the curve at a specific index (increasing or decreasing)
157- bool IsIncreasing (int index);
132+ bool IsIncreasing (int index) const ;
158133
159134 // / Get and Set JSON methods
160- std::string Json (); // /< Generate JSON string of this object
161- Json::Value JsonValue (); // /< Generate Json::JsonValue for this object
135+ std::string Json () const ; // /< Generate JSON string of this object
136+ Json::Value JsonValue () const ; // /< Generate Json::JsonValue for this object
162137 void SetJson (std::string value); // /< Load JSON string into this object
163138 void SetJsonValue (Json::Value root); // /< Load Json::JsonValue into this object
164139
165- /* *
166- * @brief Calculate all of the values for this keyframe.
167- *
168- * This clears any existing data in the "values" vector. This method is automatically called
169- * by AddPoint(), so you don't typically need to call this method.
170- */
171- void Process ();
172-
173140 // / Remove a point by matching a coordinate
174141 void RemovePoint (Point p);
175142
@@ -184,10 +151,10 @@ namespace openshot {
184151 void UpdatePoint (int64_t index, Point p);
185152
186153 // / Print a list of points
187- void PrintPoints ();
154+ void PrintPoints () const ;
188155
189156 // / Print just the Y value of the point's primary coordinate
190- void PrintValues ();
157+ void PrintValues () const ;
191158
192159 };
193160
0 commit comments