Skip to content

Commit

Permalink
Keyframe: Replace pair vector w/ CoordinateVector
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Dec 4, 2020
1 parent b280fbd commit deae5b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/KeyFrame.cpp
Expand Up @@ -129,9 +129,9 @@ Keyframe::Keyframe(double value) {
Keyframe::Keyframe(const std::vector<Point>& points) : Points(points) {};

// Constructor which takes a vector of std::pair tuples (and adds them all)
Keyframe::Keyframe(const std::vector<std::pair<double, double>>& coordinates) {
for (const auto& pair : coordinates) {
AddPoint(Point(pair.first, pair.second));
Keyframe::Keyframe(const std::vector<Coordinate>& coordinates) {
for (const auto& co : coordinates) {
AddPoint(Point(co));
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/KeyFrame.h
Expand Up @@ -61,6 +61,8 @@ namespace openshot {
std::vector<Point> Points; ///< Vector of all Points

public:
using CoordinateVector = std::vector<Coordinate>;
using PointsVector = std::vector<Point>;

/// Default constructor for the Keyframe class
Keyframe() = default;
Expand All @@ -69,10 +71,10 @@ namespace openshot {
Keyframe(double value);

/// Constructor which adds a supplied vector of Points
Keyframe(const std::vector<Point>& points);
Keyframe(const PointsVector& points);

/// Constructor which takes a vector of std::pair tuples
Keyframe(const std::vector<std::pair<double, double>>& coordinates);
Keyframe(const CoordinateVector& coordinates);

/// Add a new point on the key-frame. Each point has a primary coordinate, a left handle, and a right handle.
void AddPoint(Point p);
Expand Down
6 changes: 3 additions & 3 deletions tests/KeyFrame_Tests.cpp
Expand Up @@ -506,10 +506,10 @@ TEST(Point_Vector_Constructor)
CHECK_CLOSE(30.0f, k1.GetValue(10), 0.0001);
}

TEST(Pair_Vector_Constructor)
TEST(Coordinate_Vector_Constructor)
{
std::vector<std::pair<double,double>> coordinates{
{1, 100}, {10, 500}, {1000, 80000}
std::vector<Coordinate> coordinates{
Coordinate(1, 100), Coordinate(10, 500), Coordinate(1000, 80000)
};
Keyframe k1(coordinates);

Expand Down

0 comments on commit deae5b2

Please sign in to comment.