|
OpenShot Library | libopenshot 0.5.0
|
This class represents a fraction. More...
#include <Fraction.h>
Public Member Functions | |
| Fraction () | |
| Default Constructor. | |
| Fraction (int num, int den) | |
| Constructor with numerator and denominator. | |
| Fraction (std::map< std::string, int > mapping) | |
| Constructor that takes a key-value mapping (keys: 'num'. 'den'). | |
| Fraction (std::pair< int, int > pair) | |
| Constructor that accepts a (num, den) pair. | |
| Fraction (std::vector< int > vector) | |
| Constructor that takes a vector of length 2 (containing {num, den}). | |
| int | GreatestCommonDenominator () |
| Calculate the greatest common denominator. | |
| template<class numT> | |
| numT | operator* (const numT &other) const |
| Multiplication in the form (openshot_Fraction * numeric_value). | |
| openshot::Fraction | operator* (openshot::Fraction other) |
| Multiply two Fraction objects together. | |
| template<class numT> | |
| numT | operator/ (const numT &other) const |
| Division in the form (openshot_Fraction / numeric_value). | |
| openshot::Fraction | operator/ (openshot::Fraction other) |
| Divide a Fraction by another Fraction. | |
| Fraction | Reciprocal () const |
| Return the reciprocal as a Fraction. | |
| void | Reduce () |
| Reduce this fraction (i.e. 640/480 = 4/3). | |
| double | ToDouble () const |
| Return this fraction as a double (i.e. 1/2 = 0.5). | |
| float | ToFloat () |
| Return this fraction as a float (i.e. 1/2 = 0.5). | |
| int | ToInt () |
| Return a rounded integer of the fraction (for example 30000/1001 returns 30). | |
Public Attributes | |
| int | den |
| Denominator for the fraction. | |
| int | num |
| Numerator for the fraction. | |
This class represents a fraction.
Fractions are often used in video editing to represent ratios and rates, for example: pixel ratios, frames per second, timebase, and other common ratios. Fractions are preferred over decimals due to their increased precision.
Definition at line 30 of file Fraction.h.
| Fraction::Fraction | ( | ) |
Default Constructor.
Definition at line 19 of file Fraction.cpp.
Referenced by Fraction(), Fraction(), Fraction(), Fraction(), and Reciprocal().
| Fraction::Fraction | ( | int | num, |
| int | den ) |
Constructor with numerator and denominator.
Definition at line 31 of file Fraction.cpp.
| Fraction::Fraction | ( | std::pair< int, int > | pair | ) |
Constructor that accepts a (num, den) pair.
Definition at line 21 of file Fraction.cpp.
| Fraction::Fraction | ( | std::vector< int > | vector | ) |
Constructor that takes a vector of length 2 (containing {num, den}).
Definition at line 27 of file Fraction.cpp.
| Fraction::Fraction | ( | std::map< std::string, int > | mapping | ) |
Constructor that takes a key-value mapping (keys: 'num'. 'den').
Definition at line 24 of file Fraction.cpp.
| int Fraction::GreatestCommonDenominator | ( | ) |
Calculate the greatest common denominator.
Definition at line 50 of file Fraction.cpp.
Referenced by Reduce().
|
inline |
Multiplication in the form (openshot_Fraction * numeric_value).
Definition at line 82 of file Fraction.h.
|
inline |
Multiply two Fraction objects together.
Definition at line 71 of file Fraction.h.
|
inline |
Division in the form (openshot_Fraction / numeric_value).
Definition at line 88 of file Fraction.h.
|
inline |
Divide a Fraction by another Fraction.
Definition at line 76 of file Fraction.h.
| Fraction Fraction::Reciprocal | ( | ) | const |
Return the reciprocal as a Fraction.
Definition at line 78 of file Fraction.cpp.
Referenced by openshot::TrackedObjectBBox::FrameNToTime(), openshot::Frame::GetSamplesPerFrame(), operator/(), openshot::ImageWriter::SetVideoOptions(), and openshot::Timeline::Timeline().
| void Fraction::Reduce | ( | ) |
Reduce this fraction (i.e. 640/480 = 4/3).
Definition at line 65 of file Fraction.cpp.
Referenced by openshot::ImageReader::Open(), openshot::QtHtmlReader::Open(), openshot::QtImageReader::Open(), openshot::QtTextReader::Open(), openshot::FFmpegWriter::SetVideoOptions(), and openshot::ImageWriter::SetVideoOptions().
| double Fraction::ToDouble | ( | ) | const |
Return this fraction as a double (i.e. 1/2 = 0.5).
Definition at line 40 of file Fraction.cpp.
Referenced by openshot::AudioWaveformer::ApplyKeyframes(), openshot::TrackedObjectBBox::FrameNToTime(), openshot::Caption::GetFrame(), openshot::Frame::GetSamplesPerFrame(), operator*(), openshot::operator*(), operator/(), openshot::operator/(), openshot::Profile::operator<, and openshot::Profile::operator>.
| float Fraction::ToFloat | ( | ) |
Return this fraction as a float (i.e. 1/2 = 0.5).
Definition at line 35 of file Fraction.cpp.
Referenced by VideoRenderWidget::centeredViewport(), and openshot::Caption::GetFrame().
| int Fraction::ToInt | ( | ) |
Return a rounded integer of the fraction (for example 30000/1001 returns 30).
Definition at line 45 of file Fraction.cpp.
| int openshot::Fraction::den |
Denominator for the fraction.
Definition at line 33 of file Fraction.h.
Referenced by openshot::FrameMapper::ChangeMapping(), openshot::WriterBase::CopyReaderInfo(), openshot::Frame::DeepCopy(), Fraction(), GreatestCommonDenominator(), openshot::QtHtmlReader::Open(), openshot::QtImageReader::Open(), openshot::QtTextReader::Open(), operator*(), openshot::Profile::operator==, Reciprocal(), Reduce(), openshot::FFmpegWriter::SetVideoOptions(), openshot::ImageWriter::SetVideoOptions(), ToDouble(), ToFloat(), and ToInt().
| int openshot::Fraction::num |
Numerator for the fraction.
Definition at line 32 of file Fraction.h.
Referenced by openshot::FrameMapper::ChangeMapping(), openshot::WriterBase::CopyReaderInfo(), openshot::Frame::DeepCopy(), Fraction(), GreatestCommonDenominator(), openshot::QtHtmlReader::Open(), openshot::QtImageReader::Open(), openshot::QtTextReader::Open(), operator*(), openshot::Profile::operator==, Reciprocal(), Reduce(), openshot::FFmpegWriter::SetVideoOptions(), openshot::ImageWriter::SetVideoOptions(), ToDouble(), ToFloat(), and ToInt().