OpenShot Library | libopenshot  0.1.9
Public Member Functions | Public Attributes | List of all members
openshot::Keyframe Class Reference

A Keyframe is a collection of Point instances, which is used to vary a number or property over time. More...

#include <KeyFrame.h>

Public Member Functions

void AddPoint (Point p)
 Add a new point on the key-frame. Each point has a primary coordinate, a left handle, and a right handle. More...
 
void AddPoint (double x, double y)
 Add a new point on the key-frame, with some defaults set (BEZIER) More...
 
void AddPoint (double x, double y, InterpolationType interpolate)
 Add a new point on the key-frame, with a specific interpolation type. More...
 
bool Contains (Point p)
 Does this keyframe contain a specific point. More...
 
int64_t FindIndex (Point p)
 Get the index of a point by matching a coordinate. More...
 
void FlipPoints ()
 Flip all the points in this openshot::Keyframe (useful for reversing an effect or transition, etc...) More...
 
Point GetClosestPoint (Point p)
 Get current point (or closest point to the right) from the X coordinate (i.e. the frame number) More...
 
Point GetClosestPoint (Point p, bool useLeft)
 
int64_t GetCount ()
 Get the number of points (i.e. # of points) More...
 
double GetDelta (int64_t index)
 Get the change in Y value (from the previous Y value) More...
 
int GetInt (int64_t index)
 Get the rounded INT value at a specific index. More...
 
int64_t GetLength ()
 
int64_t GetLong (int64_t index)
 Get the rounded LONG value at a specific index. More...
 
Point GetMaxPoint ()
 Get max point (by Y coordinate) More...
 
PointGetPoint (int64_t index)
 Get a point at a specific index. More...
 
Point GetPreviousPoint (Point p)
 Get previous point (. More...
 
Fraction GetRepeatFraction (int64_t index)
 Get the fraction that represents how many times this value is repeated in the curve. More...
 
double GetValue (int64_t index)
 Get the value at a specific index. More...
 
bool IsIncreasing (int index)
 Get the direction of the curve at a specific index (increasing or decreasing) More...
 
string Json ()
 Get and Set JSON methods. More...
 
Json::Value JsonValue ()
 Generate Json::JsonValue for this object. More...
 
 Keyframe ()
 Default constructor for the Keyframe class. More...
 
 Keyframe (double value)
 Constructor which sets the default point & coordinate at X=0. More...
 
void PrintPoints ()
 Print a list of points. More...
 
void PrintValues ()
 Print just the Y value of the point's primary coordinate. More...
 
void Process ()
 Calculate all of the values for this keyframe. More...
 
void RemovePoint (Point p)
 Remove a point by matching a coordinate. More...
 
void RemovePoint (int64_t index)
 Remove a point by index. More...
 
void ScalePoints (double scale)
 
void SetJson (string value)
 Load JSON string into this object. More...
 
void SetJsonValue (Json::Value root)
 Load Json::JsonValue into this object. More...
 
void UpdatePoint (int64_t index, Point p)
 Replace an existing point with a new point. More...
 

Public Attributes

vector< PointPoints
 Vector of all Points. More...
 
vector< CoordinateValues
 Vector of all Values (i.e. the processed coordinates from the curve) More...
 

Detailed Description

A Keyframe is a collection of Point instances, which is used to vary a number or property over time.

Keyframes are used to animate and interpolate values of properties over time. For example, a single property can use a Keyframe instead of a constant value. Assume you want to slide an image (from left to right) over a video. You can create a Keyframe which will adjust the X value of the image over 100 frames (or however many frames the animation needs to last) from the value of 0 to 640.

Please see the following Example Code:

k1.AddPoint(Point(1,0));
k1.AddPoint(Point(100,640));
kf.PrintValues();

Definition at line 64 of file KeyFrame.h.

Constructor & Destructor Documentation

◆ Keyframe() [1/2]

Keyframe::Keyframe ( )

Default constructor for the Keyframe class.

Definition at line 65 of file KeyFrame.cpp.

◆ Keyframe() [2/2]

Keyframe::Keyframe ( double  value)

Constructor which sets the default point & coordinate at X=0.

Definition at line 56 of file KeyFrame.cpp.

Member Function Documentation

◆ AddPoint() [1/3]

void Keyframe::AddPoint ( Point  p)

Add a new point on the key-frame. Each point has a primary coordinate, a left handle, and a right handle.

Definition at line 72 of file KeyFrame.cpp.

◆ AddPoint() [2/3]

void Keyframe::AddPoint ( double  x,
double  y 
)

Add a new point on the key-frame, with some defaults set (BEZIER)

Definition at line 90 of file KeyFrame.cpp.

◆ AddPoint() [3/3]

void Keyframe::AddPoint ( double  x,
double  y,
InterpolationType  interpolate 
)

Add a new point on the key-frame, with a specific interpolation type.

Definition at line 100 of file KeyFrame.cpp.

◆ Contains()

bool Keyframe::Contains ( Point  p)

Does this keyframe contain a specific point.

Definition at line 128 of file KeyFrame.cpp.

◆ FindIndex()

int64_t Keyframe::FindIndex ( Point  p)

Get the index of a point by matching a coordinate.

Definition at line 110 of file KeyFrame.cpp.

◆ FlipPoints()

void Keyframe::FlipPoints ( )

Flip all the points in this openshot::Keyframe (useful for reversing an effect or transition, etc...)

Definition at line 875 of file KeyFrame.cpp.

◆ GetClosestPoint() [1/2]

Point Keyframe::GetClosestPoint ( Point  p)

Get current point (or closest point to the right) from the X coordinate (i.e. the frame number)

Definition at line 183 of file KeyFrame.cpp.

◆ GetClosestPoint() [2/2]

Point Keyframe::GetClosestPoint ( Point  p,
bool  useLeft 
)

Get current point (or closest point) from the X coordinate (i.e. the frame number) Either use the closest left point, or right point

Definition at line 146 of file KeyFrame.cpp.

◆ GetCount()

int64_t Keyframe::GetCount ( )

Get the number of points (i.e. # of points)

Definition at line 452 of file KeyFrame.cpp.

◆ GetDelta()

double Keyframe::GetDelta ( int64_t  index)

Get the change in Y value (from the previous Y value)

Definition at line 410 of file KeyFrame.cpp.

◆ GetInt()

int Keyframe::GetInt ( int64_t  index)

Get the rounded INT value at a specific index.

Definition at line 248 of file KeyFrame.cpp.

◆ GetLength()

int64_t Keyframe::GetLength ( )

Definition at line 442 of file KeyFrame.cpp.

◆ GetLong()

int64_t Keyframe::GetLong ( int64_t  index)

Get the rounded LONG value at a specific index.

Definition at line 270 of file KeyFrame.cpp.

◆ GetMaxPoint()

Point Keyframe::GetMaxPoint ( )

Get max point (by Y coordinate)

Definition at line 207 of file KeyFrame.cpp.

◆ GetPoint()

Point & Keyframe::GetPoint ( int64_t  index)

Get a point at a specific index.

Definition at line 432 of file KeyFrame.cpp.

◆ GetPreviousPoint()

Point Keyframe::GetPreviousPoint ( Point  p)

Get previous point (.

Definition at line 188 of file KeyFrame.cpp.

◆ GetRepeatFraction()

Fraction Keyframe::GetRepeatFraction ( int64_t  index)

Get the fraction that represents how many times this value is repeated in the curve.

Definition at line 388 of file KeyFrame.cpp.

◆ GetValue()

double Keyframe::GetValue ( int64_t  index)

Get the value at a specific index.

Definition at line 226 of file KeyFrame.cpp.

◆ IsIncreasing()

bool Keyframe::IsIncreasing ( int  index)

Get the direction of the curve at a specific index (increasing or decreasing)

Definition at line 292 of file KeyFrame.cpp.

◆ Json()

string Keyframe::Json ( )

Get and Set JSON methods.

Generate JSON string of this object

Definition at line 314 of file KeyFrame.cpp.

◆ JsonValue()

Json::Value Keyframe::JsonValue ( )

Generate Json::JsonValue for this object.

Definition at line 321 of file KeyFrame.cpp.

◆ PrintPoints()

void Keyframe::PrintPoints ( )

Print a list of points.

Definition at line 510 of file KeyFrame.cpp.

◆ PrintValues()

void Keyframe::PrintValues ( )

Print just the Y value of the point's primary coordinate.

Definition at line 522 of file KeyFrame.cpp.

◆ Process()

void Keyframe::Process ( )

Calculate all of the values for this keyframe.

This clears any existing data in the "values" vector. This method is automatically called by AddPoint(), so you don't typically need to call this method.

Definition at line 536 of file KeyFrame.cpp.

◆ RemovePoint() [1/2]

void Keyframe::RemovePoint ( Point  p)

Remove a point by matching a coordinate.

Definition at line 459 of file KeyFrame.cpp.

◆ RemovePoint() [2/2]

void Keyframe::RemovePoint ( int64_t  index)

Remove a point by index.

Definition at line 481 of file KeyFrame.cpp.

◆ ScalePoints()

void Keyframe::ScalePoints ( double  scale)

Scale all points by a percentage (good for evenly lengthening or shortening an openshot::Keyframe) 1.0 = same size, 1.05 = 5% increase, etc...

Definition at line 858 of file KeyFrame.cpp.

◆ SetJson()

void Keyframe::SetJson ( string  value)

Load JSON string into this object.

Definition at line 339 of file KeyFrame.cpp.

◆ SetJsonValue()

void Keyframe::SetJsonValue ( Json::Value  root)

Load Json::JsonValue into this object.

Definition at line 362 of file KeyFrame.cpp.

◆ UpdatePoint()

void Keyframe::UpdatePoint ( int64_t  index,
Point  p 
)

Replace an existing point with a new point.

Definition at line 496 of file KeyFrame.cpp.

Member Data Documentation

◆ Points

vector<Point> openshot::Keyframe::Points

Vector of all Points.

Definition at line 92 of file KeyFrame.h.

◆ Values

vector<Coordinate> openshot::Keyframe::Values

Vector of all Values (i.e. the processed coordinates from the curve)

Definition at line 93 of file KeyFrame.h.


The documentation for this class was generated from the following files: