diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 9ac7a98e..2cc1021e 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -125,6 +125,16 @@ Keyframe::Keyframe(double value) { AddPoint(Point(value)); } +// Constructor which takes a vector of Points +Keyframe::Keyframe(const std::vector& points) : Points(points) {}; + +// Constructor which takes a vector of std::pair tuples (and adds them all) +Keyframe::Keyframe(const std::vector>& coordinates) { + for (const auto& pair : coordinates) { + AddPoint(Point(pair.first, pair.second)); + } +} + // Add a new point on the key-frame. Each point has a primary coordinate, // a left handle, and a right handle. void Keyframe::AddPoint(Point p) { diff --git a/src/KeyFrame.h b/src/KeyFrame.h index 560bf259..7245a5d1 100644 --- a/src/KeyFrame.h +++ b/src/KeyFrame.h @@ -68,6 +68,12 @@ namespace openshot { /// Constructor which sets the default point & coordinate at X=1 Keyframe(double value); + /// Constructor which adds a supplied vector of Points + Keyframe(const std::vector& points); + + /// Constructor which takes a vector of std::pair tuples + Keyframe(const std::vector>& 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);