OpenShot Library | libopenshot
0.2.6
|
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, InterpolationType interpolate=BEZIER) |
Add a new point on the key-frame, with optional interpolation type. 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 |
Generate JSON string of this object. 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... | |
Keyframe (const std::vector< openshot::Point > &points) | |
Constructor which adds a supplied vector of Points. 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 (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 (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... | |
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:
Definition at line 72 of file KeyFrame.h.
|
default |
Default constructor for the Keyframe class.
Keyframe::Keyframe | ( | double | value | ) |
Constructor which sets the default point & coordinate at X=1.
Definition at line 131 of file KeyFrame.cpp.
Keyframe::Keyframe | ( | const std::vector< openshot::Point > & | points | ) |
Constructor which adds a supplied vector of Points.
Definition at line 137 of file KeyFrame.cpp.
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 141 of file KeyFrame.cpp.
Referenced by AddPoint(), openshot::Color::Color(), SetJsonValue(), and UpdatePoint().
void Keyframe::AddPoint | ( | double | x, |
double | y, | ||
InterpolationType | interpolate = BEZIER |
||
) |
Add a new point on the key-frame, with optional interpolation type.
Definition at line 166 of file KeyFrame.cpp.
bool Keyframe::Contains | ( | Point | p | ) | const |
Does this keyframe contain a specific point.
Definition at line 194 of file KeyFrame.cpp.
Referenced by openshot::ClipBase::add_property_json(), and openshot::TrackedObjectBBox::add_property_json().
int64_t Keyframe::FindIndex | ( | Point | p | ) | const |
Get the index of a point by matching a coordinate.
Definition at line 176 of file KeyFrame.cpp.
Referenced by GetPreviousPoint().
void Keyframe::FlipPoints | ( | ) |
Flip all the points in this openshot::Keyframe (useful for reversing an effect or transition, etc...)
Definition at line 597 of file KeyFrame.cpp.
Get current point (or closest point to the right) from the X coordinate (i.e. the frame number)
Definition at line 231 of file KeyFrame.cpp.
Referenced by openshot::ClipBase::add_property_json(), and openshot::TrackedObjectBBox::add_property_json().
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 201 of file KeyFrame.cpp.
int64_t Keyframe::GetCount | ( | ) | const |
Get the number of points (i.e. # of points)
Definition at line 516 of file KeyFrame.cpp.
Referenced by openshot::ClipBase::add_property_json(), openshot::TrackedObjectBBox::add_property_json(), openshot::Clip::End(), openshot::Timeline::GetFrame(), and openshot::Clip::init_reader_rotation().
double Keyframe::GetDelta | ( | int64_t | index | ) | const |
Get the change in Y value (from the previous Y value)
Definition at line 491 of file KeyFrame.cpp.
Referenced by openshot::Clip::GetEffect(), and PrintValues().
int Keyframe::GetInt | ( | int64_t | index | ) | const |
Get the rounded INT value at a specific index.
Definition at line 292 of file KeyFrame.cpp.
Referenced by openshot::Timeline::apply_effects(), openshot::Color::GetColorHex(), openshot::Color::GetColorRGBA(), openshot::ChromaKey::GetFrame(), openshot::Blur::GetFrame(), and openshot::Clip::RemoveEffect().
int64_t Keyframe::GetLength | ( | ) | const |
Definition at line 509 of file KeyFrame.cpp.
Referenced by openshot::Clip::End(), GetDelta(), openshot::Clip::GetEffect(), openshot::Clip::GetFrame(), GetRepeatFraction(), IsIncreasing(), and PrintValues().
int64_t Keyframe::GetLong | ( | int64_t | index | ) | const |
Get the rounded LONG value at a specific index.
Definition at line 297 of file KeyFrame.cpp.
Referenced by GetDelta(), openshot::Clip::GetFrame(), GetRepeatFraction(), and IsIncreasing().
Point Keyframe::GetMaxPoint | ( | ) | const |
Get max point (by Y coordinate)
Definition at line 255 of file KeyFrame.cpp.
Referenced by openshot::QtImageReader::GetFrame(), and openshot::FFmpegReader::GetFrame().
Point const & Keyframe::GetPoint | ( | int64_t | index | ) | const |
Get a point at a specific index.
Definition at line 499 of file KeyFrame.cpp.
Get previous point (.
Definition at line 236 of file KeyFrame.cpp.
Referenced by openshot::ClipBase::add_property_json(), and openshot::TrackedObjectBBox::add_property_json().
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 388 of file KeyFrame.cpp.
Referenced by openshot::Clip::GetEffect(), and PrintValues().
double Keyframe::GetValue | ( | int64_t | index | ) | const |
Get the value at a specific index.
Definition at line 268 of file KeyFrame.cpp.
Referenced by openshot::Timeline::apply_effects(), openshot::TrackedObjectBBox::GetBox(), openshot::TrackedObjectBBox::GetBoxValues(), openshot::Hue::GetFrame(), openshot::Brightness::GetFrame(), openshot::Noise::GetFrame(), openshot::Shift::GetFrame(), openshot::Distortion::GetFrame(), openshot::Delay::GetFrame(), openshot::Echo::GetFrame(), openshot::Bars::GetFrame(), openshot::Wave::GetFrame(), openshot::Crop::GetFrame(), openshot::Mask::GetFrame(), openshot::Saturation::GetFrame(), openshot::Blur::GetFrame(), openshot::ColorShift::GetFrame(), openshot::Expander::GetFrame(), openshot::Compressor::GetFrame(), openshot::Stabilizer::GetFrame(), openshot::Caption::GetFrame(), openshot::Timeline::GetFrame(), GetInt(), GetLong(), openshot::TrackedObjectBBox::GetParentClipProperties(), openshot::Pixelate::Pixelate(), PrintValues(), openshot::Hue::PropertiesJSON(), openshot::Brightness::PropertiesJSON(), openshot::Noise::PropertiesJSON(), openshot::Shift::PropertiesJSON(), openshot::ChromaKey::PropertiesJSON(), openshot::Distortion::PropertiesJSON(), openshot::Pixelate::PropertiesJSON(), openshot::Delay::PropertiesJSON(), openshot::ParametricEQ::PropertiesJSON(), openshot::Wave::PropertiesJSON(), openshot::Bars::PropertiesJSON(), openshot::Echo::PropertiesJSON(), openshot::Crop::PropertiesJSON(), openshot::Mask::PropertiesJSON(), openshot::Blur::PropertiesJSON(), openshot::Saturation::PropertiesJSON(), openshot::ColorShift::PropertiesJSON(), openshot::Compressor::PropertiesJSON(), openshot::Expander::PropertiesJSON(), openshot::Caption::PropertiesJSON(), openshot::Stabilizer::PropertiesJSON(), openshot::TrackedObjectBBox::PropertiesJSON(), openshot::Clip::PropertiesJSON(), openshot::Clip::RemoveEffect(), openshot::Distortion::updateFilters(), and openshot::ParametricEQ::updateFilters().
bool Keyframe::IsIncreasing | ( | int | index | ) | const |
Get the direction of the curve at a specific index (increasing or decreasing)
Definition at line 302 of file KeyFrame.cpp.
Referenced by openshot::Clip::GetEffect(), and PrintValues().
std::string Keyframe::Json | ( | ) | const |
Generate JSON string of this object.
Definition at line 328 of file KeyFrame.cpp.
Json::Value Keyframe::JsonValue | ( | ) | const |
Generate Json::Value for this object.
Definition at line 335 of file KeyFrame.cpp.
Referenced by Json(), openshot::Color::JsonValue(), openshot::Hue::JsonValue(), openshot::Noise::JsonValue(), openshot::Brightness::JsonValue(), openshot::Shift::JsonValue(), openshot::ChromaKey::JsonValue(), openshot::Distortion::JsonValue(), openshot::Pixelate::JsonValue(), openshot::Delay::JsonValue(), openshot::ParametricEQ::JsonValue(), openshot::Echo::JsonValue(), openshot::Crop::JsonValue(), openshot::Bars::JsonValue(), openshot::Wave::JsonValue(), openshot::Mask::JsonValue(), openshot::Saturation::JsonValue(), openshot::Blur::JsonValue(), openshot::ColorShift::JsonValue(), openshot::Compressor::JsonValue(), openshot::Expander::JsonValue(), openshot::Stabilizer::JsonValue(), openshot::Caption::JsonValue(), openshot::TrackedObjectBBox::JsonValue(), openshot::Clip::JsonValue(), and openshot::Timeline::JsonValue().
void Keyframe::PrintPoints | ( | ) | const |
Print a list of points.
Definition at line 562 of file KeyFrame.cpp.
void Keyframe::PrintValues | ( | ) | const |
Print just the Y value of the point's primary coordinate.
Definition at line 570 of file KeyFrame.cpp.
void Keyframe::RemovePoint | ( | Point | p | ) |
Remove a point by matching a coordinate.
Definition at line 522 of file KeyFrame.cpp.
Referenced by UpdatePoint().
void Keyframe::RemovePoint | ( | int64_t | index | ) |
Remove a point by index.
Definition at line 541 of file KeyFrame.cpp.
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 583 of file KeyFrame.cpp.
void Keyframe::SetJson | ( | const std::string | value | ) |
Load JSON string into this object.
Definition at line 351 of file KeyFrame.cpp.
void Keyframe::SetJsonValue | ( | const Json::Value | root | ) |
Load Json::Value into this object.
Definition at line 368 of file KeyFrame.cpp.
Referenced by openshot::Timeline::ApplyJsonDiff(), SetJson(), openshot::Color::SetJsonValue(), openshot::Hue::SetJsonValue(), openshot::Noise::SetJsonValue(), openshot::Brightness::SetJsonValue(), openshot::Shift::SetJsonValue(), openshot::ChromaKey::SetJsonValue(), openshot::Distortion::SetJsonValue(), openshot::Pixelate::SetJsonValue(), openshot::Delay::SetJsonValue(), openshot::ParametricEQ::SetJsonValue(), openshot::Echo::SetJsonValue(), openshot::Crop::SetJsonValue(), openshot::Bars::SetJsonValue(), openshot::Wave::SetJsonValue(), openshot::Mask::SetJsonValue(), openshot::Saturation::SetJsonValue(), openshot::Blur::SetJsonValue(), openshot::ColorShift::SetJsonValue(), openshot::Compressor::SetJsonValue(), openshot::Expander::SetJsonValue(), openshot::Caption::SetJsonValue(), openshot::Stabilizer::SetJsonValue(), openshot::TrackedObjectBBox::SetJsonValue(), and openshot::Clip::SetJsonValue().
void Keyframe::UpdatePoint | ( | int64_t | index, |
Point | p | ||
) |
Replace an existing point with a new point.
Definition at line 554 of file KeyFrame.cpp.