You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Fraction.h: Fix indentation
This commit is contained in:
@@ -38,62 +38,63 @@
|
||||
|
||||
namespace openshot {
|
||||
|
||||
/**
|
||||
* @brief 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.
|
||||
*/
|
||||
class Fraction {
|
||||
public:
|
||||
int num; ///<Numerator for the fraction
|
||||
int den; ///<Denominator for the fraction
|
||||
/**
|
||||
* @brief 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.
|
||||
*/
|
||||
class Fraction {
|
||||
public:
|
||||
int num; ///<Numerator for the fraction
|
||||
int den; ///<Denominator for the fraction
|
||||
|
||||
/// Default Constructor
|
||||
Fraction();
|
||||
/// Default Constructor
|
||||
Fraction();
|
||||
|
||||
/// Constructor with numerator and denominator
|
||||
Fraction(int num, int den);
|
||||
/// Constructor with numerator and denominator
|
||||
Fraction(int num, int den);
|
||||
|
||||
/// Constructor that accepts a (num, den) pair
|
||||
Fraction(std::pair<int, int> pair);
|
||||
/// Constructor that accepts a (num, den) pair
|
||||
Fraction(std::pair<int, int> pair);
|
||||
|
||||
/// Constructor that takes a vector of length 2 (containing {num, den})
|
||||
Fraction(std::vector<int> vector);
|
||||
/// Constructor that takes a vector of length 2 (containing {num, den})
|
||||
Fraction(std::vector<int> vector);
|
||||
|
||||
/// Constructor that takes a key-value mapping (keys: 'num'. 'den')
|
||||
Fraction(std::map<std::string, int> mapping);
|
||||
/// Constructor that takes a key-value mapping (keys: 'num'. 'den')
|
||||
Fraction(std::map<std::string, int> mapping);
|
||||
|
||||
/// Calculate the greatest common denominator
|
||||
int GreatestCommonDenominator();
|
||||
/// Calculate the greatest common denominator
|
||||
int GreatestCommonDenominator();
|
||||
|
||||
/// Reduce this fraction (i.e. 640/480 = 4/3)
|
||||
void Reduce();
|
||||
/// Reduce this fraction (i.e. 640/480 = 4/3)
|
||||
void Reduce();
|
||||
|
||||
/// Return this fraction as a float (i.e. 1/2 = 0.5)
|
||||
float ToFloat();
|
||||
/// Return this fraction as a float (i.e. 1/2 = 0.5)
|
||||
float ToFloat();
|
||||
|
||||
/// Return this fraction as a double (i.e. 1/2 = 0.5)
|
||||
double ToDouble() const;
|
||||
/// Return this fraction as a double (i.e. 1/2 = 0.5)
|
||||
double ToDouble() const;
|
||||
|
||||
/// Return a rounded integer of the fraction (for example 30000/1001 returns 30)
|
||||
int ToInt();
|
||||
/// Return a rounded integer of the fraction (for example 30000/1001 returns 30)
|
||||
int ToInt();
|
||||
|
||||
/// Return the reciprocal as a Fraction
|
||||
Fraction Reciprocal() const;
|
||||
};
|
||||
/// Return the reciprocal as a Fraction
|
||||
Fraction Reciprocal() const;
|
||||
};
|
||||
|
||||
// Stream output operator for openshot::Fraction
|
||||
template<class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& o, const openshot::Fraction& frac) {
|
||||
std::basic_ostringstream<charT, traits> s;
|
||||
s.flags(o.flags());
|
||||
s.imbue(o.getloc());
|
||||
s.precision(o.precision());
|
||||
s << "Fraction(" << frac.num << ", " << frac.den << ")";
|
||||
return o << s.str();
|
||||
};
|
||||
}
|
||||
// Stream output operator for openshot::Fraction
|
||||
template<class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& o, const openshot::Fraction& frac) {
|
||||
std::basic_ostringstream<charT, traits> s;
|
||||
s.flags(o.flags());
|
||||
s.imbue(o.getloc());
|
||||
s.precision(o.precision());
|
||||
s << "Fraction(" << frac.num << ", " << frac.den << ")";
|
||||
return o << s.str();
|
||||
};
|
||||
|
||||
} // namespace openshot
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user