OpenShot Library | libopenshot
0.4.0
|
Go to the documentation of this file.
13 #ifndef OPENSHOT_FRACTION_H
14 #define OPENSHOT_FRACTION_H
48 Fraction(std::map<std::string, int> mapping);
83 return static_cast<numT
>(
ToDouble() * other);
89 return static_cast<numT
>(
ToDouble() / other);
96 return static_cast<numT
>(left * right.
ToDouble());
102 return static_cast<numT
>(left / right.
ToDouble());
106 template<
class charT,
class traits>
107 std::basic_ostream<charT, traits>&
109 std::basic_ostringstream<charT, traits> s;
112 s.precision(o.precision());
113 s <<
"Fraction(" << frac.
num <<
", " << frac.
den <<
")";
float ToFloat()
Return this fraction as a float (i.e. 1/2 = 0.5)
openshot::Fraction operator/(openshot::Fraction other)
Divide a Fraction by another Fraction.
int ToInt()
Return a rounded integer of the fraction (for example 30000/1001 returns 30)
This namespace is the default namespace for all code in the openshot library.
This class represents a fraction.
int GreatestCommonDenominator()
Calculate the greatest common denominator.
numT operator*(const numT &left, const openshot::Fraction &right)
Multiplication in the form (numeric_value * openshot_Fraction)
double ToDouble() const
Return this fraction as a double (i.e. 1/2 = 0.5)
Fraction()
Default Constructor.
int num
Numerator for the fraction.
numT operator/(const numT &left, const openshot::Fraction &right)
Division in the form (numeric_value / openshot_Fraction)
int den
Denominator for the fraction.
void Reduce()
Reduce this fraction (i.e. 640/480 = 4/3)
Fraction Reciprocal() const
Return the reciprocal as a Fraction.
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &o, const openshot::Coordinate &co)
Stream output operator for openshot::Coordinate.
numT operator/(const numT &other) const
Division in the form (openshot_Fraction / numeric_value)
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.