13#ifndef OPENSHOT_KEYFRAME_H
14#define OPENSHOT_KEYFRAME_H
31 double InterpolateBezierCurve(Point
const & left, Point
const & right,
double const target,
double const allowed_error);
34 double InterpolateBetween(Point
const & left, Point
const & right,
double target,
double allowed_error);
57 std::vector<Point> Points;
67 Keyframe(
const std::vector<openshot::Point>& points);
88 double GetValue(int64_t index)
const;
91 int GetInt(int64_t index)
const;
94 int64_t
GetLong(int64_t index)
const;
97 double GetDelta(int64_t index)
const;
125 std::string
Json()
const;
127 void SetJson(
const std::string value);
144 void PrintPoints(std::ostream* out=&std::cout)
const;
147 void PrintValues(std::ostream* out=&std::cout)
const;
Header file for JSON class.
Header file for Point class.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
int64_t FindIndex(Point p) const
Get the index of a point by matching a coordinate.
void RemovePoint(Point p)
Remove a point by matching a coordinate.
void SetJson(const std::string value)
Load JSON string into this object.
bool Contains(Point p) const
Does this keyframe contain a specific point.
void PrintValues(std::ostream *out=&std::cout) const
Print just the Y value of the point's primary coordinate.
Point GetMaxPoint() const
Get max point (by Y coordinate)
int GetInt(int64_t index) const
Get the rounded INT value at a specific index.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
void AddPoint(Point p)
Add a new point on the key-frame. Each point has a primary coordinate, a left handle,...
double GetDelta(int64_t index) const
Get the change in Y value (from the previous Y value)
Point const & GetPoint(int64_t index) const
Get a point at a specific index.
int64_t GetLength() const
void PrintPoints(std::ostream *out=&std::cout) const
Print a list of points.
Point GetPreviousPoint(Point p) const
Get previous point (.
int64_t GetLong(int64_t index) const
Get the rounded LONG value at a specific index.
void UpdatePoint(int64_t index, Point p)
Replace an existing point with a new point.
void ScalePoints(double scale)
std::string Json() const
Generate JSON string of this object.
double GetValue(int64_t index) const
Get the value at a specific index.
Json::Value JsonValue() const
Generate Json::Value for this object.
void FlipPoints()
Flip all the points in this openshot::Keyframe (useful for reversing an effect or transition,...
Keyframe()=default
Default constructor for the Keyframe class.
bool IsIncreasing(int index) const
Get the direction of the curve at a specific index (increasing or decreasing)
int64_t GetCount() const
Get the number of points (i.e. # of points)
Point GetClosestPoint(Point p) const
Get current point (or closest point to the right) from the X coordinate (i.e. the frame number)
A Point is the basic building block of a key-frame curve.
This namespace is the default namespace for all code in the openshot library.
double InterpolateLinearCurve(Point const &left, Point const &right, double const target)
Linear interpolation between two points.
double InterpolateBezierCurve(Point const &left, Point const &right, double const target, double const allowed_error)
Bezier interpolation between two points.
bool IsPointBeforeX(Point const &p, double const x)
Check if the X coordinate of a given Point is lower than a given value.
double InterpolateBetween(Point const &left, Point const &right, double target, double allowed_error)
Interpolate two points using the right Point's interpolation method.
InterpolationType
This controls how a Keyframe uses this point to interpolate between two points.
@ BEZIER
Bezier curves are quadratic curves, which create a smooth curve.