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 (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...
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...
bool | Contains (Point p) const
| Does this keyframe contain a specific point. More...
int64_t | FindIndex (Point p) const
| 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) const
| 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) const
int64_t | GetCount () const
| Get the number of points (i.e. # of points) More...
double | GetDelta (int64_t index) const
| Get the change in Y value (from the previous Y value) More...
int | GetInt (int64_t index) const
| Get the rounded INT value at a specific index. More...
int64_t | GetLength () const
int64_t | GetLong (int64_t index) const
| Get the rounded LONG value at a specific index. More...
Point | GetMaxPoint () const
| Get max point (by Y coordinate) More...
Point const & | GetPoint (int64_t index) const
| Get a point at a specific index. More...
Point | GetPreviousPoint (Point p) const
| Get previous point (. More...
Fraction | GetRepeatFraction (int64_t index) const
| Get the fraction that represents how many times this value is repeated in the curve. More...
double | GetValue (int64_t index) const
| Get the value at a specific index. More...
bool | IsIncreasing (int index) const
| Get the direction of the curve at a specific index (increasing or decreasing) More...
std::string | Json () const
| Get and Set JSON methods. More...
Json::Value | JsonValue () const
| Generate Json::Value for this object. More...
| Keyframe ()=default
| Default constructor for the Keyframe class. More...
| Keyframe (double value)
| Constructor which sets the default point & coordinate at X=1. More...
void | PrintPoints () const
| Print a list of points. More...
void | PrintValues () const
| Print just the Y value of the point's primary coordinate. More...
void | RemovePoint (int64_t index)
| Remove a point by index. More...
void | RemovePoint (Point p)
| Remove a point by matching a coordinate. More...
void | ScalePoints (double scale)
void | SetJson (const std::string value)
| Load JSON string into this object. More...
void | SetJsonValue (const Json::Value root)
| Load Json::Value into this object. More...
void | UpdatePoint (int64_t index, Point p)
| Replace an existing point with a new point. 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:

Keyframe k1;
k1.AddPoint(Point(1,0));
k1.AddPoint(Point(100,640));
kf.PrintValues();
openshot::Keyframe::Keyframe
Keyframe()=default
Default constructor for the Keyframe class.

Definition at line 64 of file KeyFrame.h.

## Constructor & Destructor Documentation

## Keyframe() [1/2]

openshot::Keyframe::Keyframe | ( |  | ) |

default

Default constructor for the Keyframe class.

## Keyframe() [2/2]

Keyframe::Keyframe | ( | double | value | ) |

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

Definition at line 118 of file KeyFrame.cpp.

## Member Function Documentation

## AddPoint() [1/3]

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

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

Definition at line 150 of file KeyFrame.cpp.

## AddPoint() [2/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 160 of file KeyFrame.cpp.

## AddPoint() [3/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 125 of file KeyFrame.cpp.

Referenced by openshot::Color::Color().

## Contains()

bool Keyframe::Contains | ( | Point | p | ) | const

Does this keyframe contain a specific point.

Definition at line 188 of file KeyFrame.cpp.

Referenced by openshot::ClipBase::add_property_json().

## FindIndex()

int64_t Keyframe::FindIndex | ( | Point | p | ) | const

Get the index of a point by matching a coordinate.

Definition at line 170 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 590 of file KeyFrame.cpp.

## GetClosestPoint() [1/2]

Point Keyframe::GetClosestPoint | ( | Point | p | ) | const

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

Definition at line 225 of file KeyFrame.cpp.

Referenced by openshot::ClipBase::add_property_json().

## GetClosestPoint() [2/2]

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

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 195 of file KeyFrame.cpp.

## GetCount()

int64_t Keyframe::GetCount | ( |  | ) | const

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

Definition at line 510 of file KeyFrame.cpp.

Referenced by openshot::ClipBase::add_property_json(), openshot::Clip::End(), and openshot::Timeline::GetFrame().

## GetDelta()

double Keyframe::GetDelta | ( | int64_t | index | ) | const

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

Definition at line 485 of file KeyFrame.cpp.

## GetInt()

int Keyframe::GetInt | ( | int64_t | index | ) | const

Get the rounded INT value at a specific index.

Definition at line 286 of file KeyFrame.cpp.

Referenced by openshot::Color::GetColorHex(), openshot::Clip::GetFrame(), openshot::Blur::GetFrame(), and openshot::ChromaKey::GetFrame().

## GetLength()

int64_t Keyframe::GetLength | ( |  | ) | const

Definition at line 503 of file KeyFrame.cpp.

Referenced by openshot::Clip::End(), and openshot::Clip::GetFrame().

## GetLong()

int64_t Keyframe::GetLong | ( | int64_t | index | ) | const

Get the rounded LONG value at a specific index.

Definition at line 291 of file KeyFrame.cpp.

Referenced by openshot::Clip::GetFrame().

## GetMaxPoint()

Point Keyframe::GetMaxPoint | ( |  | ) | const

Get max point (by Y coordinate)

Definition at line 249 of file KeyFrame.cpp.

## GetPoint()

Point const & Keyframe::GetPoint | ( | int64_t | index | ) | const

Get a point at a specific index.

Definition at line 493 of file KeyFrame.cpp.

## GetPreviousPoint()

Point Keyframe::GetPreviousPoint | ( | Point | p | ) | const

Get previous point (.

Definition at line 230 of file KeyFrame.cpp.

Referenced by openshot::ClipBase::add_property_json().

## GetRepeatFraction()

Fraction Keyframe::GetRepeatFraction | ( | int64_t | index | ) | const

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

Definition at line 382 of file KeyFrame.cpp.

## GetValue()

double Keyframe::GetValue | ( | int64_t | index | ) | const

Get the value at a specific index.

Definition at line 262 of file KeyFrame.cpp.

Referenced by openshot::Timeline::GetFrame(), openshot::Bars::GetFrame(), openshot::Blur::GetFrame(), openshot::Brightness::GetFrame(), openshot::ColorShift::GetFrame(), openshot::Crop::GetFrame(), openshot::Hue::GetFrame(), openshot::Mask::GetFrame(), openshot::Pixelate::GetFrame(), openshot::Saturation::GetFrame(), openshot::Shift::GetFrame(), openshot::Wave::GetFrame(), openshot::Clip::PropertiesJSON(), openshot::Bars::PropertiesJSON(), openshot::Blur::PropertiesJSON(), openshot::Brightness::PropertiesJSON(), openshot::ChromaKey::PropertiesJSON(), openshot::ColorShift::PropertiesJSON(), openshot::Crop::PropertiesJSON(), openshot::Hue::PropertiesJSON(), openshot::Mask::PropertiesJSON(), openshot::Pixelate::PropertiesJSON(), openshot::Saturation::PropertiesJSON(), openshot::Shift::PropertiesJSON(), and openshot::Wave::PropertiesJSON().

## IsIncreasing()

bool Keyframe::IsIncreasing | ( | int | index | ) | const

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

Definition at line 296 of file KeyFrame.cpp.

## Json()

std::string Keyframe::Json | ( |  | ) | const

Get and Set JSON methods.

Generate JSON string of this object

Definition at line 322 of file KeyFrame.cpp.

## JsonValue()

Json::Value Keyframe::JsonValue | ( |  | ) | const

Generate Json::Value for this object.

Definition at line 329 of file KeyFrame.cpp.

Referenced by openshot::Color::JsonValue(), openshot::Clip::JsonValue(), openshot::Bars::JsonValue(), openshot::Blur::JsonValue(), openshot::Brightness::JsonValue(), openshot::ChromaKey::JsonValue(), openshot::ColorShift::JsonValue(), openshot::Crop::JsonValue(), openshot::Hue::JsonValue(), openshot::Mask::JsonValue(), openshot::Pixelate::JsonValue(), openshot::Saturation::JsonValue(), openshot::Shift::JsonValue(), openshot::Wave::JsonValue(), and openshot::Timeline::JsonValue().

## PrintPoints()

void Keyframe::PrintPoints | ( |  | ) | const

Print a list of points.

Definition at line 555 of file KeyFrame.cpp.

## PrintValues()

void Keyframe::PrintValues | ( |  | ) | const

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

Definition at line 563 of file KeyFrame.cpp.

## RemovePoint() [1/2]

void Keyframe::RemovePoint | ( | int64_t | index | ) |

Remove a point by index.

Definition at line 535 of file KeyFrame.cpp.

## RemovePoint() [2/2]

void Keyframe::RemovePoint | ( | Point | p | ) |

Remove a point by matching a coordinate.

Definition at line 516 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 576 of file KeyFrame.cpp.

## SetJson()

void Keyframe::SetJson | ( | const std::string | value | ) |

Load JSON string into this object.

Definition at line 345 of file KeyFrame.cpp.

## SetJsonValue()

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

Load Json::Value into this object.

Definition at line 362 of file KeyFrame.cpp.

Referenced by openshot::Clip::SetJsonValue(), openshot::Color::SetJsonValue(), openshot::Bars::SetJsonValue(), openshot::Blur::SetJsonValue(), openshot::Brightness::SetJsonValue(), openshot::ChromaKey::SetJsonValue(), openshot::ColorShift::SetJsonValue(), openshot::Crop::SetJsonValue(), openshot::Hue::SetJsonValue(), openshot::Mask::SetJsonValue(), openshot::Pixelate::SetJsonValue(), openshot::Saturation::SetJsonValue(), openshot::Shift::SetJsonValue(), and openshot::Wave::SetJsonValue().

## UpdatePoint()

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

Replace an existing point with a new point.

Definition at line 547 of file KeyFrame.cpp.

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

- KeyFrame.h
- KeyFrame.cpp